	/* check login info */
	function validate()
	{
		var juser=document.getElementById("loginForm").username.value;
		var jpassword=document.getElementById("loginForm").password.value;
		if(juser=="")
			{
				alert("Please fill in your Username");
				return false;
			}
		if(jpassword=="")
			{
				alert("Please fill in your Password");
				return false;
			}
	
		form.submit();
		return true;
	  
	}

	function emtyUSR()
	{
        if (document.getElementById("loginForm").username.value == "Username")
           document.getElementById("loginForm").username.value = "";
	}
	
	function emtyPWD()
	{
		if (document.getElementById("loginForm").password.value == "password")
			document.getElementById("loginForm").password.value = "";	
	}
	
   function goThere(index)
   {
      var theTarget = "_top";
      var theSelect = document.getElementById("udropdown_sel_" + index);
      if(!theSelect.selectedIndex==""){
         window.open(theSelect.options[theSelect.selectedIndex].value,theTarget,"");
      }
   }

   //function emtyName(obj)
   function emtyName(thisform)
	{
   	with (thisform)
      {
   		if (name.value == "Name")
   			name.value = "";	
      }
	}
	
   //function emtyEmail(obj)
   function emtyEmail(thisform)
	{alert(thisform.value);
   	with (thisform)
      { alert(email + "A");
   		if (email.value == "Email")
   			email.value = "";	
      }
	}

	
// check email and name fields for newsletter subscription
function checkDetails(thisform){

	with (thisform)
   {
   	var fname=name.value;
   	var femail=email.value;
   	
   	var str = femail.value; // email string
   	
   	//var reg1=new RegExp("@");//check if valid email
   	var reg1 = new RegExp("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$");
   	var char = /[^(A-Z)(a-z)(\s)]+/; //check if name is only alphabets
   	
   	
   	if (fname=="" || fname=="Name")
   	{
   	
   	document.getElementById("error_name").style.display ="none";
   	document.getElementById("error_email").style.display ="none";

   	document.getElementById("error_name").style.display ="inline";
   	return false;
   	}
       	else {
   	//if name is non alphabets, throw error
   	if(char.test(fname))
   			
   	{
   		alert("There are some none alphabetic characters\n in the name field. Please try again.");
   		return false;
   	}
       }

   	
       if (femail==""|| fname=="Email")
   	{
   		document.getElementById("error_name").style.display ="none";
   		document.getElementById("error_email").style.display ="none";
   		document.getElementById("error_email").style.display ="inline";
   		return false;
   	}
   	else 
   	{
   		//if email not valid format, alert user
   		if (reg1.test(femail)==false) 
   		{
   			alert(femail + " is an invalid e-mail. \n Please try again!"); 
   	
   		  return false;
   		}
   	}
   }
	return true;

}

//check search option one - Search by satellite map
function validateSatMapInput()
{
	if (document.getElementById("browseregion").region.value == "Please select Major Catchment")
	{
		alert("Please select Major Catchment");
		document.getElementById("browseregion").region.focus();
		return false;
	}
}

//check search option three - Search by Major catchment
function validateSub()
{
	if(document.getElementById("searchRegion").regionSub.value == "Please select Major Catchment")
	{
		alert("Please select Major Catchment");
		document.getElementById("searchRegion").regionSub.focus();
		return false;
	}
	else if(document.getElementById("searchSub").subcatchmentID.value == "Please select Sub-Catchment")
	{
		alert("Please select Sub-Catchment");
		document.getElementById("searchSub").subcatchmentID.focus();
		return false;
	}
}


//sitedetail.php's tabs management

	function tabtop(obj,divid)			            
	{
        var iCtr=0;
        var divObj=document.getElementById(divid); 
		 

		if (window.ActiveXObject)
		{				
			for(iCtr=0;iCtr<obj.parentNode.children.length;iCtr++)
            {
            	if(obj.id == obj.parentNode.children.item(iCtr).id)
                {    		   
                	document.getElementById(obj.parentNode.children.item(iCtr).id).className="current";
                }
                else
                {
                 document.getElementById(obj.parentNode.children.item(iCtr).id).className="";
                }
             }
	
             //HIDE AND SHOW  DIV
        /*   for(iCtr=0;iCtr<divObj.parentNode.children.length;iCtr++)
             {    		 
                if(divObj.id == divObj.parentNode.children.item(iCtr).id)
                {
                    divObj.style.visibility='visible';
                    divObj.style.display='block'; 		             
                }		  
                else
                {
     	             document.getElementById(divObj.parentNode.children.item(iCtr).id).style.visibility='hidden';
                     document.getElementById(divObj.parentNode.children.item(iCtr).id).style.display='none';
                }
             }	*/				
             
		}				
		else if (document.implementation && document.implementation.createDocument)
		{	 
			for(iCtr=0;iCtr<obj.parentNode.childNodes.length;iCtr++)
        	{  
				if(obj.parentNode.childNodes[iCtr].id!="undefined")
				{
					if(obj.id == obj.parentNode.childNodes[iCtr].id)
	                {         
	                	obj.parentNode.childNodes[iCtr].className="current";
					}
	                else
	                {
	                    obj.parentNode.childNodes[iCtr].className="";
	                } 
         		 }
		 	 }	
	   
	     /*  for(iCtr=0;iCtr<divObj.parentNode.childNodes.length;iCtr++)
	         {    	
				if(divObj.id == divObj.parentNode.childNodes[iCtr].id)
			    {
			        divObj.parentNode.childNodes[iCtr].style.visibility='visible';
			        divObj.parentNode.childNodes[iCtr].style.display='block';              
			    }		  
				 else
		        {
		             divObj.parentNode.childNodes[iCtr].style.visibility='hidden';
		             divObj.parentNode.childNodes[iCtr].style.display='none';
		        }	
	         }		*/
		}			 
 	}

//check table back up options
function validateTable()
{
	
	if(document.getElementById("browsetable").tabledata.value == "Please select Table")
	{
		alert("Please select a table");
		document.getElementById("browsetable").tabledata.focus();
		return false;
	}
}

//confirm alert
function confirmAction(message)
{
   input_box=confirm(""+message);
   if (input_box==true) { 
      return true;
   }
   return false;
}

