// JavaScript Document
function nocolor(){
var i,cnt;
cnt=document.forms[0].elements.length;
for(i=0;i<cnt-1;i++){
document.forms[0].elements[i].style.backgroundColor="#FAFFF4";
}
}
var userid=/^[A-Za-z0-9\s\-]{1,10}$/; //for name
var user_name=/^[A-Za-z0-9\s\-]{1,45}[A-Za-z]$/; //for user first name
var user_lastname=/^[A-Za-z0-9\s\-]{1,45}[A-Za-z]$/; //for user last name
var user_address=/^[A-Za-z0-9\s\-]{1,45}[A-Za-z]$/; //for user last name
var cel=/^[0-9\s\-]{1,20}$/; //for Cell
var password=/^[A-Za-z0-9\s\-]{1,10}$/; //for password
var genC=/^[A-Za-z0-9\s\-@$%^&*]{1,45}[A-Za-z]$/;
var rexEmail=/^[a-zA-Z0-9_]+@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;  //for email

function vf(){
	nocolor();
	//This JavaScript portion is for user data confirmation. To check that user's entered data is correct for server.
	if(document.forms[0].elements['ui'].value.length==0)
	{
		document.getElementById("ui").style.backgroundColor="#ffccFF";
		document.forms[0].elements['ui'].focus();
				alert('Please Enter User Id');			
				document.x=false;
	}
	else if(document.forms[0].elements['ui'].value.search(userid)==-1)
	{
		document.getElementById("ui").style.backgroundColor="#ffccFF";
		document.forms[0].elements['ui'].focus();
				alert('Enter Valid User Id like (1548795) and characters should be less than 45 words.');			
				document.x=false;
	}
	else if(document.forms[0].elements['fn'].value.search(genC)==-1)
	{
		document.getElementById("fn").style.backgroundColor="#ffccFF";
		document.forms[0].elements['fn'].focus();
				alert('Please Enter  firstName');			
				document.x=false;
	}
	else if(document.forms[0].elements['fn'].value.search(genC)==-1)
	{
		document.getElementById("fn").style.backgroundColor="#ffccFF";
		document.forms[0].elements['fn'].focus();
				alert('Enter Valid  First Name');			
				document.x=false;
	}
	else if(document.forms[0].elements['ln'].value.length==0)
	{
		document.getElementById("ln").style.backgroundColor="#ffccFF";
		document.forms[0].elements['ln'].focus();
				alert('Please Enter  User lastName');			
				document.x=false;
	}
	else if(document.forms[0].elements['ln'].value.search(user_lastname)==-1)
	{
		document.getElementById("ln").style.backgroundColor="#ffccFF";
		document.forms[0].elements['ln'].focus();
				alert('Enter Valid last Name like (Mythyan) and characters should be less than 45 characters');			
				document.x=false;
	}
	else if(document.forms[0].elements['pw'].value.length==0)
	{
		document.getElementById("pw").style.backgroundColor="#ffccFF";
		document.forms[0].elements['pw'].focus();
				alert('Enter password like mypass123 and should be less than 10 characters');			
				document.x=false;
	}
	else if(document.forms[0].elements['pw'].value.search(password)==-1)
	{
		document.getElementById("pw").style.backgroundColor="#ffccFF";
		document.forms[0].elements['pw'].focus();
				alert('Enter password like mypass123 and should be less than 10 characters');			
				document.x=false;
	}
	
	else if(document.forms[0].elements['cp'].value.length==0)
	{
		document.getElementById("cp").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cp'].focus();
				alert(' Confirm password Does not match with passsword');			
				document.x=false;
	}
	else if(document.forms[0].elements['cp'].value.search(password)==-1)
	{
		document.getElementById("cp").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cp'].focus();
				alert('Confirm password Does not match with passsword');			
				document.x=false;
	}
	
	else if(document.forms[0].elements['pw'].value!=document.forms[0].elements['cp'].value)
	{
		document.getElementById("cp").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cp'].focus();
				alert('Your Confirm Password does not match with the password');			
				document.x=false;
	}
	
	else if(document.forms[0].elements['st'].value.length==0)
	{
		document.getElementById("st").style.backgroundColor="#ffccFF";
		document.forms[0].elements['st'].focus();
				alert('Enter  Address like House No M/1054');			
				document.x=false;
	}
	/*else if(document.forms[0].elements['st'].value.search(user_address)==-1)
	{
		document.getElementById("st").style.backgroundColor="#ffccFF";
		document.forms[0].elements['st'].focus();
				alert('Enter Valid Address like (House No M/1054) and characters should be less than 45 characters');			
				document.x=false;
	}*/
	
	else if(document.forms[0].elements['email'].value.length==0)
	{
		document.getElementById("email").style.backgroundColor="#ffccFF";
		document.forms[0].elements['email'].focus();
				alert('Please Enter a valid Email address Like order@premier786.com');			
				document.x=false;
	}
	else if(document.forms[0].elements['email'].value.search(rexEmail)==-1)
	{
		document.getElementById("email").style.backgroundColor="#ffccFF";
		document.forms[0].elements['email'].focus();
				alert('Please Enter a valid Email address Like order@premier786.com');			
				document.x=false;
	}
	
	
	/*else if(document.forms[0].elements['phone'].value.length==0)
	{
		document.getElementById("phone").style.backgroundColor="#ffccFF";
		document.forms[0].elements['phone'].focus();
				alert('Please Enter Telephone# like (0152251234567)');			
				document.x=false;
	}*/
	else if(document.forms[0].elements['phone'].value.search(cel)==-1)
	{
		document.getElementById("phone").style.backgroundColor="#ffccFF";
		document.forms[0].elements['phone'].focus();
				alert('Enter Valid Telephone# like (0152251234567)');			
				document.x=false;
	}
	
	else if(document.forms[0].elements['cellP'].value.length==0)
	{
		document.getElementById("cellP").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cellP'].focus();
				alert('Please Enter  cell# like (79891548754)');			
				document.x=false;
	}
	else if(document.forms[0].elements['cellP'].value.search(cel)==-1)
	{
		document.getElementById("cellP").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cellP'].focus();
				alert('Enter Valid cell like (79891548754)');			
				document.x=false;
	}
	
	
	
	/////this java Script portion is for Picker detail
	
	
		else if(document.forms[0].elements['pid'].value.length==0)
	{
		document.getElementById("pid").style.backgroundColor="#ffccFF";
		document.forms[0].elements['pid'].focus();
				alert('Please Enter User Id');			
				document.x=false;
	}
	else if(document.forms[0].elements['pid'].value.search(userid)==-1)
	{
		document.getElementById("pid").style.backgroundColor="#ffccFF";
		document.forms[0].elements['pid'].focus();
				alert('Enter Valid User Id like (1548795) and characters should be less than 45 words.');			
				document.x=false;
	}
	else if(document.forms[0].elements['fn2'].value.length==0)
	{
		document.getElementById("fn2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['fn2'].focus();
				alert('Please Enter  firstName');			
				document.x=false;
	}
	else if(document.forms[0].elements['fn2'].value.search(user_name)==-1)
	{
		document.getElementById("fn2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['fn2'].focus();
				alert('Enter Valid User firstName');			
				document.x=false;
	}
	else if(document.forms[0].elements['ln2'].value.length==0)
	{
		document.getElementById("ln2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['ln2'].focus();
				alert('Please Enter  User lastName');			
				document.x=false;
	}
	else if(document.forms[0].elements['ln2'].value.search(user_lastname)==-1)
	{
		document.getElementById("ln2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['ln2'].focus();
				alert('Enter Valid User last Name like (Mythyan) and characters should be less than 45 characters');			
				document.x=false;
	}
	/*else if(document.forms[0].elements['pw2'].value.length==0)
	{
		document.getElementById("pw2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['pw2'].focus();
				alert('Enter Numeric password like 1548745 and should be less than 45 characters');			
				document.x=false;
	}
	else if(document.forms[0].elements['pw2'].value.search(password)==-1)
	{
		document.getElementById("pw2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['pw2'].focus();
				alert('Enter Numeric password like 1548745 and should be less than 45 characters');			
				document.x=false;
	}*/
	
	/*else if(document.forms[0].elements['cp2'].value.length==0)
	{
		document.getElementById("cp2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cp2'].focus();
				alert('Please Enter Numeric Confirm password like 1548745 and should be less than 45 characters');			
				document.x=false;
	}
	else if(document.forms[0].elements['cp2'].value.search(password)==-1)
	{
		document.getElementById("cp2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cp2'].focus();
				alert('Enter Numeric Confirm password like 1548745 and should be less than 45 characters');			
				document.x=false;
	}
	
	else if(document.forms[0].elements['pw2'].value!=document.forms[0].elements['cp2'].value)
	{
		document.getElementById("cp").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cp'].focus();
				alert('Your Confirm Password does not match with the password');			
				document.x=false;
	}*/
	
	else if(document.forms[0].elements['st2'].value.length==0)
	{
		document.getElementById("st2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['st2'].focus();
				alert('Enter User Address like House No M/1054');			
				document.x=false;
	}
	else if(document.forms[0].elements['st2'].value.search(user_address)==-1)
	{
		document.getElementById("st2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['st2'].focus();
				alert('Enter Valid Address like (House No M/1054) and characters should be less than 45 characters');			
				document.x=false;
	}
	
	else if(document.forms[0].elements['cellP2'].value.length==0)
	{
		document.getElementById("cellP2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cellP2'].focus();
				alert('Please Enter  cell# like (0300-1548754)');			
				document.x=false;
	}
	else if(document.forms[0].elements['cellP2'].value.search(cel)==-1)
	{
		document.getElementById("cellP2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['cellP2'].focus();
				alert('Enter Valid cell like (0300-1234567)');			
				document.x=false;
	}
	else if(document.forms[0].elements['phone2'].value.length==0)
	{
		document.getElementById("phone2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['phone2'].focus();
				alert('Please Enter Telephone# like (051-1234567)');			
				document.x=false;
	}
	else if(document.forms[0].elements['phone2'].value.search(cel)==-1)
	{
		document.getElementById("phone2").style.backgroundColor="#ffccFF";
		document.forms[0].elements['phone2'].focus();
				alert('Enter Valid Telephone# like (092-2546321)');			
				document.x=false;
	}
	
	else
	{
				document.x=true;
	}	
}
