
var downStrokeField;
function autojump(fieldName,nextFieldName,fakeMaxLength)
{
	var myForm=document.forms[document.forms.length - 1];
	var myField=myForm.elements[fieldName];
	myField.nextField=myForm.elements[nextFieldName];

	if (myField.maxLength == null)
	myField.maxLength=fakeMaxLength;

	myField.onkeydown=autojump_keyDown;
	myField.onkeyup=autojump_keyUp;
}

function autojump_keyDown()
{
	this.beforeLength=this.value.length;
	downStrokeField=this;
}

function autojump_keyUp()
{
	if (
	(this == downStrokeField) && 
	(this.value.length > this.beforeLength) && 
	(this.value.length >= this.maxLength)
	)
	this.nextField.focus();
	downStrokeField=null;
}

//this function is modified by Sharadha M-Roche WMS Team - Offshore
function checkuncheck(theBox)
{  
  bName  = theBox.name;         
  if (theBox.checked) 
  {
		if (bName == 'bonivachk')
		{
			document.forms[0].fosamaxchk.checked= false;
			//document.forms[0].actonelchk.checked = false;
			document.forms[0].otherchk.checked = false;
			document.forms[0].nonechk.checked = false;  
		}
		if (bName == 'fosamaxchk')
		{
			document.forms[0].bonivachk.checked= false;
			//document.forms[0].actonelchk.checked = false;
			document.forms[0].otherchk.checked = false;
			document.forms[0].nonechk.checked = false;    
		}
	/*	if (bName == 'actonelchk')
		{
			document.forms[0].bonivachk.checked= false;
			document.forms[0].fosamaxchk.checked= false;
			document.forms[0].otherchk.checked = false;
			document.forms[0].nonechk.checked = false;      
		}*/
		if (bName == 'otherchk')
		{
			document.forms[0].bonivachk.checked= false;
			document.forms[0].fosamaxchk.checked= false;
			//document.forms[0].actonelchk.checked = false;
			document.forms[0].nonechk.checked = false;        
		}
		if (bName == 'nonechk')
		{
			document.forms[0].bonivachk.checked= false;
			document.forms[0].fosamaxchk.checked= false;
			//document.forms[0].actonelchk.checked = false;
			document.forms[0].otherchk.checked = false;
		}
  } 
}

function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function ClickGeneralAll(obj)
{		
	document.Form1.GeneralMail.checked = obj.checked;
	document.Form1.GeneralEmail.checked = obj.checked;
	return true;
}
function ClickMyBonivaAll(obj)
{
	document.Form1.MyBonivaProgramMail.checked = obj.checked;
	document.Form1.MyBonivaProgramEmail.checked = obj.checked;
	document.Form1.MyBonivaProgramPhone.checked = obj.checked;
	return true;
}

function ClickBoneDivasAll(obj)
{
	document.Form1.BoneDivasMail.checked = obj.checked;
	document.Form1.BoneDivasEmail.checked = obj.checked;  
	return true;
}
function ClickRallySallyAll(obj)
{
	document.Form1.RallySallyMail.checked = obj.checked;
	document.Form1.RallySallyEmail.checked = obj.checked;  
	return true;
}
function UnCheckGeneralAll(obj)
{	
	if 	(!obj.checked)
	{
		document.Form1.GeneralAll.checked = obj.checked;	
	}	
}
function UnCheckMyBonivaAll(obj)
{
	if (!obj.checked)
	{
		document.Form1.MyBonivaProgramAll.checked = obj.checked;	
	}
}
function UnCheckBoneDivasAll(obj)
{
	if (!obj.checked)
	{
		document.Form1.BoneDivasAll.checked = obj.checked;	
	}
}
function UnCheckRallySallyAll(obj)
{
	if (!obj.checked)
	{
		document.Form1.RallySallyAll.checked = obj.checked;	
	}
}

function Trim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function signin_pcode_validation()
{	
	document.getElementById('passwordtxtlbl').style.color='black';	
	document.getElementById('emailtxtlbl').style.color='black';
	var err = false;
	/************************ Zip code ****************/

	document.forms[0].ziptxt.value = Trim(document.forms[0].ziptxt.value)	
	//zipcode empty check
	if(document.forms[0].ziptxt.value=='')
	{
		document.getElementById('ziptxtlbl').style.color='red';		
		document.forms[0].ziptxt.focus();
		err=true;
	}
	else
	{
		document.getElementById('ziptxtlbl').style.color='black';		
	}
	
	//zipcode valid check	
	var zipRE = /^\d{5}(-\d{4})?$/;
	if (!zipRE.test(document.forms[0].ziptxt.value)) 
	{			
		document.forms[0].ziptxt.focus();
		document.forms[0].ziptxt.select();		
		document.getElementById('ziptxtlbl').style.color='red';		
		err=true;
	}
	else
	{
		document.getElementById('ziptxtlbl').style.color='black';		
	}
	/************************ Priority Code ****************/
	//Priority code check
	document.forms[0].prioritytxt.value = Trim(document.forms[0].prioritytxt.value)
	if(document.forms[0].prioritytxt.value=='')
	{
		document.getElementById('prioritytxtlbl').style.color='red';		
		document.forms[0].prioritytxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('prioritytxtlbl').style.color='black';		
	}

	//Priority code valid check
	// ** digits do not repeat ** var pcodeRE = /^([1-9])(?!\1)([1-9])(?!\1|\2)([1-9])(?!\1|\2|\3)([1-9])$/;
	var pcodeRE = /^([1-9])([0-9]){7}$/;
	if(!pcodeRE.test(document.forms[0].prioritytxt.value))
	{
		document.getElementById('prioritytxtlbl').style.color='red';		
		document.forms[0].prioritytxt.focus();
		document.forms[0].prioritytxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('prioritytxtlbl').style.color='black';		
	}

	
	if (err == true)
	{	
		document.getElementById('errorlbl').innerHTML = "We're sorry but some pieces of information are invalid or missing. The problem areas are highlighted in red. Please correct and submit your information again."	
		return false;	
	}	
	else
	{
		return true;
	}		
}

function signin_email_validation()
{	
	document.getElementById('prioritytxtlbl').style.color='black';
	document.getElementById('ziptxtlbl').style.color='black';
	var err = false;
	/************************ Password ****************/
	//Password empty check
	document.forms[0].passwordtxt.value = Trim(document.forms[0].passwordtxt.value)
	if(document.forms[0].passwordtxt.value=='')
	{
		document.getElementById('passwordtxtlbl').style.color='red';		
		document.forms[0].passwordtxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('passwordtxtlbl').style.color='black';		
	}

	//Password valid check
	var passwordRE = /^[a-zA-Z0-9]\w{5,10}$/;
	if(!passwordRE.test(document.forms[0].passwordtxt.value))
	{
		document.getElementById('passwordtxtlbl').style.color='red';		
		document.forms[0].passwordtxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('passwordtxtlbl').style.color='black';		
	}

	/************************ Email ****************/

	document.forms[0].emailtxt.value = Trim(document.forms[0].emailtxt.value)	
	//Email empty check
	if(document.forms[0].emailtxt.value=='')
	{
		document.getElementById('emailtxtlbl').style.color='red';		
		document.forms[0].emailtxt.focus();
		err=true;
	}
	else
	{
		document.getElementById('emailtxtlbl').style.color='black';		
	}
	
	//Email valid check	
	var emailRE  = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!emailRE.test(document.forms[0].emailtxt.value)) 
	{			
		document.forms[0].emailtxt.focus();
		document.forms[0].emailtxt.select();		
		document.getElementById('emailtxtlbl').style.color='red';		
		err=true;
	}
	else
	{
		document.getElementById('emailtxtlbl').style.color='black';		
	}
	
	if (err == true)
	{	
		document.getElementById('errorlbl').innerHTML = "We're sorry but some pieces of information are invalid or missing. The problem areas are highlighted in red. Please correct and submit your information again."	
		return false;	
	}	
	else
	{
		return true;
	}		
}

function registration_step2_Validation()
{
	if(document.forms[0].delivery1.checked)
	{
		document.forms[0].delivery2.checked = false;
		document.forms[0].delivery3.checked = false;
		document.forms[0].delivery4.checked = false;		
		
		document.forms[0].pretxt.value = '';
		document.forms[0].exchtxt.value	= '';
		document.forms[0].numtxt.value	= '';
		document.forms[0].dayddl.selectedIndex = 0;	

	}
	
		document.forms[0].delivery2.disabled = document.forms[0].delivery1.checked;
		document.forms[0].delivery3.disabled = document.forms[0].delivery1.checked;
		document.forms[0].delivery4.disabled = document.forms[0].delivery1.checked;
		
		document.forms[0].pretxt.disabled	= document.forms[0].delivery1.checked;
		document.forms[0].exchtxt.disabled	= document.forms[0].delivery1.checked;
		document.forms[0].numtxt.disabled	= document.forms[0].delivery1.checked;
		document.forms[0].dayddl.disabled	= document.forms[0].delivery1.checked;

	
	if((document.forms[0].delivery2.checked)||(document.forms[0].delivery3.checked)||(document.forms[0].delivery4.checked))
	{
		document.forms[0].delivery1.checked = false;
		
		document.forms[0].pretxt.disabled = false;
		document.forms[0].exchtxt.disabled= false;
		document.forms[0].numtxt.disabled = false;
		document.forms[0].dayddl.disabled = false;			
	}	
}

function registration_step1_Validation()
{
	var err = false;
	/************************ Zipcode ****************/
	//Zip empty check	
	document.forms[0].ziptxt.value = Trim(document.forms[0].ziptxt.value)
	if(document.forms[0].ziptxt.value=='')
	{
		document.getElementById('ziptxtlbl').style.color='red';		
		document.forms[0].ziptxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('ziptxtlbl').style.color='black';		
	}

	//Zip valid check
	var zipRE = /^\d{5}(-\d{4})?$/;
	if(!zipRE.test(document.forms[0].ziptxt.value))
	{
		document.getElementById('ziptxtlbl').style.color='red';		
		document.forms[0].ziptxt.focus();
		document.forms[0].ziptxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('ziptxtlbl').style.color='black';		
	}
	
	/************************ State ****************/
	//State valid check
	if(document.forms[0].stateddl.value=='')
	{
		document.getElementById('stateddllbl').style.color='red';		
		document.forms[0].stateddl.focus();
		err=true;	
	}
	else
	{
		document.getElementById('stateddllbl').style.color='black';		
	}

	/************************ Address ****************/
	//City empty check
	document.forms[0].citytxt.value = Trim(document.forms[0].citytxt.value)
	if(document.forms[0].citytxt.value=='')
	{
		document.getElementById('citytxtlbl').style.color='red';		
		document.forms[0].citytxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('citytxtlbl').style.color='black';		
	}

	//City valid check
	//var cityRE = /^[A-za-z '\.-]+$/;
	var cityRE=/^[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC '\.-]+$/
	if(!cityRE.test(document.forms[0].citytxt.value))
	//if (!DoMatch(document.forms[0].regularExprCity.value,document.forms[0].citytxt.value))		
	{
		document.getElementById('citytxtlbl').style.color='red';		
		document.forms[0].citytxt.focus();
		document.forms[0].citytxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('citytxtlbl').style.color='black';		
	}

	/*********************
	*** Address ****************/
	//Address1 empty check
	document.forms[0].address1txt.value = Trim(document.forms[0].address1txt.value)
	if(document.forms[0].address1txt.value=='')
	{
		document.getElementById('address1txtlbl').style.color='red';		
		document.forms[0].address1txt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('address1txtlbl').style.color='black';		
	}

	//Address1 valid check
	//var addressRE = /^[a-zA-Z\d]+(([\'\,\.\- #][a-zA-Z\d ])?[a-zA-Z\d]*[\.]*)*$/;	
	var addressRE = /^[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC\u0030-\u0039]+(([\'\,\.\- #][\u0041-\u005A\u0061-\u007a\u00C0-\u00FC\u0030-\u0039 ])?[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC\u0030-\u0039]*[\.]*)*$/;	
	if(!addressRE.test(document.forms[0].address1txt.value))
	//if (!DoMatch(document.forms[0].regularExprAddr.value,document.forms[0].address1txt.value))		
	{
		document.getElementById('address1txtlbl').style.color='red';		
		document.forms[0].address1txt.focus();
		document.forms[0].address1txt.select();
		err=true;
	}	
	else
	{
		document.getElementById('address1txtlbl').style.color='black';		
	}

	/************************ Last Name ****************/
	//var firstRE = /^[A-za-z '\.-]+$/;
	//var firstRE = /^[\w '\.-]+$/;
	var firstRE = /^[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC '\.-]+$/
	//var firstRE = 

	//Lastname empty check
	var re = new RegExp("");	
	document.forms[0].lasttxt.value = Trim(document.forms[0].lasttxt.value)
	if(document.forms[0].lasttxt.value=='')
	{
		document.getElementById('lasttxtlbl').style.color='red';		
		document.forms[0].lasttxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('lasttxtlbl').style.color='black';		
	}

	//Lastname valid check		
	if(!firstRE.test(document.forms[0].lasttxt.value))
	//if (!DoMatch(document.forms[0].regularExpName.value,document.forms[0].lasttxt.value))		
	{
		document.getElementById('lasttxtlbl').style.color='red';		
		document.forms[0].lasttxt.focus();
		document.forms[0].lasttxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('lasttxtlbl').style.color='black';		
	}

	/************************ First Name ****************/
	//Firstname empty check
	document.forms[0].firsttxt.value = Trim(document.forms[0].firsttxt.value)
	if(document.forms[0].firsttxt.value=='')
	{
		document.getElementById('firsttxtlbl').style.color='red';		
		document.forms[0].firsttxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('firsttxtlbl').style.color='black';		
	}

	//Firstname valid check
	//if (!DoMatch(document.forms[0].firsttxt.value))
	if(!firstRE.test(document.forms[0].firsttxt.value))
	{
		document.getElementById('firsttxtlbl').style.color='red';		
		document.forms[0].firsttxt.focus();
		document.forms[0].firsttxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('firsttxtlbl').style.color='black';		
	}


	/************************ Password ****************/
	//Password confirm empty check
	document.forms[0].password2txt.value = Trim(document.forms[0].password2txt.value)
	if(document.forms[0].password2txt.value=='')
	{
		document.getElementById('password2txtlbl').style.color='red';		
		document.forms[0].password2txt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('password1txtlbl').style.color='black';		
	}

	//Password confirmation check
	if (document.forms[0].password1txt.value!='')
	{
		if(document.forms[0].password1txt.value != document.forms[0].password2txt.value)
		{
			document.getElementById('password2txtlbl').style.color='red';		
			document.forms[0].password2txt.focus();
			document.forms[0].password2txt.select();
			err=true;		
		}
		else
		{
			document.getElementById('password2txtlbl').style.color='black';		
		}
	}
	//Password empty check
	document.forms[0].password1txt.value = Trim(document.forms[0].password1txt.value)
	if(document.forms[0].password1txt.value=='')
	{
		document.getElementById('password1txtlbl').style.color='red';		
		document.forms[0].password1txt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('password1txtlbl').style.color='black';		
	}

	//Password valid check
	var passwordRE = /^[a-zA-Z0-9]\w{5,10}$/;
	if(!passwordRE.test(document.forms[0].password1txt.value))
	{
		document.getElementById('password1txtlbl').style.color='red';		
		document.forms[0].password1txt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('password1txtlbl').style.color='black';		
	}

	/************************ Email ****************/

	document.forms[0].emailtxt.value = Trim(document.forms[0].emailtxt.value)	
	//Email empty check
	if(document.forms[0].emailtxt.value=='')
	{
		document.getElementById('emailtxtlbl').style.color='red';		
		document.forms[0].emailtxt.focus();
		err=true;
	}
	else
	{
		document.getElementById('emailtxtlbl').style.color='black';		
	}
	
	//Email valid check	
	var emailRE  = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!emailRE.test(document.forms[0].emailtxt.value)) 
	{			
		document.forms[0].emailtxt.focus();
		document.forms[0].emailtxt.select();		
		document.getElementById('emailtxtlbl').style.color='red';		
		err=true;
	}
	else
	{
		document.getElementById('emailtxtlbl').style.color='black';		
	}

		
	
	if (err == true)
	{
		toggleLayer('errordivlbl');		
		return false;	
	}	
	else
	{
		//toggleLayer('errordivlbl');		
		return true;
	}
}

function unsubscribe_Validation()
{
	var err = false;
	/************************ Zipcode ****************/
	//Zip empty check	
	document.forms[0].ziptxt.value = Trim(document.forms[0].ziptxt.value)
	if(document.forms[0].ziptxt.value=='')
	{
		document.getElementById('ziplbl').style.color='red';		
		document.forms[0].ziptxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('ziplbl').style.color='black';		
	}

	//Zip valid check
	var zipRE = /^\d{5}(-\d{4})?$/;
	if(!zipRE.test(document.forms[0].ziptxt.value))
	{
		document.getElementById('ziplbl').style.color='red';		
		document.forms[0].ziptxt.focus();
		document.forms[0].ziptxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('ziplbl').style.color='black';		
	}
	
	/************************ State ****************/
	//State valid check
	if(document.forms[0].stateddl.value=='')
	{
		document.getElementById('statelbl').style.color='red';		
		document.forms[0].stateddl.focus();
		err=true;	
	}
	else
	{
		document.getElementById('statelbl').style.color='black';		
	}

	/************************ Address ****************/
	//City empty check
	document.forms[0].citytxt.value = Trim(document.forms[0].citytxt.value)
	if(document.forms[0].citytxt.value=='')
	{
		document.getElementById('citylbl').style.color='red';		
		document.forms[0].citytxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('citylbl').style.color='black';		
	}

	//City valid check
	//var cityRE = /^[A-za-z '\.-]+$/;
	var cityRE=/^[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC '\.-]+$/
	if(!cityRE.test(document.forms[0].citytxt.value))
	{
		document.getElementById('citylbl').style.color='red';		
		document.forms[0].citytxt.focus();
		document.forms[0].citytxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('citylbl').style.color='black';		
	}

	/************************ Address ****************/
	//Address1 empty check
	document.forms[0].address1txt.value = Trim(document.forms[0].address1txt.value)
	if(document.forms[0].address1txt.value=='')
	{
		document.getElementById('address1lbl').style.color='red';		
		document.forms[0].address1txt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('address1lbl').style.color='black';		
	}

	//Address1 valid check
	//var addressRE = /^[a-zA-Z\d]+(([\'\,\.\- #][a-zA-Z\d ])?[a-zA-Z\d]*[\.]*)*$/;
	var addressRE = /^[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC\u0030-\u0039]+(([\'\,\.\- #][\u0041-\u005A\u0061-\u007a\u00C0-\u00FC\u0030-\u0039 ])?[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC\u0030-\u0039]*[\.]*)*$/;	
	if(!addressRE.test(document.forms[0].address1txt.value))
	{
		document.getElementById('address1lbl').style.color='red';		
		document.forms[0].address1txt.focus();
		document.forms[0].address1txt.select();
		err=true;
	}	
	else
	{
		document.getElementById('address1lbl').style.color='black';		
	}

	/************************ Last Name ****************/
	//var firstRE = /^[A-za-z '\.-]+$/;
	var firstRE = /^[\u0041-\u005A\u0061-\u007a\u00C0-\u00FC '\.-]+$/
	//var firstRE = 

	//Lastname empty check
	document.forms[0].lastNametxt.value = Trim(document.forms[0].lastNametxt.value)
	if(document.forms[0].lastNametxt.value=='')
	{
		document.getElementById('lastNamelbl').style.color='red';		
		document.forms[0].lastNametxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('lastNamelbl').style.color='black';		
	}

	//Lastname valid check	
	//if (!DoMatch(document.forms[0].lastNametxt.value))		
	if(!firstRE.test(document.forms[0].lastNametxt.value))
	{
		document.getElementById('lastNamelbl').style.color='red';		
		document.forms[0].lastNametxt.focus();
		document.forms[0].lastNametxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('lastlbl').style.color='black';		
	}

	/************************ First Name ****************/
	//Firstname empty check
	document.forms[0].firstNametxt.value = Trim(document.forms[0].firstNametxt.value)
	if(document.forms[0].firstNametxt.value=='')
	{
		document.getElementById('firstNamelbl').style.color='red';		
		document.forms[0].firstNametxt.focus();
		err=true;
	}	
	else
	{
		document.getElementById('firstNamelbl').style.color='black';		
	}

	//Firstname valid check
	if(!firstRE.test(document.forms[0].firstNametxt.value))
	{
		document.getElementById('firstNamelbl').style.color='red';		
		document.forms[0].firstNametxt.focus();
		document.forms[0].firstNametxt.select();
		err=true;
	}	
	else
	{
		document.getElementById('firstNamelbl').style.color='black';		
	}

	/************************ Email ****************/

	document.forms[0].emailtxt.value = Trim(document.forms[0].emailtxt.value)	
	//Email empty check
	if(document.forms[0].emailtxt.value=='')
	{
		document.getElementById('emaillbl').style.color='red';		
		document.forms[0].emailtxt.focus();
		err=true;
	}
	else
	{
		document.getElementById('emaillbl').style.color='black';		
	}
	
	//Email valid check	
	var emailRE  = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!emailRE.test(document.forms[0].emailtxt.value)) 
	{			
		document.forms[0].emailtxt.focus();
		document.forms[0].emailtxt.select();		
		document.getElementById('emaillbl').style.color='red';		
		err=true;
	}
	else
	{
		document.getElementById('emaillbl').style.color='black';		
	}
	
	if (err == true)
	{
		toggleLayer('errordivlbl');		
		alert(err);
		return false;	
	}	
	else
	{
		toggleLayer('errordivlbl');		
		return true;
	}
}
//FUNCTION TO SHOW AND HIDE THE QUESTIONS IN REGISTER PAGE

	

