// JavaScript Document

function checkFieldsBanquet(){

Name2 = document.banquet.name.value;
Email2 = document.banquet.email.value;
function_date = document.banquet.function_date.value;
function_duration = document.banquet.function_duration.value;
function_type = document.banquet.function_type.value;


msgblank="Please fill in all mandatory fields marked *";

if  (Name2 =="") 
{
			document.banquet.name.focus(); 
			alert(msgblank); 
			return false;

}

 if (Email2 == "") 
{
			document.banquet.email.focus(); 
			alert(msgblank); 
			return false;

}

if (function_date == "") 
{
			document.banquet.function_date.focus(); 
			alert(msgblank); 
			return false;

}

if (function_duration == "") 
{
			document.banquet.function_duration.focus(); 
			alert(msgblank); 
			return false;

}

if (function_type == "") 
{
			document.banquet.function_type.focus(); 
			alert(msgblank); 
			return false;

}

if(document.banquet.email.value.length != 0)
 { 
	
		 if(-1 == document.banquet.email.value.indexOf("@")) { 
		   document.banquet.email.focus(); 
		   alert("Your email must have a '@'."); 
		   return false; 
		   }
		  if(-1 != document.banquet.email.value.indexOf(",")) { 
		   document.banquet.email.focus(); 
		   alert("Your email must not have a ',' in it"); 
		   return false; 
		   }
		   if(-1 != document.banquet.email.value.indexOf("#")) { 
		   document.banquet.email.focus(); 
		   alert("Your email must not have an '#' in it." ); 
		   return false; 
		   }
		   if(-1 != document.banquet.email.value.indexOf("!")) { 
		   document.banquet.email.focus(); 
		   alert("Your email must not have a '!' in it." ); 
		   return false; 
		   } 
		   if(-1 != document.banquet.email.value.indexOf(" ")) { 
		   document.banquet.email.focus(); 
		   alert("Your email must not have a space in it." ); 
		   return false; 
		   }
		   if(document.banquet.email.value == (document.banquet.email.value.indexOf("@")+1) ) {
		   document.banquet.email.focus();
		   alert("Your email must have a domain name after the '@'.");
		   return false;
		   }
		   if(document.banquet.email.value.length == (document.banquet.email.value.indexOf(".")+1) ) {
		   document.banquet.email.focus();
		   alert("Your email must have a valid domain name.  (e.g. yourname@hotmail.com)");
		   return false;
		   }
		   
		   if(!isEmail(email))
			{
			alert("Not a Valid Email..!");
			return false;
			}		   
}	

else return true;
}


function checkFieldsMembers(){

Name2 = document.members.Name.value;
Email2 = document.members.Email.value;
Inquiry = document.members.Inquiry.value;


msgblank="Please fill in all mandatory fields marked *";

if  (Name2 =="") 
{
			document.members.Name.focus(); 
			alert(msgblank); 
			return false;

}

 if (Email2 == "") 
{
			document.members.Email.focus(); 
			alert(msgblank); 
			return false;

}

 if (Inquiry == "") 
{
			document.members.Inquiry.focus(); 
			alert(msgblank); 
			return false;

}

 
if(document.members.Email.value.length != 0)
 { 
	
		 if(-1 == document.members.Email.value.indexOf("@")) { 
		  document.members.Email.focus(); 
		   alert("Your email must have a '@'."); 
		   return false; 
		   }
		  if(-1 != document.members.Email.value.indexOf(",")) { 
		   document.members.Email.focus(); 
		   alert("Your email must not have a ',' in it"); 
		   return false; 
		   }
		   if(-1 != document.members.Email.value.indexOf("#")) { 
		   document.members.Email.focus(); 
		   alert("Your email must not have an '#' in it." ); 
		   return false; 
		   }
		   if(-1 != document.members.Email.value.indexOf("!")) { 
		   document.members.Email.focus(); 
		   alert("Your email must not have a '!' in it." ); 
		   return false; 
		   } 
		   if(-1 != document.members.Email.value.indexOf(" ")) { 
		   document.members.Email.focus(); 
		   alert("Your email must not have a space in it." ); 
		   return false; 
		   }
		   if(document.members.Email.value == (document.members.Email.value.indexOf("@")+1) ) {
		   document.members.Email.focus();
		   alert("Your email must have a domain name after the '@'.");
		   return false;
		   }
		   if(document.members.Email.value.length == (document.members.Email.value.indexOf(".")+1) ) {
		  document.members.Email.focus();
		   alert("Your email must have a valid domain name.  (e.g. yourname@hotmail.com)");
		   return false;
		   }
		   
		   if(!isEmail(Email2))
			{
			alert("Not a Valid Email..!");
			return false;
			}		   
}	

else return true;
}


function checkFieldsContact(){

Name2 = document.contact.Name.value;
Email2 = document.contact.Email.value;
Inquiry = document.contact.Inquiry.value;


msgblank="Please fill in all mandatory fields marked *";

if  (Name2 =="") 
{
			document.contact.Name.focus(); 
			alert(msgblank); 
			return false;

}

 if (Email2 == "") 
{
			document.contact.Email.focus(); 
			alert(msgblank); 
			return false;

}

 if (Inquiry == "") 
{
			document.contact.Inquiry.focus(); 
			alert(msgblank); 
			return false;

}

 
if(document.contact.Email.value.length != 0)
 { 
	
		 if(-1 == document.contact.Email.value.indexOf("@")) { 
		  document.contact.Email.focus(); 
		   alert("Your email must have a '@'."); 
		   return false; 
		   }
		  if(-1 != document.contact.Email.value.indexOf(",")) { 
		   document.contact.Email.focus(); 
		   alert("Your email must not have a ',' in it"); 
		   return false; 
		   }
		   if(-1 != document.contact.Email.value.indexOf("#")) { 
		   document.contact.Email.focus(); 
		   alert("Your email must not have an '#' in it." ); 
		   return false; 
		   }
		   if(-1 != document.contact.Email.value.indexOf("!")) { 
		   document.contact.Email.focus(); 
		   alert("Your email must not have a '!' in it." ); 
		   return false; 
		   } 
		   if(-1 != document.contact.Email.value.indexOf(" ")) { 
		   document.contact.Email.focus(); 
		   alert("Your email must not have a space in it." ); 
		   return false; 
		   }
		   if(document.contact.Email.value == (document.contact.Email.value.indexOf("@")+1) ) {
		   document.contact.Email.focus();
		   alert("Your email must have a domain name after the '@'.");
		   return false;
		   }
		   if(document.contact.Email.value.length == (document.contact.Email.value.indexOf(".")+1) ) {
		   document.contact.Email.focus();
		   alert("Your email must have a valid domain name.  (e.g. yourname@hotmail.com)");
		   return false;
		   }
		   
		   if(!isEmail(Email2))
			{
			alert("Not a Valid Email..!");
			return false;
			}		   
}	

else return true;
}

function checkFieldsRegister(){

Name2 = document.register.Name.value;
Email = document.register.Email.value;
Username = document.register.Username.value;
Password = document.register.Password.value;
ConfirmPassword = document.register.ConfirmPassword.value;
FinEmail = document.register.FinEmail.value;
FinPassword = document.register.FinPassword.value;
ConfirmFinPassword = document.register.ConfirmFinPassword.value;

msgblank="Please fill in all mandatory fields marked *";

if  (Name2 =="") 
{
			document.register.Name.focus(); 
			alert(msgblank); 
			return false;

}

 if (Email == "") 
{
			document.register.Email.focus(); 
			alert(msgblank); 
			return false;

}


if(document.register.Email.value.length != 0)
 { 
	
		 if(-1 == document.register.Email.value.indexOf("@")) { 
		  document.register.Email.focus(); 
		   alert("Your email must have a '@'."); 
		   return false; 
		   }
		  if(-1 != document.register.Email.value.indexOf(",")) { 
		   document.register.Email.focus(); 
		   alert("Your email must not have a ',' in it"); 
		   return false; 
		   }
		   if(-1 != document.register.Email.value.indexOf("#")) { 
		   document.register.Email.focus(); 
		   alert("Your email must not have an '#' in it." ); 
		   return false; 
		   }
		   if(-1 != document.register.Email.value.indexOf("!")) { 
		   document.register.Email.focus(); 
		   alert("Your email must not have a '!' in it." ); 
		   return false; 
		   } 
		   if(-1 != document.register.Email.value.indexOf(" ")) { 
		   document.register.Email.focus(); 
		   alert("Your email must not have a space in it." ); 
		   return false; 
		   }
		   if(document.register.Email.value == (document.register.Email.value.indexOf("@")+1) ) {
		   document.register.Email.focus();
		   alert("Your email must have a domain name after the '@'.");
		   return false;
		   }
		   if(document.register.Email.value.length == (document.register.Email.value.indexOf(".")+1) ) {
		   document.register.Email.focus();
		   alert("Your email must have a valid domain name.  (e.g. yourname@hotmail.com)");
		   return false;
		   }
		   
		   if(!isEmail(Email))
			{
			alert("Not a valid email..!");
			document.register.Email.focus();
			return false;
			}		   
}


 if (Username == "") 
{
			document.register.Username.focus(); 
			alert(msgblank); 
			return false;

}

if ((document.register.Username.value.length < 5) || (document.register.Username.value.length > 12))
{
			document.register.Username.focus(); 
			alert("Username must be 5 to 12 characters long"); 
			return false;

}

if (Password == "") 
{
			document.register.Password.focus(); 
			alert(msgblank); 
			return false;

}

if ( (document.register.Password.value.length < 5) || (document.register.Password.value.length > 12) )
{
			document.register.Password.focus(); 
			alert("Password must be 5 to 12 characters long"); 
			return false;

}

if (ConfirmPassword == "") 
{
			document.register.ConfirmPassword.focus(); 
			alert(msgblank); 
			return false;

}

if (document.register.Password.value != document.register.ConfirmPassword.value) 
{
			document.register.ConfirmPassword.focus(); 
			alert("password not matching confirm password"); 
			return false;

}

if (FinEmail == "") 
{
			document.register.FinEmail.focus(); 
			alert(msgblank); 
			return false;

}
 
if(document.register.FinEmail.value.length != 0)
 { 
	
		 if(-1 == document.register.FinEmail.value.indexOf("@")) { 
		  document.register.FinEmail.focus(); 
		   alert("Your email must have a '@'."); 
		   return false; 
		   }
		  if(-1 != document.register.FinEmail.value.indexOf(",")) { 
		   document.register.FinEmail.focus(); 
		   alert("Your email must not have a ',' in it"); 
		   return false; 
		   }
		   if(-1 != document.register.FinEmail.value.indexOf("#")) { 
		   document.register.FinEmail.focus(); 
		   alert("Your email must not have an '#' in it." ); 
		   return false; 
		   }
		   if(-1 != document.register.FinEmail.value.indexOf("!")) { 
		   document.register.FinEmail.focus(); 
		   alert("Your email must not have a '!' in it." ); 
		   return false; 
		   } 
		   if(-1 != document.register.FinEmail.value.indexOf(" ")) { 
		   document.register.FinEmail.focus(); 
		   alert("Your email must not have a space in it." ); 
		   return false; 
		   }
		   if(document.register.FinEmail.value == (document.register.FinEmail.value.indexOf("@")+1) ) {
		   document.register.FinEmail.focus();
		   alert("Your email must have a domain name after the '@'.");
		   return false;
		   }
		   if(document.register.FinEmail.value.length == (document.register.FinEmail.value.indexOf(".")+1) ) {
		   document.register.FinEmail.focus();
		   alert("Your email must have a valid domain name.  (e.g. yourname@hotmail.com)");
		   return false;
		   }
		   
		   if(!isEmail(FinEmail))
			{
			alert("Entered fingara.com email is not a valid email..!");
			document.register.FinEmail.focus();
			return false;
			}		   
}

if (FinPassword == "") 
{
		document.register.FinPassword.focus(); 
		alert(msgblank); 
		return false;

}

if ( (document.register.FinPassword.value.length < 5) || (document.register.FinPassword.value.length > 12) )
{
			document.register.FinPassword.focus(); 
			alert("Password for fingara.com email must be 5 to 12 characters long"); 
			return false;
}

if (document.register.FinPassword.value != document.register.ConfirmFinPassword.value) 
{
			document.register.ConfirmFinPassword.focus(); 
			alert("fingara.com password not matching confirm password"); 
			return false;

}

else return true;
}



function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function LegendWindow()
{

win = window.open("../help/HelpLegend.htm","", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=200,top=200,width=400,height=300")

}


function AcronymWindow()
{

win = window.open("../help/HelpAcronym.htm","", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=200,top=200,width=650,height=600")

}

function SensorWindow()
{

win = window.open("../help/HelpSensors.htm","", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=200,top=200,width=750,height=600")

}


//block certain keys
function CheckChars(kc)
{	
	//if ((kc > 32 && kc < 48) || (kc > 57 && kc< 65) || (kc > 90 && kc < 97))
	if (kc == 38 || kc == 47 || kc == 63 || kc == 62 || kc == 60 || kc == 32 || kc == 94 || kc == 64 || kc == 37 || kc == 35 || kc == 33 || kc == 34 || kc == 126 || kc == 96 || kc == 40 || kc == 41 || kc == 123 || kc == 125 || kc == 91 || kc == 93 || kc == 47 || kc == 92 || kc == 58 || kc == 59 || kc == 42 || kc == 45 || kc == 43 || kc == 61 || kc == 61 || kc == 44 || kc == 124 || kc == 39 || kc == 36)
	{ 
	alert ("Invalid character entered!")
	return false;
 	}
	return true;
}

function winalert()
{
alert("If you are a registered user, please logon to download data\nIf you are not registered, please register with us");
}


function downloadwin()
{
alert("If you are a registered user, please logon to download data\nIf you are not registered, please register with us");
}

	 
function ConfirmDownload(xPath){
		
		var ht = screen.height;
		var wdth = screen.width;
		var newWidth = 350;
		var newHeight = 120;
		var lft = (wdth / 2) - (newWidth / 2);
		var tp = (ht / 2) - (newHeight / 2);
		
		
				
win = window.open("../User/download.php?xPath="+xPath,"", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=" + lft + ",top=" + tp + ",width=" + newWidth + ",height=" + newHeight)

}


function checkorderFields() {

Name = document.dataorder.txtName.value;
Affiliation = document.dataorder.txtaffiliation.value;
Institute = document.dataorder.txtinstitute.value;
Address = document.dataorder.txtaddress.value;
Telephone = document.dataorder.txttelephone.value;
Email = document.dataorder.txtemail.value;
Requirement = document.dataorder.data.value;
Purpose = document.dataorder.txtpurpose.value;


msgblank="Please fill in all mandatory fields marked *";

if  (Name =="") 
{
			document.dataorder.txtName.focus(); 
			alert(msgblank); 
			return false;

}

else if (Affiliation == "") 
{
			document.dataorder.txtaffiliation.focus(); 
			alert(msgblank); 
			return false;
}

else if (Institute == "") 
{
			document.dataorder.txtinstitute.focus(); 
			alert(msgblank); 
			return false;

}

else if (Address == "") 
{
			document.dataorder.txtaddress.focus(); 
			alert(msgblank); 
			return false;

}

else if (Telephone == "") 
{
			document.dataorder.txttelephone.focus(); 
			alert(msgblank); 
			return false;

}

else if (Email == "") 
{
			document.dataorder.txtemail.focus(); 
			alert(msgblank); 
			return false;

}

 if(!isEmail(Email))
{
			document.dataorder.txtemail.focus(); 
			alert("Not a Valid Email..!");
			return false;
}

else if (Requirement == "") 
{
			document.dataorder.txtrequirement.focus(); 
			alert(msgblank); 
			return false;

}

else if (Purpose == "") 
{
			document.dataorder.txtpurpose.focus(); 
			alert(msgblank); 
			return false;
}

else return true;
}

// JavaScript Document
function checkFields() {
Name = document.contact.name.value;
Organisation = document.contact.org.value;
Email = document.contact.email.value;
Telephone = document.contact.tel.value;
Fax = document.contact.fax.value;
Requirement = document.contact.requirement.value;

if ((Name == "") && (Organisation == "") && (Email == "") && (Telephone == "") && (Fax == "") && (Requirement  == "") ) {
alert("Your inquiry must contain at least one entry ! ");
document.contact.name.focus();
return false;
}
else return true;
}




	



