
function checkSponsor(that) {
	
	if(that.value == 2) {
		for(i = 0; i < that.form.checkWhere.length; i++) {
			that.form.checkWhere[i].checked = false;
			that.form.checkWhere[i].disabled = true; 
			that.form.checkWhere[i].readOnly = true;
		}
	} else {
		for(i = 0; i < that.form.checkWhere.length; i++) {
			that.form.checkWhere[i].disabled = false; 
			that.form.checkWhere[i].readOnly = false;
		}
	}
}


function checkChecks(that, off) {
	if(off == 1) {
		if(that.checked == true) { 
			for(i = 0; i < that.form.checkWhere.length - 1; i++) {
				that.form.checkWhere[i].checked = false; 
			}
		}	
	} else {
		if(that.checked == true) { 
			that.form.checkWhere[that.form.checkWhere.length - 1].checked = false; 
		}
	} 
}


						
function validate(){
	if (trimSpaces(window.document.frmInsert.First_Name.value)==""){
		window.alert ("Please enter your first name.");
		return false;
	} 
	if (trimSpaces(window.document.frmInsert.Last_Name.value)==""){
		window.alert ("Please enter your last name.");
		return false;
	} 
	
	if (trimSpaces(window.document.frmInsert.DOB_year.value)==""){
		window.alert ("Please enter your year of birth.");
		return false;
	} 
	
	if (trimSpaces(window.document.frmInsert.Email.value)==""){
		window.alert ("Please enter an e-mail address.");
		return false;
	} 	
	
	if (trimSpaces(window.document.frmInsert.Phone.value)==""){
		window.alert ("Please enter your phone.");
		return false;
	} 

	if (trimSpaces(window.document.frmInsert.DOB_year.value)==""){
		window.alert ("Please enter your year of birth.");
		return false;
	}	
	
	if (trimSpaces(window.document.frmInsert.flown.value)==""){
		window.alert ("Please select how many times you've flown with JetBlue.");
		return false;
	}	
	
	if (trimSpaces(window.document.frmInsert.HomeAirportCode.value)==""){
		window.alert ("Please select a home airport.");
		return false;
	}	

	//Email Validation - start
	var email = window.document.frmInsert.Email.value

	var invalid = ' /:,;'

	for(var i=0; i<invalid.length; i++)
	{
		var badChar = invalid.charAt(i)

		if (email.indexOf(badChar,0) != -1)
		{
			alert( 'The e-mail address you entered \ncontains one or more invalid characters.' )
			return false;
		}
	}

	var atSignPos = email.indexOf('@',1)

	if (atSignPos == -1)
	{
		alert( 'The e-mail address you entered \nis missing its @ sign.' )
		return false;
	}
	else if (email.indexOf('@',atSignPos+1) != -1)
	{
		alert( 'The e-mail address you entered \ncontains too many @ signs.' )
		return false;
	}

	var dotPos = email.indexOf('.',atSignPos+2)

	if (dotPos == -1)
	{
		alert( 'The e-mail address you entered \nis missing its extension.' )
		return false;
	}
	else if (dotPos+3 > email.length)
	{
		alert( 'The e-mail address you entered appears\nto use an invalid extension.' )
		return false;
	}
	// Validation - end
	
	/*if (trimSpaces(window.document.frmInsert.Phone.value)==""){
		window.alert ("Please enter a phone number.");
		return false;
	}*/
	
	
	if (window.document.frmInsert.readrules.checked == false){
		window.alert ("Please acknowledge reading the rules of this promotion.");
		return false;
	}
	
	
window.document.frmInsert.btnSubmit.value = 'Please wait....';	
/*window.document.frmInsert.Address_Line.value =  window.document.frmInsert.addr1.value + ',' + window.document.frmInsert.addr2.value + ',' + window.document.frmInsert.city.value + ',' + window.document.frmInsert.state.value;	*/
 

 return true;
} 

//this function will strip preceding and following 
//spaces
//
function trimSpaces(sDataToTrim)
{
	var sReturnDataF = '';
	var sReturnDataE = '';
	var bFrontDone = false;
	var bEndDone = false;

	//strip leading spaces
	//
	for(x=0;x<sDataToTrim.length;x++)
	{
		//if not a space, append to the return
		//value
		//
		if(sDataToTrim.charAt(x)!=' ')
		{
			sReturnDataF = sReturnDataF + sDataToTrim.charAt(x);
			bFrontDone = true;
		}
		else
		{
			if(bFrontDone)
				sReturnDataF = sReturnDataF + sDataToTrim.charAt(x);
		}	
	}

	//strip trailing spaces
	//
	for(x=sReturnDataF.length-1;x>=0;x--)
	{
		//if not a space, append to the return
		//value
		//
		if(sReturnDataF.charAt(x)!=' ')
		{
			sReturnDataE = sReturnDataF.charAt(x) + sReturnDataE;
			bEndDone = true;
		}
		else
		{
			if(bEndDone)
				sReturnDataE = sReturnDataF.charAt(x) + sReturnDataE;
		}	
	}
	return sReturnDataE;
}

ie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4));
function mouseOnBlack()
{if (ie4) {event.srcElement.style.color = "#000000";}}
function mouseOffBlack()
{if (ie4){event.srcElement.style.color = "#FFFFFF";}}