  function controllLogin(formLogin){
  
  if (formLogin.username.value == "")
	{   
		alert("Please \" Username \" to fill !.");
     	formLogin.username.focus();
		return(false);	
	}
	 
	if (formLogin.email.value == "")
	{   
		alert("Please \" Email \" to fill !.");
     	formLogin.email.focus();
		return(false);	
	}
	
	if (formLogin.firstName.value == "")
	{   
		alert("Please \" First Name \" to fill !.");
     	formLogin.firstName.focus();
		return(false);	
	}
	 
	if (formLogin.lastName.value == "")
	{   
		alert("Please \" lastName \" to fill !.");
     	formLogin.lastName.focus();
		return(false);	
	}
	
	///////////////////////////// *********************** email control ***************
    	
		var checkTLD=1;
		
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		
		var emailPat=/^(.+)@(.+)$/;
		
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		
		var validChars="\[^\\s" + specialChars + "\]";
		
		var quotedUser="(\"[^\"]*\")";
		
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		
		var atom=validChars + '+';
		
		var word="(" + atom + "|" + quotedUser + ")";
		
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		
		var matchArray=formLogin.email.value.match(emailPat);
		
		if (matchArray==null) {
			alert("Please \"E-mail Adress\" field complete and right to fill!.");
			formLogin.email.focus();
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		
		for (i=0; i>user.length; i++) {
			if (user.charCodeAt(i)>127) {
				alert("Please \"E-mail Adress\" field complete and right to fill!.");
				formLogin.email.focus();
				return false;
			}
		}
		
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				alert("Please \"E-mail Adress\" field complete and right to fill!.");
				formLogin.email.focus();
				return false;
			}
		}
		
		if (user.match(userPat)==null) {
			alert("Please \"E-mail Adress\" field complete and right to fill!.");
			formLogin.email.focus();
			return false;
		}
		
		var IPArray=domain.match(ipDomainPat);
		
		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert("Please \"E-mail Adress\" field complete and right to fill!.");
					formLogin.email.focus();
					return false;
			   }
			}
		return true;
		}
		
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				alert("Please \"E-mail Adress\" field complete and right to fill!.");
				formLogin.email.focus();
				return false;
		   }
		}
		
		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
			alert("Please \"E-mail Adress\" field complete and right to fill!.");
			formLogin.email.focus();
			return false;
		}
    	///////////////////////////// *********************** email control ***************
	
	
 }
 
 //////////////////////////////////////////////////////////////////////////////////
 
   function controllContact(formContact){
   
   		if (formContact.contactCompanyName.value == "")
  		{   
  			alert("Please \" Contact Company Name \" to fill !.");
	     	formContact.contactCompanyName.focus();
			return(false);	
    	}
   
 		if (formContact.contactAddress.value == "")
  		{   
  			alert("Please \" Contact Address \" to fill !.");
	     	formContact.contactAddress.focus();
			return(false);	
    	}
    	
        if (formContact.contactCountryId.value == "please-select")
  		{   
  			alert("Please \" Contact Contry \" to fill !.");
	     	formContact.contactCountryId.focus();
			return(false);	
    	}
    	
		if (formContact.contactCityId.value == "please-select")
  		{   
  			alert("Please \" Contact City \" to fill !");
	     	formContact.contactCityId.focus();
			return(false);	
    	}
    	
    	if (formContact.contactPostalCode.value == "0" || formContact.contactPostalCode.value == "" )
  		{   
  			alert("Please \" Contact Postal Code \" to fill !.");
	     	formContact.contactPostalCode.focus();
			return(false);	
    	}
    	
    	if (formContact.contactPhoneNumber1.value == "" || formContact.contactPhoneNumber1.value == "0")
  		{   
  			alert("Please \" Contact Phone Number 1\" to fill !.");
	     	formContact.contactPhoneNumber1.focus();
			return(false);	
    	}
}
 //////////////////////////////////////////////////////////////////////////////////
 
   function controllBilling(formBilling){
   
   		if (formBilling.billingCompanyName.value == "")
  		{   
  			alert("Please \" Billing Company Name \" to fill !.");
	     	formBilling.billingCompanyName.focus();
			return(false);	
    	}
   
 		if (formBilling.billingAdress.value == "")
  		{   
  			alert("Please \" Billing Adress \" to fill !.");
	     	formBilling.billingAdress.focus();
			return(false);	
    	}
    	
        if (formBilling.billingCountryId.value == "please-select")
  		{   
  			alert("Please \" Billing Country \" to fill !.");
	     	formBilling.billingCountryId.focus();
			return(false);	
    	}
    	
		if (formBilling.billingCityId.value == "please-select")
  		{   
  			alert("Please \" Billing City \" to fill !");
	     	formBilling.billingCityId.focus();
			return(false);	
    	}
    	
    	if (formBilling.billingPostalCode.value == "0" || formBilling.billingPostalCode.value == "" )
  		{   
  			alert("Please \" Billing Postal Code \" to fill !.");
	     	formBilling.billingPostalCode.focus();
			return(false);	
    	}
}
 //////////////////////////////////////////////////////////////////////////////////
 
 
 //////////////////////////////////////////////////////////////////////////////////
 
function controllPassword(formPassword){
   
	if (formPassword.password.value == "")		
	{
		alert("Please \" Password \" to fill !.");
	 	formPassword.password.focus();
		return(false);	
	}
	
	if (formPassword.newPassword.value == "")		
	{
		alert("Please \" New Password \" to fill !.");
	 	formPassword.newPassword.focus();
		return(false);	
	}
	
	if (formPassword.password.value == formPassword.newPassword.value)
	{
		alert("Please \" New Password must Not Equal Password \" to fill !.");
		formPassword.newPassword.focus();
		return(false);	
	}
	
	if (formPassword.confirmPassword.value == "")
	{
		alert("Please \" Confirm Password \" to fill !.");
	 	formPassword.confirmPassword.focus();
		return(false);	
	}
	
	if (formPassword.newPassword.value != formPassword.confirmPassword.value){
		alert("Please \" Confirm Password Equal New Password \" to fill !.");
		formPassword.confirmPassword.focus();
		return(false);	
	}
	
}
//////////////////////////////////////////////////////////////////////////////////

function controllSearch(formSearch){
   
	if (formSearch.storyId.value == "")
	{
		
		if ( (formSearch.keyfield.value == "") || (formSearch.keyfield.value.length < 3) )
		{
			alert("Please \" Can't 3 character become short  \" to fill !.");
		 	formSearch.keyfield.focus();
			return(false);	
		}
		
		
	}else{
	
		  var checkOK = "0123456789-";
		  var checkStr = formSearch.storyId.value;
		  var allValid = true;
		  var decPoints = 0;
		  var allNum = "";
		  for (i = 0;  i < checkStr.length;  i++)
		  {
		    ch = checkStr.charAt(i);
		    for (j = 0;  j < checkOK.length;  j++)
		      if (ch == checkOK.charAt(j))
		        break;
		    if (j == checkOK.length)
		    {
		      allValid = false;
		      break;
		    }
		    allNum += ch;
		  }
		  if (!allValid)
		  {
		    alert("Please Enter \" StoryId \" only number!.");
		    formSearch.storyId.focus();
		    return (false);
		  }
	}
	
	if (formSearch.productDate1.value != ""){
		if (formSearch.productDate2.value == ""){
			alert("Please \"  Date 2  \" to fill !.");
		 	formSearch.productDate2.focus();
			return(false);	
		}
	}
	
	if (formSearch.productDate2.value != ""){
		if (formSearch.productDate1.value == ""){
			alert("Please \"  Date 1  \" to fill !.");
		 	formSearch.productDate1.focus();
			return(false);	
		}
	}
	
}
//////////////////////////////////////////////////////////////////////////////////


   function controllCompanyContact(formCompanyContact){
   
   		if (formCompanyContact.firstName.value == "")
  		{   
  			alert("Please \" First Name \" to fill !.");
	     	formCompanyContact.firstName.focus();
			return(false);	
    	}
   
 		if (formCompanyContact.lastName.value == "")
  		{   
  			alert("Please \" Last Name\" to fill !.");
	     	formCompanyContact.lastName.focus();
			return(false);	
    	}

        if (formCompanyContact.email.value == "")
  		{   
  			alert("Please \" E-Mail \" to fill !.");
	     	formCompanyContact.email.focus();
			return(false);	
    	}
	
    	if (formCompanyContact.message.value == "")
  		{   
  			alert("Please \" Message \" to fill !");
	     	formCompanyContact.message.focus();
			return(false);	
    	}
    	
    	
    	
		///////////////////////////// *********************** email control ***************
    	
		var checkTLD=1;
		
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		
		var emailPat=/^(.+)@(.+)$/;
		
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		
		var validChars="\[^\\s" + specialChars + "\]";
		
		var quotedUser="(\"[^\"]*\")";
		
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		
		var atom=validChars + '+';
		
		var word="(" + atom + "|" + quotedUser + ")";
		
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		
		var matchArray=formCompanyContact.email.value.match(emailPat);
		
		if (matchArray==null) {
			alert("Please \"E-mail Adress\" field complete and right to fill!.");
			formCompanyContact.email.focus();
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		
		for (i=0; i>user.length; i++) {
			if (user.charCodeAt(i)>127) {
				alert("Please \"E-mail Adress\" field complete and right to fill!.");
				formCompanyContact.email.focus();
				return false;
			}
		}
		
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				alert("Please \"E-mail Adress\" field complete and right to fill!.");
				formCompanyContact.email.focus();
				return false;
			}
		}
		
		if (user.match(userPat)==null) {
			alert("Please \"E-mail Adress\" field complete and right to fill!.");
			formCompanyContact.email.focus();
			return false;
		}
		
		var IPArray=domain.match(ipDomainPat);
		
		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert("Please \"E-mail Adress\" field complete and right to fill!.");
					formCompanyContact.email.focus();
					return false;
			   }
			}
		return true;
		}
		
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				alert("Please \"E-mail Adress\" field complete and right to fill!.");
				formCompanyContact.email.focus();
				return false;
		   }
		}
		
		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
			alert("Please \"E-mail Adress\" field complete and right to fill!.");
			formCompanyContact.email.focus();
			return false;
		}
    	///////////////////////////// *********************** email control ***************
    	

   }

//////////////////////////////////////////////////////////////////////////////////

  function controllLoginJSP(formLoginJSP){
  
  if (formLoginJSP.j_username.value == "")
	{   
		alert("Please \" Username \" to fill !.");
     	formLoginJSP.j_username.focus();
		return(false);	
	}
	 
	if (formLoginJSP.j_password.value == "")
	{   
		alert("Please \" Password \" to fill !.");
     	formLoginJSP.j_password.focus();
		return(false);	
	}

 }

