// JavaScript Document





function checkFieldsRegister() {

Name2 = document.register.txtName.value;
Title = document.register.txtTitle.value;
Affilliation = document.register.txtAffilliation.value;
Email2 = document.register.txtEmail.value;




msgblank="Please fill in all mandatory fields marked *";

if  (Name2 =="") 
{
			document.register.txtName.focus(); 
			alert(msgblank); 
			return false;

}

if  (Title =="") 
{
			document.register.txtTitle.focus(); 
			alert(msgblank); 
			return false;

}
else if (Affilliation == "") 
{
			document.register.txtAffilliation.focus(); 
			alert(msgblank); 
			return false;

}

else if (Email2 == "") 
{
			document.register.txtEmail.focus(); 
			alert(msgblank); 
			return false;

}
	
else if(document.register.txtEmail.value.length != 0)
 { 
	
		 if(-1 == document.register.txtEmail.value.indexOf("@")) { 
		   document.register.txtEmail.focus(); 
		   alert("Your email must have a '@'."); 
		   return false; 
		   }
		  if(-1 != document.register.txtEmail.value.indexOf(",")) { 
		   document.register.txtEmail.focus(); 
		   alert("Your email must not have a ',' in it"); 
		   return false; 
		   }
		   if(-1 != document.register.txtEmail.value.indexOf("#")) { 
		   document.register.txtEmail.focus(); 
		   alert("Your email must not have an '#' in it." ); 
		   return false; 
		   }
		   if(-1 != document.register.txtEmail.value.indexOf("!")) { 
		   document.register.txtEmail.focus(); 
		   alert("Your email must not have a '!' in it." ); 
		   return false; 
		   } 
		   if(-1 != document.register.txtEmail.value.indexOf(" ")) { 
		   document.register.txtEmail.focus(); 
		   alert("Your email must not have a space in it." ); 
		   return false; 
		   }
		   if(document.register.txtEmail.value.length == (document.register.txtEmail.value.indexOf("@")+1) ) {
		   document.register.txtEmail.focus();
		   alert("Your email must have a domain name after the '@'.");
		   return false;
		   }
		   if(document.register.txtEmail.value.length == (document.register.txtEmail.value.indexOf(".")+1) ) {
		   document.register.txtEmail.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 checkFieldsNews() {

Esubject = document.form1.Esubject.value;
Ebody = document.form1.Ebody.value;
docpath = document.form1.docpath.value;

msgblank="Please fill in all mandatory fields marked *";

if  (Esubject =="") 
{
			document.form1.Esubject.focus(); 
			alert("Please enter subject"); 
			return false;

}

if  (Ebody =="") 
{
			document.form1.Ebody.focus(); 
			alert("Please enter email body"); 
			return false;

}
else if (docpath == "") 
{
			document.form1.docpath.focus(); 
			alert("Please select a newsletter"); 
			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 PrivacyWindow()
{
//alert("hi");
win = window.open("../../info/main/privacy.htm","", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=200,top=200,width=600,height=600")

}

function TermsWindow()
{
//alert("hi");
win = window.open("../../info/main/terms.htm","", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=200,top=200,width=600,height=600")

}

function openHelp()
{
//alert("hi");
win = window.open("../../info/main/GeneralHelp.htm","", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=200,top=200,width=600,height=600")

}

function EnableDegMinSec(Enabled)
{

	document.comments.long_deg.disabled = Enabled;
	document.comments.long_min.disabled = Enabled;
	document.comments.long_sec.disabled = Enabled;
	document.comments.long_select.disabled = Enabled;

	document.comments.lat_deg.disabled = Enabled;
	document.comments.lat_min.disabled = Enabled;
	document.comments.lat_sec.disabled = Enabled;
	document.comments.lat_select.disabled = Enabled;

	if(Enabled)
	{

		document.comments.long_deg.style.backgroundColor = '#D4D0C8';
		document.comments.long_min.style.backgroundColor = '#D4D0C8';
		document.comments.long_sec.style.backgroundColor = '#D4D0C8';
		document.comments.long_select.style.backgroundColor = '#D4D0C8';

		document.comments.lat_deg.style.backgroundColor = '#D4D0C8';
		document.comments.lat_min.style.backgroundColor = '#D4D0C8';
		document.comments.lat_sec.style.backgroundColor = '#D4D0C8';
		document.comments.lat_select.style.backgroundColor = '#D4D0C8';
	}
	else
	{

		document.comments.long_deg.style.backgroundColor = '#FFFFFF';
		document.comments.long_min.style.backgroundColor = '#FFFFFF';
		document.comments.long_sec.style.backgroundColor = '#FFFFFF';
		document.comments.long_select.style.backgroundColor = '#FFFFFF';

		document.comments.lat_deg.style.backgroundColor = '#FFFFFF';
		document.comments.lat_min.style.backgroundColor = '#FFFFFF';
		document.comments.lat_sec.style.backgroundColor = '#FFFFFF';
		document.comments.lat_select.style.backgroundColor = '#FFFFFF';

	}

}


function EnableDecimals(Enabled)
{

	document.comments.long_Dec.disabled = Enabled;
	document.comments.lat_Dec.disabled = Enabled;
	
	document.comments.long_Dec_select.disabled = Enabled;
	document.comments.lat_Dec_select.disabled = Enabled;
	


	if(Enabled)
	{

		document.comments.long_Dec.style.backgroundColor = '#D4D0C8';
		document.comments.lat_Dec.style.backgroundColor = '#D4D0C8';
		
		document.comments.long_Dec_select.style.backgroundColor = '#D4D0C8';
		document.comments.lat_Dec_select.style.backgroundColor = '#D4D0C8';
		
	
	}
	else
	{
	
		document.comments.long_Dec.style.backgroundColor = '#FFFFFF';
		document.comments.lat_Dec.style.backgroundColor = '#FFFFFF';

		document.comments.long_Dec_select.style.backgroundColor = '#FFFFFF';
		document.comments.lat_Dec_select.style.backgroundColor = '#FFFFFF';
		
	}

}



function isNotInteger(s)
	{
		var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return true;
		}
		// All characters are numbers.
		return false;
	}



	function ValidateNums(argVal)
	{

		Status = true;

		var x = argVal;

		
		for(i=0;i < x.length;i++)
		{
		

		var charval = x.charCodeAt(i);


		if(charval != 46)
			{
				if((charval > 57) || (charval < 48))
				{
		
				Status = false;
			
				break;
				}
		
			}
			
		}
		

		i = 0;

		var Found = false;
		
		if(Status != false)
		{
		
			for(i=0;i < x.length;i++)
			{
		

			var charval = x.charCodeAt(i);
		

		
			if((charval == 46) && (Found != true))
				{

				Found = true;
		
		
				}
			else if((charval == 46) && (Found == true))
		
				{
		
				Status = false;
		
				break;
			
				}
			
		
			
			}
		
		
		}
		
		return !Status;

	}

function ValidateDegMinSec()
{

	var long_deg = document.comments.long_deg.value;
	var long_min = document.comments.long_min.value;
	var long_sec = document.comments.long_sec.value;
	
	var lat_deg = document.comments.lat_deg.value;
	var lat_min = document.comments.lat_min.value;
	var lat_sec = document.comments.lat_sec.value;

	if(long_deg == "" || isNotInteger(long_deg) || (eval(long_deg) < 0.0 ) || (eval(long_deg) > 179.0 ))
	{
		alert("Invalid Longititude Degree Value...");
		return false;
		
	}
	else if(long_min == "" || isNotInteger(long_min) || (eval(long_min) < 0.0 ) || (eval(long_min) > 59.0))
	{
		alert("Invalid Longititude Minute Value...");
		return false;
		
	}
	else if(long_sec == "" || ValidateNums(long_sec) || (eval(long_sec) < 0.0 ) || (eval(long_sec) > 59.0 ))
	{
		alert("Invalid Longititude Second Value...");
		return false;
		
	}
	else if(lat_deg == "" || isNotInteger(lat_deg) || (eval(lat_deg) < 0.0 ) || (eval(lat_deg) > 179.0 ))
	{
		alert("Invalid Latitude Degree Value...");
		return false;
		
	}
	else if(lat_min == "" || isNotInteger(lat_min) || (eval(lat_min) < 0.0 ) || (eval(lat_min) > 59.0 ))
	{
		alert("Invalid Latitude Minute Value...");
		return false;
		
	}
	else if(lat_sec == "" || ValidateNums(lat_sec) || (eval(lat_sec) < 0.0 ) || (eval(lat_sec) > 59.0 ))
	{
		alert("Invalid Latitude Second Value...");
		return false;
		
	}
	else if(ValidateComments() == false)
	{	
	
		alert(msgblank);
		return false;
	}
	else if(isEmail(document.comments.txtEmail.value) == false)
	{
	
		alert("Valid Email Required");
		return false;
	
	}	
	else
	
		return true;
		



}

function ValidateDecimals()
{

	var long_Dec = document.comments.long_Dec.value;
	
	var lat_Dec = document.comments.lat_Dec.value;
	
	if(long_Dec == "" || ValidateNums(long_Dec) || (eval(long_Dec) < 0.0 ) || (eval(long_Dec) > 180.0 ))
	{
		alert("Invalid Longititude Value...");
		return false;
		
	}
	else if(lat_Dec == "" || ValidateNums(lat_Dec) || (eval(lat_Dec) < 0.0 ) || (eval(lat_Dec) > 180.0 ))
	{
		alert("Invalid Latitude Value...");
		return false;
		
	}
	else if(ValidateComments() == false)
	{	
		alert(msgblank);
		return false;
			
	}
	else if(isEmail(document.comments.txtEmail.value) == false)
	{
	
		alert("Valid Email Required");
		return false;
	
	}
	else
	
		return true;

}

function ValidateComments()
{

if(document.comments.txtName.value == "" || document.comments.txtOrg.value == "" || document.comments.txtEmail.value == "")

	return false;

else

	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");
}