

function validate()
{
	
	
	
	if(trim(document.getElementById('login').value)=="")
	{
		alert("Please specify User Name.");
		document.getElementById('login').focus();
		return false;
		
	}
	if(trim(document.getElementById('password').value) =="")
	{
		alert("Please specify password.");
		document.getElementById('password').focus();
		return false;
		
	}
	if(trim(document.getElementById('cPassword').value )=="")
	{
		alert("Please confirm your password.");
		document.getElementById('cPassword').focus();
		return false;
		
	}
	if(trim(document.getElementById('cPassword').value ) != trim(document.getElementById('password').value))
	{
		alert("Password doesn't matches.");
		document.getElementById('cPassword').focus();
		return false;
	}
	if(trim(document.getElementById('hintQuestion').value )=="")
	{
		alert("Please specify hint question.");
		document.getElementById('hintQuestion').focus();
		return false;
		
	}
	if(trim(document.getElementById('hintAnswer').value )=="")
	{
		alert("Please specify hint answer.");
		document.getElementById('hintAnswer').focus();
		return false;
		
	}
	if(trim(document.getElementById('fName').value )=="")
	{
		alert("Please specify first name.");
		document.getElementById('fName').focus();
		return false;
		
	}
	if(trim(document.getElementById('lName').value )=="")
	{
		alert("Please specify last name.");
		document.getElementById('lName').focus();
		return false;
		
	}
	if(trim(document.getElementById('email').value )=="")
	{
		alert("Please specify email address.");
		document.getElementById('email').focus();
		return false;
		
	}
	var contactEmail = trim(document.getElementById( 'email' ).value);
	if(contactEmail !="")
	{
		if(!checkEmail(contactEmail,null,"Please enter valid email address."))
		{
			document.getElementById( 'email' ).focus();
			return false;
		}
	}
	
	if(contactEmail !="")
	{
		if(validOfficialEmail(contactEmail)==false)
		{
			alert("Please input a more official email address.");
			document.getElementById( 'email' ).focus();
			return false;
		}
	}
	if(trim(document.getElementById('phone').value)=="")
	{
		alert("Please specify Phone No.");
		document.getElementById('phone').focus();
		return false;
		
	}
	if(!isValidPhone(trim(document.getElementById('phone').value)))
	{
		alert("Please specify valid Phone No.");
		document.getElementById('phone').focus();
		return false;
	}
	
	if(document.getElementById('country').value =="")
	{
		alert("Please specify country.");
		document.getElementById('country').focus();
		return false;
		
	}
	return true;
}


function checkEmail(field,excval,errstmt){
var emailregex=/^[\w]+\+?\w*@[\w]+\.[\w.]+\w$/;
var match=field.match(emailregex);
     if (!match) {
          if (errstmt) alert(errstmt);
          if (excval) eval(excval);
          return false;
     }else return true;
}
function validOfficialEmail(emailVal)
{
	var invalidaddress=new Array()
	invalidaddress[0]="hotmail"
	invalidaddress[1]="yahoo"
	invalidaddress[2]="rediff"
	

	var invalidcheck=0;
	var tempstring=emailVal.split("@")
	tempstring=tempstring[1].split(".")
	
	for (i=0;i<invalidaddress.length;i++)
	{
		if (tempstring[0]==invalidaddress[i])
		{
			invalidcheck=1
			
		}
	}
	if (invalidcheck!=1)
		testresults=true
	else
	{
		//alert("Please input a more official email address!")
		testresults=false
	}
	return testresults;
}

function validateLogin(){
	var userName = document.getElementById('login');
	var password = document.getElementById('password');
	if(validLength ( trim(userName.value),"Please specify your user name." ) == false ){
		userName.focus();
		return false;
	}else if(validLength ( trim(password.value),"Please specify your password." ) == false ){
		password.focus();
		return false;
	}
	return true;
}//end of validateAdmin function
function validLength ( strVal, strMsg ) {
  if ( strVal.length < 1) {
		alert( strMsg );
		return false;
  }  //End of IF
  
} //End of FUNC validLength

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
function isValidPhone(phonenumber) 
{ 
	if(isNaN(parseInt(phonenumber)))
		return false; 
	else
		return true;

} 