/* 	$VERSION = '3.4';	 */
/* include	me like this
<script type="text/javascript" 
	language="JavaScript1.3"
	src="/shaklee.js">
</script>
*/

//Active Controls run start, write params, run end
function ACStart(width,height,id)
{
    document.write('<OBJECT CLASSID="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width=' + width + ' height=' + height + ' id=' + id + ' ALIGN="middle">');

}


/* Disable Submit Button */
function disableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
		var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
			tempobj.disabled = true;
		}
	setTimeout('', 20000);
	return true;
	}
	else {
	alert("The form has been submitted.  You're not using IE 4+ or NS 6+, the submit button was not disabled, do not click submit again!");
	return false;
   }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function closeRemote() {
 timer = setTimeout('window.close();', 10);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
/*  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0; */
}

function checksearchrequired(which){
	if(which.requiredeMail_user.value == '')
	{
		alert("Please make sure the USER NAME was properly completed");
		return false;
	}
}

function checkloginrequired(which){
	if(which.requiredUser_Name.value == '')
	{
		alert("Please make sure the USER NAME was properly completed");
		return false;
	}
	if(which.requiredPassword.value == '')
	{
		alert("Please make sure the PASSWORD was properly completed");
		return false;
	}
}

function checkadminrequired(which){
	if(which.requiredFirst_Name.value == '')
	{
		alert("Please make sure the USER NAME was properly completed");
		return false;
	}
	if(which.requiredLast_Name.value == '')
	{
		alert("Please make sure the PASSWORD was properly completed");
		return false;
	}
}

function checkrequiredForget(which) {
	var pass=true;

	if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
				(tempobj.value=='' || tempobj.value.split(' ').join('').length==0))||
				(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==0)) {
					pass=false;
					break;
         	}
      	}
   	}
	}

	if (!pass) {
		shortFieldName=tempobj.name.substring(8,30).toUpperCase();

		alert("Please make sure the "+shortFieldName+" field was properly completed.");
		return false;
	}
   if(which.requiredEmail){ 
       var str =which.requiredEmail.value;
       if(!matchPattern(str,/^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/))
       {
   		  alert("Invalid E-MAIL ID");
           return false;
       }
   }
   if(which.requiredGraduation_Year){   
    	 if(isNaN(which.requiredGraduation_Year.value))
   	 {
   		  alert("Please make sure Graduation year is numeric");
		     return false;
   	 }
	}
}

// Functions added by Sivakumar.
function checkrequired(which,mode) {
	var pass=true;
   var special =true;
   var prof_flag=true;

	if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
				(tempobj.value=='' || tempobj.value.split(' ').join('').length==0))||
				(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==0)) {
               if(matchPattern(tempobj.name.substring(8,30),/(PROFESSION|DEGREE|SCHOOL_NAME|GRADUATION_YEAR|PRIMARY_SPECIALTY)/i)){
						if ( mode == 'Admin' )
						{
							alert("Please make sure the PROFESSION field was properly completed");
							return false;
						}
						else
						{
							prof_flag=false;
						}
               }
               else{
						pass=false;
						break;
               }
         	}
            if (((tempobj.type=="text"||tempobj.type=="textarea")&& matchPattern(tempobj.value, /['"]/))){
               special = false;
               break;
            }
      	}
   	}
	}

	if (!pass) {
		shortFieldName=tempobj.name.substring(8,30).toUpperCase();

		alert("Please make sure the "+shortFieldName+" field was properly completed.");
		return false;
	}
	else {

   	if (!special) {
   		shortFieldName=tempobj.name.substring(8,30).toUpperCase();
   
   		alert("The field "+shortFieldName+" should not contain the characters \' or \".");
   		return false;
   	}

		if(isNaN(which.requiredPhone1.value) || isNaN(which.requiredPhone2.value) || isNaN(which.requiredPhone3.value) || isNaN(which.PhoneEx.value)){
			alert ("Please make sure the PHONE numbers are in numeric.");
			return false;
		}

		var str =which.requiredEmail.value;
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-MAIL ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-MAIL ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-MAIL ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-MAIL ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-MAIL ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-MAIL ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-MAIL ID");
		    return false;
		 }
		 
		if(which.requiredProfession.value == "Other" && (which.Profession_Other.value == 'Please specify' || 	
							which.Profession_Other.value == '' || which.Profession_Other.value.split(' ').join('').length==0 )) {
			if ( mode == 'Admin' )
			{
				alert("Please make sure the PROFESSION(Other) field was properly completed");
				return false;
			}
			else
			{
         	prof_flag=false;
			}
		}	

		if(which.requiredAddress_Type.value == "Other" && (which.AddressFor_Other.value == 'Please specify' || 
							which.AddressFor_Other.value == '' || which.AddressFor_Other.value.split(' ').join('').length==0 )) {
			alert("Please make sure the ADDRESSTYPE(Other) field was properly completed");
			return false;
		}	

/*		
      if(isNaN(which.requiredAddress_ZipCode.value)) {
         alert("Please make sure the ZIP/POSTAL CODE field contains only number.");
         return false;
      }
*/
      var Graduation_Year = which.requiredGraduation_Year.value;
		if(isNaN(Graduation_Year) && Graduation_Year!='' && Graduation_Year.split(' ').join('').length!=0) {
			alert("Please make sure the GRADUATION YEAR field contains only number.");
			return false;
		}
		if (Graduation_Year < 1000 && Graduation_Year!='' && Graduation_Year.split(' ').join('').length!=0) {
			alert("Please enter the GRADUATION YEAR in four digits.");
			return false;
		}
      if(!prof_flag){
     		which.action = 'util_register3.htm';    
      }
	}
}

<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}


function checkFields(which) {

	var pass=false;

	if (document.images) {

		for (i=0; i<which.length; i++) {

			var tempobj=which.elements[i];

			if (tempobj.type == "text" || tempobj.type == "textarea") {
				tempobj.value = trim(tempobj.value);
			}


			if (((tempobj.type=="text" || tempobj.type=="textarea") && 
			tempobj.value!='') || (tempobj.type.toString().charAt(0)=="s" && 
			tempobj.selectedIndex>0)) { //If anyone of the fields has value,
												 // pass is set to true.

				pass=true;
				break;
			}
		}
	}

	if (!pass) {

		alert("Please fill in at least any one of the field and then click 'Get Member' button.");
		return false;
	}
	else
		return true;
}

function trim(val) { //Remove spaces at the beginning and end of the values

	val = val.replace(/^\s+/, '');
	val = val.replace(/\s+$/, '');
	return val;

}


function delete_member_confirm(val)
{
	
	var memberName = val;
	if ( memberName == '')
	{
		alert("Please enter the member name to be deleted!!!");		
		return false;
	}
	else
	{
		var name=confirm("Are you sure to delete this member !!!");

		if (name==true)
		{
				 return true;
		}
		else
		{
				 return false;
		}
	}
}

function matchPattern(val, pattern)
{
    var re = new RegExp(pattern);
    myArray = re.exec(val);
    return (myArray == null) ? false : true;
}
