// JavaScript Document

//**************************************************************//
//**************************************************************//
<!-- Begin Date Function
var mydate=new Date();
var year=mydate.getYear();
if (year < 1000)
year+=1900
var day=mydate.getDay();
var month=mydate.getMonth();
var daym=mydate.getDate();
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//  End -->
//**************************************************************//
//**************************************************************//
<!-- Begin Menu Function
var checkIt;
function displaySubMenu(num){
	hideSubMenu('all');
	switch (num){
		case 1: document.getElementById('about').style.display='block'; 
				checkUserInput('about');
			    break;
		case 3: document.getElementById('gallery').style.display='block'; 
				checkUserInput('gallery');
		 		break;
		case 4: document.getElementById('data').style.display='block'; 
				checkUserInput('data');
		 		break;
		case 5: document.getElementById('conferences').style.display='block'; 
				checkUserInput('conferences');
		 		break;								
	}
}
function checkUserInput(name){
	menuName=name;
	if (checkIt) clearTimeout(checkIt); 
		checkIt = setTimeout('hideSubMenu(menuName)',5000);
}
function hideSubMenu(name){
	switch (name){
		case 'about'	: document.getElementById('about').style.display='none'; 
						  break;
		case 'gallery'	: document.getElementById('gallery').style.display='none';
						  break;
		case 'all'		: document.getElementById('about').style.display='none'; 
						  document.getElementById('gallery').style.display='none'; 
						  break;	
	}
}
//  End -->
//**************************************************************//
//**************************************************************//

$date_message = "Please enter a valid date. Otherwise leave the field as it is."
$date_message2 = "Please enter a valid date."

/* 
function isEmpty(field,label)
Parameters : field-> The name of the field whose value is to be checked
			 label-> The label with that field to give the appropiate error message
Purpose : To check if the value of field is null or not.
Return Value : False if value is empty else True
*/			 

function isEmpty(field,label)
{
	if(Trim(field.value) == "")
	{
		 label = label +   " cannot be left blank."
	     alert(label)
	     field.focus()
	     return false;
	}
	else
    {
       return true;
    }
	       
}

//-------------------------------------------------------------------------------------------------------------------------------

/* 
function chkSelect(field, label)
Parameters : field-> The name of the field whose value is to be checked
			 label-> The label with that field to give the appropiate error message
Purpose : To check the value of the combo if first value of it is select.
Return Value : False if value conatins anything else characters.
*/			 


function chkSelect(field,label)
{
//	alert(field.selectedIndex)
	if(field.selectedIndex == 0)
	{
		alert("Select a value for " + label);
		field.focus();
		return false;
	}
	else
	{
		return true;
	}
}			

//-------------------------------------------------------------------------------------------------------------------------------

/* 
function NameChk(field,label,boolEmpty,boolNum,splChar)
Parameters : field-> The name of the field whose value is to be checked
			 label-> The label with that field to give the appropiate error message
			 boolEmpty-> It can have only two values - 1 or 0.
			 if it is 1 then the value passed can not be blank else it can be blank.
			 boolNum->It can have only two values - 1 or 0.
			 if it is 1 then the value passed can not have numeric values else it can have numeric values.
			 splChar-> Will contain the string of special characters allowed in the field.
Purpose : To check the format of each type of name.For Eg: FirstName,LastName etc etc.
Return Value : False if value is empty else True
*/			 


function NameChk(field,label,boolEmpty,boolNum,splChar)
{
	if(boolEmpty == 1)
	{
		if (isEmpty(field,label)==false)
			return false;
	}
	else
	{
	if( !field.value)
		return true;
	}	
   	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
	if(boolNum == 0)
	{
		valid = valid + "0123456789"
	}   	
	valid = valid + splChar
    var input = field.value;
    var length = input.length;
	for(i=0; i<length; i++)
	{
		var sub = input.substring(i,i+1);
		if(valid.indexOf(sub)==-1)
	   	{
	   		 label = "Please enter the valid " + label + " before submitting the form"
			 alert(label);
             field.focus();
             return false;		
	     }	
	   
	 }
	 return true;
}
//-------------------------------------------------------------------------------------------------------------------------------

/* 
function isEmail(field,label,boolEmpty) 
Parameters : field-> The name of the field whose value is to be checked
			 label-> The label with that field to give the appropiate error message
			 boolEmpty-> It can have only two values - 1 or 0.
			 if it is 1 then the value passed can not be blank else it can b blank.
Purpose : To check the format for valid Email address.
Return Value : False if value is empty else True
*/			 

function isEmail(field,label,boolEmpty) 
{ 
	if(boolEmpty == 1)
	{
		if (isEmpty(field,label)==false)
			return false;			
	
	}
	else
	{
	if(!field.value)
		return true;
	}
	
	
	if (field.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/) != -1)
		return true;
	else
	{	
		label = "Please enter a valid " + label +"."
		alert(label);
        field.focus();
        return false;
     }
     return true;
}

 
 
//------------------------------------------------------------------------------------------------------------------------------- 

/* 
function chkPass(field,label,minChar)
Parameters : field-> The name of the field whose value is to be checked
			 label-> The label with that field to give the appropiate error message
			 minChar-> The minimum character
Purpose : To check the format for valid Password.
Return Value : False if password is not in correct format else True.
*/			 

function chkPass(field,label,minChar)
{  
//	 alert("chkPass");
     if (isEmpty(field,label)==true)
	 {
         	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 
   	        var input = field.value;
    	    var length = input.length;
	        for(i=0; i<length; i++)
	        {
		         var sub = input.substring(i,i+1);
		         if(valid.indexOf(sub)==-1)
	   	         {
	   				  label = "Please enter the valid " + label 
			          alert(label);
                      field.focus();
                      return false;		
	             }	
	   
	        }
		   
		   if(field.value.length < minChar)
			{
				alert( "Password must be at least " + minChar +  " characters.");
				field.focus();
				return false;
			}
	}
	
	else
	{
		return false;
	}	
	
return true;
}		

//------------------------------------------------------------------------------------------------------------------------------- 

/* 
function chkPassConfirm(field,field1)
Parameters : field-> The name of the field which contains the value of the password
			 field1-> The name of the field that contains the value of confirmed password.
Purpose : To check the equality of two passwords(original & it's confirmation) entered by the user.
Return Value : False if field & field1 value are different else true.
*/			 

function chkPassConfirm(field,field1)
{  
    if(field.value != field1.value)
    {
		alert("Both the passwords should be same");
		field.focus();
     	return false;
     }	
		
	
return true;
}


/*-------------------------------------------------------------------------------------------------------------------------------*/

/* 
function NumChk(field,label,boolEmpty)
Parameters : field-> The name of the field whose value is to be checked
			 label-> The label with that field to give the appropiate error message
			 boolEmpty-> It can have only two values - 1 or 0.
			 if it is 1 then the value passed can not be blank else it can b blank.
Purpose : To check the value of fields where numeric data is allowed.
Return Value : False if value is non numeric else True
*/			 


function NumChk(field,label,boolEmpty)
{
	if(boolEmpty == 1)
	{
		if (isEmpty(field,label)==false)
			return false;			
	
	}
	else
	{
	if( !field.value)
		return true;
	}
					
   	var valid = "0123456789."; 
	var input = field.value;
    var length = input.length;
	for(i=0; i<length; i++)
	{
		var sub = input.substring(i,i+1);
		if(valid.indexOf(sub)==-1)
	   	{
	   		 label = label + " can conatin only numeric data."
			 alert(label);
             field.focus();
             return false;		
	     }	
	   
	 }
	 return true;
}


//-------------------------------------------------------------------------------------------------------------------------------

/* 
function Trim(str)
Parameters : str -> String which is to be trimmed
Purpose : To trim the spaces of string.
Return Value : Trimmed string
*/			 

function Trim(str)
{
	
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}

//-------------------------------------------------------------------------------------------------------------------------------

/* 
function TrimLeft(str)
Parameters : str -> String which is to be trimmed
Purpose : To trim the spaces on the left of string.
Return Value : String with spaces trimmed from left
*/			 

function TrimLeft( str ) 
{
	var resultStr = "";
	var i = len = 0;

	if (str+"" == "undefined" || str == null)	
		return null;

	str += "";

	if (str.length == 0) 
		resultStr = "";
	else {	
	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

//-------------------------------------------------------------------------------------------------------------------------------

/* 
function TrimRight(str)
Parameters : str -> String which is to be trimmed
Purpose : To trim the spaces on the right of string.
Return Value : String with spaces trimmed from right
*/			 


function TrimRight( str ) 
{
	var resultStr = "";
	var i = 0;
	if (str+"" == "undefined" || str == null)	
		return null;

	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
 			
  		resultStr = str.substring(0, i + 1);
  	}
  	
  	return resultStr;  	
}
//------------------------------------------------------------------------------------------------


// Date Check

function validateDate (strDate) {
	//alert(strDate);
   var parsedDate = strDate.split ("-");
   if (parsedDate.length != 3) return false;
   var day, month, year;
   month = parsedDate[0]-1;
   day = parsedDate[1];
   year = parsedDate[2];
  // alert(year+month+day);

   var objDate = new Date(year,month,day); 
   if (month != objDate.getMonth()) return false;
   if (day != objDate.getDate()) return false;
   if (year != objDate.getFullYear()) return false;

   return true;
}

function validateSearchDate (strDate) {
   //alert(strDate);
   var parsedDate = strDate.split ("-");
   if (parsedDate.length != 2) return false;
   var month, year;
   month = parsedDate[1]-1;
   year = parsedDate[0];
  //alert(year+month);

   var objDate = new Date(year,month,day); 
   if (month != objDate.getMonth()) return false;
   if (year != objDate.getFullYear()) return false;
   return true;
}

function validate_dmy_Date (strDate) {
	//alert(strDate);
   var parsedDate = strDate.split ("-");
   if (parsedDate.length != 3) return false;
   var day, month, year;
   day = parsedDate[0];
   month = parsedDate[1]-1;
   year = parsedDate[2];
   //alert(year+month+day);
   var objDate = new Date(year,month,day); 
   if (month != objDate.getMonth()) return false;
   if (day != objDate.getDate()) return false;
   if (year != objDate.getFullYear()) return false;
   return true;
}

function validateSFrm(anyValue)
		{	
			if(!isEmpty(document.searchFrm.keyword,"Search"))
			{
			return false;
			}
			if(document.searchFrm.keyword.value == "Enter keywords")
			{
			alert("Please enter the keywords to be searched.");
			document.searchFrm.keyword.focus();
			return false;
			}
			if(anyValue == "SUBMIT")
			{
				document.searchFrm.submit();
			}
			return true;						
		}	
