// JavaScript Document
function changeLinkColor(tabname){
document.getElementById(tabname).style.backgroundColor="#CC0033";
}

function setCountryValue() {

	var stateValue = document.form.SP.value;
	if ( stateValue.indexOf("US") != -1 ) {
		document.form.CN.value='US';
 	} else if ( stateValue.indexOf("MX") != -1 ) {
		document.form.CN.value='MX';
	} else if ( stateValue.indexOf("CA") != -1 ) {
		document.form.CN.value='CA';
	} 

}
function setStateValue() {
	var countryValue = document.form.CN.value;
	var invalidCountry = true;
	if ( countryValue == "US" || countryValue == "CA" || countryValue == "MX" ) {
		invalidCountry = false;		
	}
	if ( invalidCountry ) {
		document.form.SP.value='---';
	}
}
function setRadioChecked() {
  document.submitForm.Registered[0].checked= true;
}
function clearUserPwd() {
  document.getElementById('usr').value = '';
  document.getElementById('pwd').value = '';
}

//on submit this function is called
function submitEmail() {
	
	var field = document.form9.EM; 
	var str = field.value; 	

	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; 

//check if the email is valid
	if (!reg1.test(str) && reg2.test(str)) { 		
		//post the lead info to the formpost page in poptionaloffers which writes to the database
		
		if(document.form9.A1.value.length > 0)
		{
		  img1.src='http://www.poptionaloffers.com/learningemail/emailcapture.jsp?CLK='+document.form9.CLK.value+ '&EM=' + document.form9.EM.value +'&A1=' + document.form9.A1.value + '&A2=' + document.form9.A2.value + '&submit=submit';		
		} 
	} 
	else {
	//throw an error message
		alert("Please enter a valid e-mail address.");
		document.getElementById('learningtext').select();
	}
}

function submitEmail2() {
	var field = document.form9.EM; 	
	var str = field.value; 	
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; 

	if (!reg1.test(str) && reg2.test(str)) { 		
		//post the lead info to the formpost page in poptionaloffers which writes to the database
      if( document.form9.A1_1.value.length > 0 )
	  {
		 img2.src='http://www.poptionaloffers.com/learningemail/emailcapture.jsp?CLK='+document.form9.CLK.value+ '&EM=' + document.form9.EM.value +'&A1=' + document.form9.A1_1.value + '&A2=' + document.form9.A2_1.value + '&submit=submit';		
      }		
	} 
	
}
