// JavaScript Document


function validatecontactus(contact)
{

if(contact.firstname.value=="")
 {alert("Field Empty. Please Enter The First Name")
 contact.firstname.focus();
 return false;
}

if(contact.lastname.value=="")
 {alert("Field Empty. Please Enter The Last Name")
 contact.lastname.focus();
 return false;
}

if(contact.dob1.value=="")
 {alert("Field Empty. Please Enter The Month Part of The Date of Birth")
 contact.dob1.focus();
 return false;
}

if(contact.dob2.value=="")
 {alert("Field Empty. Please Enter The Day Part of The Date of Birth")
 contact.dob2.focus();
 return false;
}

if(contact.dob3.value=="")
 {alert("Field Empty. Please Enter The Year Part of The Date of Birth")
 contact.dob3.focus();
 return false;
}

if(contact.dayphone1.value=="")
 {alert("Field Empty. Please Enter The Day Telephone Number Part 1")
 contact.dayphone1.focus();
 return false;
}

if(contact.dayphone2.value=="")
 {alert("Field Empty. Please Enter The Day Telephone Number Part 2")
 contact.dayphone2.focus();
 return false;
}

if(contact.dayphone3.value=="")
 {alert("Field Empty. Please Enter The Day Telephone Number Part 3")
 contact.dayphone3.focus();
 return false;
}



if(contact.eveningphone1.value=="")
 {alert("Field Empty. Please Enter The Evening Phone Number Part 1")
 contact.eveningphone1.focus();
 return false;
}
if(contact.eveningphone2.value=="")
 {alert("Field Empty. Please Enter The Evening Phone Number Part 2")
 contact.eveningphone2.focus();
 return false;
}
if(contact.eveningphone3.value=="")
 {alert("Field Empty. Please Enter The Evening Phone Number Part 3")
 contact.eveningphone3.focus();
 return false;
}





if(contact.email.value=="")
 {alert("Field Empty. Please Enter The Email Address")
 contact.email.focus();
 return false;
}


if(contact.med1.value=="")
 {alert("Field Empty. Please Select Your Medication")
 contact.med1.focus();
 return false;
}

if(contact.med1pills.value=="")
 {alert("Field Empty. Please Enter The Number of Pills Needed")
 contact.med1pills.focus();
 return false;
}


if(contact.daterequested.value=="")
 {alert("Field Empty. Please Enter the Needed by Date")
 contact.daterequested.focus();
 return false;
}




if(contact.pharmacyname.value=="")
 {alert("Field Empty. Please Enter the Pharmacy Name")
 contact.pharmacyname.focus();
 return false;
}

if(contact.pharmacyphone1.value=="")
 {alert("Field Empty. Please Enter the Pharmacy Phone Number")
 contact.pharmacyphone1.focus();
 return false;
}

if(contact.pharmacyphone2.value=="")
 {alert("Field Empty. Please Enter the Pharmacy Phone Number")
 contact.pharmacyphone2.focus();
 return false;
}

if(contact.pharmacyphone3.value=="")
 {alert("Field Empty. Please Enter the Pharmacy Phone Number")
 contact.pharmacyphone3.focus();
 return false;
}

if(contact.pharmacyaddress.value=="")
 {alert("Field Empty. Please Enter the Pharmacy Address")
 contact.pharmacyaddress.focus();
 return false;
}


if(contact.pharmacycity.value=="")
 {alert("Field Empty. Please Enter the Pharmacy City")
 contact.pharmacycity.focus();
 return false;
}

if(contact.pharmacystate.value=="")
 {alert("Field Empty. Please Enter the Pharmacy State")
 contact.pharmacystate.focus();
 return false;
}

if(contact.pharmacyzipcode.value=="")
 {alert("Field Empty. Please Enter the Pharmacy Zip Code")
 contact.pharmacyzipcode.focus();
 return false;
}



}	
	
function validmail(obj)
	{								 <!--  checking valid email address-->		
									
var EmailOk  = true
var Temp     = obj
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1

if(obj.value !=""){
if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
   {  
      EmailOk = false
      alert("Please enter a valid e-mail address!");
      Temp.value="";
      Temp.focus();
      return EmailOk;
   }
	}

}

function validnum(obj)
{//alert(event.keyCode)
  	if (navigator.appName=="Microsoft Internet Explorer")
	{
	//alert(event.keyCode)
		if((event.keyCode <48 || event.keyCode >57) || window.event.shiftKey )
		if (event.keyCode!=45)
		event.returnValue =false;
	}
	if (navigator.appName=="Netscape")
	{
		var num="0123456789";
	
		//If any value is not a number set return value to false
		for(var intloop=0;intloop<obj.value.length;intloop++)
		{
			//alert(num.indexOf(document.formDetails.txtAge.value.charAt(intloop)));
			if (-1==num.indexOf(obj.value.charAt(intloop)))
			{
				//document.formDetails.txtAge.value="";
				alert("Please enter numbers only")
				obj.value="";
				obj.focus()
				
			}
		}
			}
}

function same_as_billing()
							{
                                           var checkbox_status = document.forms['AffilliateSignUp'].elements['same'].checked
		             					   if ( !checkbox_status )
	                    								   {
									document.forms['AffilliateSignUp'].elements['same'].checked = checkbox_status
										document.forms['AffilliateSignUp'].elements['B_Firstname'].value = ''
										document.forms['AffilliateSignUp'].elements['B_Lastname'].value = ''
										document.forms['AffilliateSignUp'].elements['B_Address1'].value = ''
										document.forms['AffilliateSignUp'].elements['B_Address2'].value = ''
										document.forms['AffilliateSignUp'].elements['B_City'].value = ''
										document.forms['AffilliateSignUp'].elements['B_State'].value = ''
										document.forms['AffilliateSignUp'].elements['B_Zip'].value = ''
	    								document.forms['AffilliateSignUp'].elements['B_DayPhone'].value = ''
	   								 document.forms['AffilliateSignUp'].elements['B_EveningPhone'].value = ''
																}
															else
														{
							document.forms['AffilliateSignUp'].elements['same'].checked = checkbox_status
	document.forms['AffilliateSignUp'].elements['B_Firstname'].value = document.forms['AffilliateSignUp'].elements['Firstname'].value
	document.forms['AffilliateSignUp'].elements['B_Lastname'].value = document.forms['AffilliateSignUp'].elements['Lastname'].value
	document.forms['AffilliateSignUp'].elements['B_Address1'].value = document.forms['AffilliateSignUp'].elements['Address1'].value
	document.forms['AffilliateSignUp'].elements['B_Address2'].value = document.forms['AffilliateSignUp'].elements['Address2'].value
	document.forms['AffilliateSignUp'].elements['B_City'].value = document.forms['AffilliateSignUp'].elements['City'].value
	document.forms['AffilliateSignUp'].elements['B_State'].value = document.forms['AffilliateSignUp'].elements['State'].value
	document.forms['AffilliateSignUp'].elements['B_Zip'].value = document.forms['AffilliateSignUp'].elements['Zip'].value
	document.forms['AffilliateSignUp'].elements['B_DayPhone'].value = document.forms['AffilliateSignUp'].elements['DayPhone'].value
	document.forms['AffilliateSignUp'].elements['B_EveningPhone'].value = document.forms['AffilliateSignUp'].elements['EveningPhone'].value
															}
 									}
									
				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 isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;

      }
	  
	  
	  
	   function isValidKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if ((charCode == 60) ||(charCode == 33)  || (charCode == 62) || (charCode == 64)  || (charCode == 39)|| (charCode == 37)|| (charCode == 34)|| (charCode == 38)|| (charCode == 63))
            {
alert("Not A Valid Entry Key");
return false;}
else{
         return true;}

      }
	  
	  
	function checkEmail(checkString)
	{
    	var newstr = "";
    	var at = false;
    	var dot = false;
	
    	// DO SOME PRELIMINARY CHECKS ON THE DATA

	    // IF EMAIL ADDRESS HAS A '@' CHARACTER
    	if (checkString.indexOf("@") != -1) {
	      at = true;

	    // IF EMAIL ADDRESS HAS A '.' CHARACTER
    	} else if (checkString.indexOf(".") != -1) {
	      dot = true;
    	}
	    // PARSE REMAINDER OF STRING
    	for (var i = 0; i < checkString.length; i++) {
        	ch = checkString.substring(i, i + 1)
	        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
    	        || (ch == "@") || (ch == ".") || (ch == "_")
        	    || (ch == "-") || (ch >= "0" && ch <= "9")) {
     	           newstr += ch;
        	        if (ch == "@") {
            	        at=true;
	    	            }
                	if (ch == ".") {
    	                dot=true;
            	    }
	        }
    	}
	    if ((at == true) && (dot == true)) {
    	    return newstr;
		    }
	    else {
    	  // DISPLAY ERROR MESSAGE
	      alert ("Sorry, the email address you\nentered is not in the correct\nformat.  Format are xxxxxxxx@xxxxx.xxx");
    	  return"";
		    }
	}
function validateemail(field) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (field.value) || /None+/gi.test (field.value)){
return (true)
}
alert("Please reenter!  Only only a valid email address or the word None.");
field.value = '';
field.focus();
return (false)
}			