/**
 * @author jfujimaki
 */
function isEmail (s) { 
	var isEmail_re       = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; 
	return String(s).search (isEmail_re) != -1; 
}
function isProper(string) {
	   if (!string) return false;
	   var iChars = "0123456789*|,\":<>[]{}`\';()@&$#%";
	
	   for (var i = 0; i < string.length; i++) {
	      if (iChars.indexOf(string.charAt(i)) != -1)
	         return false;
	   }
	   return true;
	   
	} 
	function checkSpecialChars(string) {
	   if (!string) return false;
	   var iChars = "*|,\":<>[]{}`\';()@&$#%";
	
	   for (var i = 0; i < string.length; i++) {
	      if (iChars.indexOf(string.charAt(i)) != -1)
	         return false;
	   }
	   return true;
	} 

function showEmailPhone(combo){

	if (combo.options[combo.selectedIndex].value == 'Email') {
		//Hides Label for Phone and Textbox for Phone
		document.getElementById("PIID_23771_0").style.display = "none";
		
			
	}else if (combo.options[combo.selectedIndex].value == 'Phone')
	{
		
		//Show Label for Phone and TextBox for Phone
		document.getElementById("PIID_23771_0").style.display = "";
		document.getElementById("PIID_23771_0").focus();
	}else{
		//Hides Label for Phone and Textbox for Phone
		document.getElementById("PIID_23771_0").style.display = "none";
		

	}
}

function changeBackground(control){
	
	control.style.backgroundColor = "white";
}

function formValidation(form){
	
	if(!isProper(document.getElementById("PIID_21871_0").value)){
		alert("Please provide a valid Name");
		document.getElementById("PIID_21871_0").focus();
		document.getElementById("PIID_21871_0").style.backgroundColor = "yellow";
		return false;
		
	}else if(!isEmail(document.getElementById("PIID_21870_0").value)){
		alert("Please provide a valid Email Address");
		document.getElementById("PIID_21870_0").focus();
		document.getElementById("PIID_21870_0").style.backgroundColor = "yellow";		

		return false;
		
	}else if(document.getElementById("BestMethodContact").options[document.getElementById("BestMethodContact").selectedIndex].value == 'Phone'){
//		if (!isProper(document.getElementById("PIID_23771_0").value)){
			if(document.getElementById("PIID_23771_0").value == "") {
			alert("Please provide a phone number")				
			document.getElementById("PIID_23771_0").focus();
			document.getElementById("PIID_23771_0").style.backgroundColor = "yellow";
			return false;
		}
	}
	return true;

}

function formValidation2(form){
	
	 if (!isEmail(document.getElementById("PIID_21870_0").value)) {
	 	alert("Please provide a valid Email Address");
	 	document.getElementById("PIID_21870_0").focus();
	 	document.getElementById("PIID_21870_0").style.backgroundColor = "yellow";
		return false;
	 }else if(!isProper(document.getElementById("PIID_21871_0").value)){
		alert("Please provide a valid First name");
		document.getElementById("PIID_21871_0").focus();
		document.getElementById("PIID_21871_0").style.backgroundColor = "yellow";
		return false;
		
	}else if(!isProper(document.getElementById("PIID_21872_0").value)){
		alert("Please provide a valid Last name");
		document.getElementById("PIID_21872_0").focus();
		document.getElementById("PIID_21872_0").style.backgroundColor = "yellow";
		return false;
		
	}

	return true;

}

function checkEmail(){
	
	if(!isEmail(document.getElementById("emailToNl").value)){
		alert("Please provide a valid email address.");
		document.getElementById("emailToNl").focus();
		document.getElementById("emailToNl").style.backgroundColor = "yellow";
		return false;
	}else {
		return true;	
	}
	
}
//
