// JScript File
function movewin(win, width, height) {
		var fullWidth = screen.availWidth;
		var fullHeight = screen.availHeight;
		var x = (fullWidth/2)-(width/2);
		var y = (fullHeight/2)-(height/2);
		win.moveTo(x,y); 
	}
			
function viewWin(filenames,width,height)
{
	
	filenames=filenames;
			
	var newwin = window.open(filenames, 'mydoc', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,maximize=0,width='+width+',height='+height);
	
	movewin(newwin, width, height);
	    if (navigator.appName=="Netscape") 
	        newwin.location=url;
		
		newwin.opener=window;
		newwin.focus();
		return false;
}

function trimAll(sString) 
{
        while (sString.substring(0,1) == ' ')
        {
        sString = sString.substring(1, sString.length);
        }
        
        while (sString.substring(sString.length-1, sString.length) == ' ')
        {
        sString = sString.substring(0,sString.length-1);
        }
return sString;
}
function validateEmail(email)
{
	
	
	// This function is used to validate a given e-mail 
	// address for the proper syntax
	
	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}
function chk_login()
{
 var frm=document.login;
 if(trimAll(frm.email.value)=="")
 {
     alert("Please enter  E-mail. ");
     frm.email.focus();
     return false;	
 }
 if (validateEmail(frm.email.value)!=1)
	{
		alert("Please enter valid E-mail Address");
		frm.email.focus();	
		return (false);
	}
 
 if(trimAll(frm.password.value)=="")
 {
     alert("Please enter Password. ");
     frm.password.focus();
     return false;	
 }
 
	
}

function chk_createUser()
{
	var frm=document.createUser;
	 if(trimAll(frm.firstName.value)=="")
	 {
	     alert("Please enter  FirstName. ");
	     frm.firstName.focus();
	     return false;	
	 }
	  if(trimAll(frm.address.value)=="")
		 {
		     alert("Please enter  Address. ");
		     frm.address.focus();
		     return false;	
		 }
		 
		if(trimAll(frm.city.value)=="")
		 {
		     alert("Please enter  City. ");
		     frm.city.focus();
		     return false;	
		 }
		 
		 if(trimAll(frm.state.value)=="")
		 {
		     alert("Please enter State. ");
		     frm.state.focus();
		     return false;	
		 }
		 
		 if(trimAll(frm.postCode.value)=="")
		 {
		     alert("Please enter  Postcode. ");
		     frm.postCode.focus();
		     return false;	
		 }
	 if(trimAll(frm.country.value)=="")
		 {
		     alert("Please enter  Country. ");
		     frm.country.focus();
		     return false;	
		 }
		//For Email 
		if(trimAll(frm.email.value)=="")
	 {
	     alert("Please enter  E-mail. ");
	     frm.email.focus();
	     return false;	
	 }
 if (validateEmail(frm.email.value)!=1)
	{
		alert("Please enter valid E-mail Address");
		frm.email.focus();	
		return (false);
	}
	
 if(trimAll(frm.password.value)=="")
	 {
	     alert("Please enter Password. ");
	     frm.password.focus();
	     return false;	
	 }
 
}

function chk_forgotPassword()
{
		//For Email 
		var frm=document.forgotPassword;
		if(trimAll(frm.email.value)=="")
	 {
	     alert("Please enter  E-mail. ");
	     frm.email.focus();
	     return false;	
	 }
 if (validateEmail(frm.email.value)!=1)
	{
		alert("Please enter valid E-mail Address");
		frm.email.focus();	
		return (false);
	}
}