<!--hide this script from non-javascript-enabled browsers 
/*
########################################################################     
# File Name: functions.js
# Created By: Umesh Mundhe
# Created On: November 18 ,2005
# Updated By: Amol Divalkar
# This file contain all the common javascript functions
#########################################################################
*/

/*
 #############################################################################
 # Function Name: isBlank()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Function to check wether given value is blank or not.    
 # Parameters: string strValue : string. 
 # ON SUCCESS: Returns TRUE if value is blank.     
 # ON FAILURE: Returns FLASE  if value is not blank.     
 #############################################################################
 */

 function isBlank(strValue)
 {
	 for(var i = 0; i < strValue.length; i++)
	 {
		 var c = strValue.charAt(i);
		 if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	 }
	 return true; 
 }

/*
 #############################################################################
 # Function Name: isValidEmail()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Validate an email address.
 # Parameters: string strEmail : Email address
 # ON SUCCESS: Returns TRUE if string is in valid email format.     
 # ON FAILURE: Returns FLASE if string is not in valid email format.
 #############################################################################
 */
 function isValidEmail(strEmail) 
 {
	 // assume an email address cannot start with an @ or white space, but it 
	 // must contain the @ character followed by groups of alphanumerics and '-' 
	 // followed by the dot character '.' 
	 // It must end with 2 or 3 alphanumerics. 
	 // 
	 var alnum="a-zA-Z0-9"; 
	 exp="^[^@\\s]+@(["+alnum+"+\\-]+\\.)+["+alnum+"]["+alnum+"]["+alnum+"]?$"; 
	 emailregexp = new RegExp(exp); 
	 result = strEmail.match(emailregexp); 
	 if (result != null) 
	 {
		 return true; 
	 }
	 else 
	 {
		 return false; 
	 }
 }

/*
 ###########################################################################################################################
 # Function Name: isValidString()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Checks if field value contains only alphanumeric and '_' charactes. Also checks  that alphabetical chars. and '
 #          _' must have to be come first and followed by numbers. It returns false if above conditions will not satisfy 
 #         otherwise true.
 # Parameters: string strVal : string to be validated
 # ON SUCCESS: Returns TRUE if string is in valid format.  
 # ON FAILURE: Returns FLASE if string is not in valid format.  
 ###########################################################################################################################
	 */
 function isValidString(strVal) 
 {
	 var regex = /^[_]*[a-zA-Z_]+[a-zA-Z0-9_]+$/; 
	 if(!regex.test(strVal)) 
	 {
		 return false; 
	 }
	 else
	 {
		 return true; 
	 }
 }


/*
 #############################################################################
 # Function Name: IsAlphaNumeric()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Checks if field value contains only alphanumeric charecters.
 # Parameters: string strVal : string to be validated
 # ON SUCCESS: Returns TRUE if string is valid.     
 # ON FAILURE: Returns FLASE if string is not valid.     
 #############################################################################
 */
 function IsAlphaNumeric(strVal) 
 {
	 var regex = /^[a-zA-Z]+[0-9]+[a-zA-Z0-9]*$/; 
	 if(!regex.test(strVal)) 
	 {
		 return false; 
	 }
	 return true; 
 }

/*
 ###############################################################################
 # Function Name: checkFileType ()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: It checks the file types.
 # Parameters: obj fld : object of file inout type 
 #					   string strTypes : valid file types seperated by " "
 # ON SUCCESS: Returns TRUE if object contain valid file type.
 # ON FAILURE: Returns FLASE if object contain invalid file type.
 ###############################################################################
 */
 function checkFileType(fld, strTypes) 
 {
	 var strTypeList="";
	 strArray = strTypes.split(" "); 
	 for (i = 0;i<strArray.length;i++) 
	 {
		 if ( i < strArray.length && i > 0) 
		 {
			 strTypeList += "|";
		 }
            strTypeList += "."+strArray[i];
	 }
	 exp="("+strTypeList+")$"; 
	 var regex = new RegExp(exp);
	 if(!regex.test(fld.value)) 
	 {
		 return false; 
	 }
     return true; 
 }

/*
 ########################################################################################################################
 # Function Name: isFileSize()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: It ckecks the size of the image file. You can check either in terms of width and height of image or size of image in bytes.
 # Parameters: obj fld : object of file input type for which we want to check size
 #					   int size : Max file size allowed
 # ON SUCCESS: Returns TRUE file size is less than or equal to max size allowed.
 # ON FAILURE: Returns FLASE  file size is greater than max size allowed.
 #########################################################################################################################
 */

 /* ********** Commented By Jayashree ************************
 function isFileSize(fld, size) 
 {
	 alert(fld.value);
	 var img = new Image(); 
	 img.src = fld.value; 
	 //alert(img.fileSize);
	 // var Dimensions = img.width + 'x' + img.height; 
	 // var File Size = img.fileSize; 
	alert(img.fileSize);
	alert(size);
	 if(img.fileSize > size) 
	 {
		 return false; 
	 }
	 else
	 {
		  return true; 
	 }
 }
*************************************************************/

/*
 #############################################################################
 # Function Name: LTrim ()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Remove leading spaces.
 # Parameters: string str : String Value
 # ON SUCCESS: Remove leading spaces and return the string.     
 #############################################################################
 */
 function LTrim(str)
 {
	 if(str==null)
	{
		return str;
	}
	for(var i=0;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i++);
	return str.substring(i,str.length);
 }

/*
 #############################################################################
 # Function Name: RTrim ()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Remove trailing spaces.
 # Parameters: string str : String Value
 # ON SUCCESS: Remove trailing spaces and return the string.      
 #############################################################################
 */

 function RTrim(str)
 {
	 if(str==null)
	{
		return str;
	}
	for(var i=str.length-1;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i--);
	return str.substring(0,i+1);
 }

/*
 #############################################################################
 # Function Name: Trim ()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Remove leading and trailing spaces.
 # Parameters: string str : String Value
 # ON SUCCESS: Remove leading and trailing spaces and return the string.     
 #############################################################################
 */

 function Trim(str)
 {
	 return LTrim(RTrim(str));
 }


/*
 ###########################################################################################################################
 # Function Name: stripHTMLTags ()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: A simple routine to strip HTML tags from supplied string It's not very clever but it's quite useful. Everything between each "<" and the subsequent ">" is ignored hence it could get confused with any javascript comparisons or comments that contain comparisons.
 # Parameters: string str : String Value
 # ON SUCCESS: Removes html tags from string and return string.     
 ###########################################################################################################################
 */
function stripHTMLTags(str) 
 {
	 var mystr=""; 
	 var chr=""; 
	 var skip=false; 
	 var skipcancel=false; 
	 for (x=0; x<str.length; x++) 
	 {
		 if (skipcancel==true)
		 {
			 skip=false;
		 } 
		 chr=str.charAt(x); 
		 if (chr=="<")
		 {
			 skip=true;skipcancel=false;
		 } 
		 else if (chr==">" && skip==true)
		 {
			 skipcancel=true;
		 } 
		 if (skip==false) 
		 {
			 mystr=mystr+chr; 
		 }
	 }
	 return mystr; 
 } 

/*
 #############################################################################################
 # Function Name: isValidTime()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Checks if time is in HH:MM:SS format. The seconds are optional.
 # Parameters: string strTime : Time 
 # ON SUCCESS: Returns TRUE if strTime contains time in HH:MM:SS format.
 # ON FAILURE: Returns FLASE  if strTime does not contains time in HH:MM:SS format.
 #############################################################################################
 */

 function isValidTime(strTime) 
 {
	 var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?$/; 
	 var matchArray = strTime.match(timePat); 
	 if (matchArray == null) 
	 {
		 return false; 
	 }

	 hour = matchArray[1]; 
	 minute = matchArray[2]; 
	 second = matchArray[4]; 

	 if (isBlank(second)) 
	 {
		 second = null; 
	 }
	 
	 if (hour < 0  || hour > 23) 
	 {
		 return false; 
	 }

	 if (minute<0 || minute > 59) 
	 {
		 return false; 
	 }
	 
	 if (second != null && (second < 0 || second > 59)) 
	 { 
		 return false; 
	 }
	 return true; 
 }

/*
 #############################################################################
 # Function Name: isValidNumber()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Checks if the passed string contain valid number or not. 
 # Parameters: string numval : Number to check 
 # ON SUCCESS: Returns TRUE if value is numeric.     
 # ON FAILURE: Returns FLASE  if value is not numeric.
 #############################################################################
 */

 function isValidNumber(numval) 
 {
	 if (isBlank(numval))
	 {
		 return false;
	 }
	 var myRegExp = new RegExp("^[/+|/-]?[0-9]*[/.]?[0-9]*$"); 
	 return myRegExp.test(numval); 
 }
     
    

/*
 #########################################################################################################
 # Function Name: isValidInterval()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Check we ther the passed value is valid interval or not ( i.e. 1 Year, 1 day, 20 days etc).
 # Parameters: string interval : Value
 # ON SUCCESS: Returns TRUE parameter contains valid interval.   
 # ON FAILURE: Returns FLASE  parameter is not a valid interval.
 ##########################################################################################################
 */

 function isValidInterval(interval) 
 {
	 var strIntervals = new Array("yrs","year","years","mos","month","months","day","days","week","weeks","hrs","hour","hours","mins","min","minutes","secs","sec","second","seconds"); 
	 strArray = interval.split(" "); 
	 
	 // need at least two items 
	 if (strArray.length < 2) 
	 {
		 return false;
	 }
	 
	 // check all pairs of values to be valid intervals (e.g 2 hrs 5 mins) 
	 for (i = 0;i<strArray.length-1;i=i+2) 
	 {
		 if (isNaN(strArray[i]))
		 {
			 return false;
		 }
		 found=false; 
		 for (var x = 0;x<strIntervals.length;x++) 
		 {
			 if (strArray[i+1].toUpperCase() == strIntervals[x].toUpperCase()) 
			 {
				 found=true;
			 }
		 }
		 if (!found)
		 {
			 return false;
		 }
	 }
	 return true; 
 }


/*
 #############################################################################
 # Function Name: isValidDate()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Checks if date is in MM-DD-YYYY format  format. 
 # Parameters: string d : Date
 #                    
 # ON SUCCESS: Returns TRUE if value is blank.     
 # ON FAILURE: Returns FLASE  if value is not blank.     
 #############################################################################
 */

 function isValidDate(d) 
 {
	 //var strDatestyle = "US"; //United States date style 
	 var strDatestyle = "EU";  //European date style 
	 var strDate; 
	 var strDateArray; 
	 var strDay; 
	 var strMonth; 
	 var strYear; 
	 var intDay; 
	 var intMonth; 
	 var intYear; 
	 var booFound = false; 
	 var strSeparatorArray = new Array("-"," ","/","."); 
	 var intElementNr; 
	 var err = 0; 
	 var strMonthArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); 
	 strDate = d; 
	 if (strDate.length < 1) 
	 {
		 return false; 
	 }
	 
	 if (strDate.toLowerCase()=="today" || strDate.toLowerCase()=="now")
	 {
		 return true;
	 }
	 
	 for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) 
	 {
		 if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) 
		 {
			 strDateArray = strDate.split(strSeparatorArray[intElementNr]); 
			 if (strDateArray.length != 3) 
			 {
				 err = 1; 
				 return false; 
			 }
			 else 
			 {
				 strDay = strDateArray[0]; 
				 strMonth = strDateArray[1]; 
				 strYear = strDateArray[2]; 
			 }
			 booFound = true; 
		 }
	 }

	 if (booFound == false) 
	 {
		 if (strDate.length>5) 
		 {
			 strDay = strDate.substr(0, 2); 
			 strMonth = strDate.substr(2, 2); 
			 strYear = strDate.substr(4); 
		 }
		 else 
		 {
			 return false; 
		 }
	 }

	 // verify year part   2 or 4 digits 
	 if (strYear.length != 2 && strYear.length != 4) 
	 {
		 return false;
	 }

	 if (isNaN(strYear))
	 {
		 return false;
	 }
	 
	 // US style (swap month and day) 
	 if (strDatestyle == "US") 
	 {
		 strTemp = strDay; 
		 strDay = strMonth; 
		 strMonth = strTemp; 
	 }

	 // verify 1 or 2 digit integer day 
	 if (strDay.length<1 || strDay.length>2) 
	 {
		 return false;
	 }
	 
	 if (isNaN(strDay))
	 {
		 return false;
	 }
	 
	 // month may be digits of characters, hence following check 
	 intMonth = parseInt(strMonth, 10); 
	 if (isNaN(intMonth)) 
	 {
		 for (i = 0;i<12;i++) 
		 {
			 if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) 
			 {
				 intMonth = i+1; 
				 strMonth = strMonthArray[i]; 
				 i = 12; 
			 }
		 }
		 if (isNaN(intMonth)) 
		 {
			 err = 3; 
			 return false; 
		 }
	 }

	 intDay=parseInt(strDay,10); 
	 intYear = parseInt(strYear, 10); 

	 if (intMonth>12 || intMonth<1) 
	 {
		 err = 5; 
		 return false; 
	 }

	 // day in month check 
	 if (intDay < 1 || intDay > 31)
	 {
		 return false;
	 }
	 
	 if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30)) 
	 {
		 return false; 
	 }

	 if (intMonth == 2) 
	 {
		 if (LeapYear(intYear)) 
		 {
			 if (intDay > 29) 
			 {
				 return false;
			 }
		 }
		 else 
		 {
			 if (intDay > 28) 
			 {
				 return false;
			 }
		 }
	 }

	 if (intYear<=99)
	 {
		  intYear=intYear+2000;
	 }
	 return intDay+"/"+intMonth+"/"+intYear; 
 }

/*
 #########################################################################################################################
 # Function Name: isValidDateTime()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: check a composite date/time field  assume date is everything up to first space  and time is everything after first space.
 # Parameters: string strDateTime : Date time string in DD-MM-YYYY HH:MM:SS
 # ON SUCCESS: Returns TRUE date time is valid.
 # ON FAILURE: Returns FLASE  date time is invalid.
 ##########################################################################################################################
 */

 function isValidDateTime(strDateTime) 
 {
	 var dt = Trim(strDateTime); 
	 var intMatch; 
	 var intDateOnly = false; 
	 if (strDateTime.toLowerCase()=="today" || strDateTime.toLowerCase()=="now")
	 {
		 return true;
	 }
	 
	 intMatch=dt.indexOf(":"); 
	 if (intMatch < 0) 
	 {
		 intDateOnly = true; 
		 intMatch=dt.length; 
	 }
	 else 
	 {
		 intMatch=dt.indexOf(" "); 
	 }
	 
	 if (intMatch < 0) 
	 {
		 return false;
	 }
	 
	 // check date 
	 if (!isValidDate(dt.substr(0,intMatch)))
	 {
		 return false;
	 }
	 
	 // check time 
	 if (!intDateOnly) 
	 {
		 if (!isValidTime(dt.substr(intMatch+1,dt.length-intMatch)))
		 {
			 return false;
		 }
	 }
	 return true; 
 }

/*
 #############################################################################
 # Function Name: LeapYear()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: check year wether it is a leap year or not.
 # Parameters: string intYear : Year
 # ON SUCCESS: Returns TRUE given year is leap year.
 # ON FAILURE: Returns FLASE  given year is not a leap year.
 #############################################################################
 */

 function LeapYear(intYear) 
 {
	 if (intYear % 100 == 0) 
	 {
		 if (intYear % 400 == 0) 
		 {
			 return true; 
		 }
	 }
	 else 
	 {
		 if ((intYear % 4) == 0) 
		 { 
			 return true; 
		 }
	 }
	 return false; 
 }

/*
 ##########################################################################################################################
 # Function Name: isEarlierOrEqual()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: This function will accept start date and end date and will check for date format and it will also check wether end date is earlier than start date.
 # Parameters: string start : Start date 
 #                    string end  : End date 
 # ON SUCCESS: Returns TRUE If both date are in valid format and start date is earlier than end date.
 # ON FAILURE: Returns FLASE If either of date are not in valid format or end date is before start date.
 ###########################################################################################################################
 */

 function isEarlierOrEqual(start,end) 
 {
	 // convert dates to dd/mm/yyyy 
	 var myStart = isValidDate(start,true);
	 var myEnd = isValidDate(end,true); 
	 if (myStart=="" || myEnd=="") 
	 {
		 return false; 
	 }

	 var startparts= myStart.split("/"); 
	 var endparts=myEnd.split("/"); 

	 if(Date.UTC(startparts[2],startparts[1],startparts[0]) < Date.UTC(endparts[2],endparts[1],endparts[0])) 
	 {
		 return true; 
	 }
	 else 
	 {
		 return false; 
	 }
 }
 
 
 function isEarlierOrEqualReserv(start,end) 
 {
     // convert dates to dd/mm/yyyy 
     var myStart = isValidDate(start,true);
     var myEnd = isValidDate(end,true); 
     if (myStart=="" || myEnd=="") 
     {
         return false; 
     }

     var startparts= myStart.split("/"); 
     var endparts=myEnd.split("/"); 

     if(Date.UTC(startparts[2],startparts[1],startparts[0]) <= Date.UTC(endparts[2],endparts[1],endparts[0])) 
     {
         return true; 
     }
     else 
     {
         return false; 
     }
 }

/*
 ###########################################################################################################################
 # Function Name: isTimeEarlierOrEqualAM()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: This function will accept start time and end time and will check for time format and it will also check wether end time is earlier than start time.
 # Parameters: string start : Start time 
 #                    string end  : End time 
 # ON SUCCESS: Returns TRUE If both time are in valid format and start time is earlier than end time.
 # ON FAILURE: Returns FLASE If either of time are not in valid format or end time is before start time.
 ###########################################################################################################################
 */

 function isTimeEarlierOrEqualAM(start,end) 
 {
	 // convert times to UTC dates 
	 if (start=="" || end=="") 
	 {
		 return false; 
	 }
	 var startparts= start.split(":"); 
	 var endparts=end.split(":"); 
	 if (Date.UTC(2000,1,1,startparts[0],startparts[1]) <= Date.UTC(2000,1,1,endparts[0],endparts[1])) 
	 {
		 return true; 
	 }
	 else 
	 {
		 return false; 
	 }
 } 
 /*
 ###########################################################################################################################
 # Function Name: isTimeEarlierOrEqualPM()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: This function will accept start time and end time and will check for time format and it will also check wether end time is earlier than start time.
 # Parameters: string start : Start time 
 #                    string end  : End time 
 # ON SUCCESS: Returns TRUE If both time are in valid format and start time is earlier than end time.
 # ON FAILURE: Returns FLASE If either of time are not in valid format or end time is before start time.
 ###########################################################################################################################
 */

 function isTimeEarlierOrEqualPM(start,end) 
 {
     // convert times to UTC dates 
     if (start=="" || end=="") 
     {
         return false; 
     }
     var startparts= start.split(":"); 
     var endparts=end.split(":"); 
     if(Date.UTC(2000,1,1,startparts[0],startparts[1]) >= Date.UTC(2000,1,1,endparts[0],endparts[1])) 
     {
         return true; 
     }
     else 
     {
         return false; 
     }
 } 

/*
 ###########################################################################################################################
 # Function Name: NewWindow()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: This function will open passed url in new window.
 # Parameters: string url : Url
 #                    string title : Window Title
 #                    string w : window width
 #                    string h : window height 
 #                    string scroll : boolean value will indicate wether window should contain scroll bars or not (true/false, 'yes'/ 'no')
 #                    string resize : boolean value will indicate wether window is resizable or not (true/false, 'yes'/ 'no')
 # ON SUCCESS: open url in new window.     
 ###########################################################################################################################
 */

 function NewWindow(url, title, w, h, scroll, resize) 
 {
	 
	 if (scroll==true || scroll=='yes') 
	 {
		 scroll='yes'; 
	 }
	 else 
	 {
		 scroll='no'; 
	 }
	 if (resize==true || resize=='yes') 
	 {
		 resize=', resizable'; 
	 }
	 else 
	 {
		 resize=''; 
	 }
	 var winl = (screen.width - w) / 2; 
	 var wint = (screen.height - h) / 2; 
	 winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+resize;
	 win = window.open(url, title, winprops);
 }


/*
 #############################################################################
 # Function Name: DisplayStatusMsg()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: Display passed string in status bar.
 # Parameters: string msgStr : value
 # ON SUCCESS: Display passed string in status bar. 
 #############################################################################
 */

 function DisplayStatusMsg(msgStr)
 { 
	status=msgStr; document.MM_returnValue = true; 
 }
     
/*#############################################################################
# Function Name : fnCheckImageType 
# Created By: Manish Sharma
# Created On: 16 May 2008
# Purpose : It checks the image type. It must be either jpg or gif. 
# Parameters: fld : file which need to check.
################################################################################
*/
function fnCheckImageType(fld) 
{ 
    var regex = /(.jpg|.jpeg|.JPG|JPEG|.gif|.GIF)$/; 
    if(!regex.test(fld.value)) 
        { 
            alert('Invalid image format , Only .jpg, .jpeg image format allowed.'); 
            fld.focus(); 
            return false; 
        } 
    return true; 
} 
/*#############################################################################
# Function Name : fnIsNumber 
# Created By: Manish Sharma
# Created On: 16 May 2008
# Purpose : It checks for valid numerical string. 
# Parameters: fld : file which need to check.
# string msg : Message if file type is not valid .
################################################################################
*/
function fnIsNumber(fld,msg) 
{ 
    fld.value = Trim(fld.value);
    //alert(fld.value);
    var regex = /^[0-9]*$/; 
    if(!regex.test(fld.value)) 
    { 
        alert(msg+' must be numerical (No dashes or parenthesis).'); 
        fld.focus(); 
        return false; 
    } 
    return true; 
} 
     
/*#############################################################################
# Function Name : fnCheckTime 
# Created By: Manish Sharma
# Created On: 20 May 2008
# Purpose : It checks for valid time in hh:mm format. 
# Parameters: timeFieldId - time field id
################################################################################
*/  
function fnCheckTime(timeFieldId) 
{
    
    var textTime = document.getElementById(timeFieldId).value;
    var timeField = document.getElementById(timeFieldId);
    var timeExpression = /^(\d{2}):(\d{2})$/;
    var valresult = textTime.match(timeExpression);
    if (valresult==null) 
        {
            alert("Time entry is invalid. Please enter a valid time in hh:mm format (e.g. 08:00 )");
            timeField.value = "";
            timeField.focus();
            return false;
        }
    return true;
}   
     
/*#############################################################################
# Function Name : fnCheckIndianCurrency() 
# Created By: Manish Sharma
# Created On: 20 May 2008
# Purpose : It checks for valid currency in rr:pp format. 
# Parameters: currencyFieldId - currency field value
# OnSuccess : Return correct format(000,00,00.00)
# OnFailure : Return $0.00.
################################################################################
*/  
function fnCheckIndianCurrency(num) 
{
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + num + '.' + cents);
}

/*#############################################################################
# Function Name : fnIsValidFloat() 
# Created By: Manish Sharma
# Created On: 20 May 2008
# Purpose : It checks for valid float formet. 
# Parameters: currencyFieldId - field value
# OnSuccess : Return true
# OnFailure : Return false.
################################################################################
*/  
function fnIsValidFloat(numval) 
{
       if(numval==0 || numval==0.0)
       {
          return true;
       }
       
       if(parseFloat(numval))
         {
            
            return true;
         
         }
         else
         {
            
            return false;
         } 
        
 }
 
/* 
###########################################################################
# Function Name : fnCancelRedirect()
# Created By : Manish Sharma
# Created On : 16 May 2008
# Description : function for redirect page through javascript
# Parameter : redirect_page - page name where application flow redirect
########################################################################### 
*/
function fnCancelRedirect(redirect_page)
{
    window.location.href=redirect_page;
}
  
/* 
####################################################################################################
# Function Name : fnShowDeleteMessageRedirect()
# Created By : Manish Sharma
# Created On : 07 July 2008
# Description : function for redirect page through javascript and show the alert message before.
# Parameter :  msg - which display through alert box.
#              redirect - page name where application flow redirect. 
#################################################################################################### 
*/  
  
function fnShowDeleteMessageRedirect(msg,redirect)
{
    alert(msg);
    fnCancelRedirect(redirect);
}  
 
 /* 
##################################################################
# Function Name : fnPutFocus()
# Created By : Manish Sharma
# Created On : 16 May 2008
# Parameter : elementId - particular field id 
# Description : function for focus to particular field
################################################################### 
 */
function fnPutFocus(elementId) 
{
    //alert(elementId);
    document.getElementById(elementId).focus();
}

/* 
##########################################################################
# Function Name : fnConfirmation()
# Created By : Manish Sharma
# Created On : 19 May 2008
# Parameter : msg-message to be show in the confirm box.
# Description : function for ask confirmation before delete anything
############################################################################ 
*/
function fnConfirmation(msg)
{
  return confirm(msg);
}  
/* 
##################################################
# Function Name : fnOpenDiv()
# Created By : Manish Sharma
# Created On : 23 May 2008
# Parameter : divId - particualr div id
# Description : Function to  show  div . 
###################################################
*/ 
function fnOpenDiv(divId)
{
  
   var k=document.getElementById(divId).style.display = '';
   
   if(k=='')
   {
    document.getElementById(divId).style.display = 'block';
   }
  
}
/* 
#################################################
# Function Name : fnCloseDiv()
# Created By : Manish Sharma
# Created On : 23 May 2008
# Parameter : divId - particualr div id 
# Description : Function to  close  div . 
#################################################
*/ 
function fnCloseDiv(divId)
{
   document.getElementById(divId).style.display = 'none';
} 
 
/* 
###############################################################################
# Function Name : fnOpenCloseDiv()
# Created By : Manish Sharma
# Created On : 26 May 2008
# Parameter : openId - particualr div id which to be display
#             closeId -particualr div id which to be set dispaly none 
# Description : Function to  one div open and one div close  . 
###############################################################################
*/  
function fnOpenCloseDiv(openId , closeId)
{
    document.getElementById(openId).style.display = '';  
    document.getElementById(closeId).style.display = 'none';
}

/* 
###################################################################################
# Function Name : fnGetXmlHttpObject()
# Created By : Manish Sharma
# Created On : 26 May 2008
# Description : Function for create a XMLHttp request object for IE and Mozzila .
# OnSuccess : Return  XMLHttp request object.
####################################################################################
*/  
function fnGetXmlHttpObject()
{
    var xmlHttp=null;
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
}

 /* 
######################################################################################################
# Function Name : fngetLocationData()
# Created By : Manish Sharma
# Created On : 27 May 2008
# Parmaeter :  pagename -  check request come from which page and accoreding to send the result.
# Description : For get alocation name according to vendor .  (ajax request)
# OnSuccess : get location selectbox.
########################################################################################################
*/  
function fngetLocationData(pagename)
{
    var vendor_id = document.getElementById('Vendor_info').value;
   
   
    if(vendor_id== -1)
    {
        alert('Please select Vendor.');
        document.getElementById('Location_info_div').innerHTML ='<select name="Location_info" id="Location_info" onchange="fnShowDiscount();"><option value=-1>Select Location</option></select>';
        
        if(pagename=='discount')
        {
          fnHideAllDiscountRow();
        }
        if(pagename=='view_discount')
        {
          fnClearAlldiscountviewDiv();
        }
        if(pagename=='VLSC')
        {
          fnClearInnerHTML('view_loc_serv_chrg_data'); 
        }
        
        if(pagename=='LSC')
        {
          fnCloseDiv('location_charges_table'); 
        }

        return false;
    }
     
        if(pagename=='VLSC')
        {
          fnClearInnerHTML('view_loc_serv_chrg_data'); 
        }
          
        if(pagename=='LSC')
        {
           fnCloseDiv('location_charges_table'); 
        }
         
         if(pagename=='discount')
        {
          fnHideAllDiscountRow();
        }
        if(pagename=='view_discount')
        {
          fnClearAlldiscountviewDiv();
        }
       
     xmlHttp=fnGetXmlHttpObject();
        if (xmlHttp==null)
          {
          alert ("Your browser does not support AJAX!");
          return;
          } 
        var url="ajax_request.php";
        url=url+"?rq_id="+9+"&id="+vendor_id+"&pagename="+pagename;
        url=url+"&sid="+Math.random();
        xmlHttp.onreadystatechange=fngetLocationDataStateChanged;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
       
   
}

 function fngetLocationDataStateChanged()
 {
    
   if (xmlHttp.readyState==1 || xmlHttp.readyState==2 || xmlHttp.readyState==3)
    {
        document.getElementById('Location_info_div').innerHTML = '<img src="../images/loading.gif" />';
    }
     
   if (xmlHttp.readyState==4)
    {
        //alert(xmlHttp.responseText);
       document.getElementById('Location_info_div').innerHTML = xmlHttp.responseText;   //Update the location dropdown box
    } 
 }
 
 /* 
################################################################################
# Function Name : isValidURL()
# Created By : Manish Sharma
# Created On : 27 May 2008
# Description : For validation of url
# Parameter : url - check field value
# OnSuccess : Return True.
# OnFailure : Return False.
####################################################################################
*/ 
 function isValidURL(url)
 {
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url))
    {
        return true;
    }
    else
    {
        return false;
    }
}  
 
/*
############################################################################
# Function Name : fncheckDate()
# Created By : Manish Sharma
# Created On : 02 June 2008
# Description : Function to check the added date or old date or not.
# Parameter : sDate - date which to be validate 
# ON SUCCESS : Return true
# ON FAILURE : Message for old date can not accepted
############################################################################
*/ 
 
function fncheckDate(sDate)
{    
   
    var date = new Date();
    var d  = date.getDate();
    var day = (d < 10) ? '0' + d : d;
    var m = date.getMonth() + 1;
    var month = (m < 10) ? '0' + m : m;
    var yy = date.getYear();
    var year = (yy < 1000) ? yy + 1900 : yy;
    var today  = day + "/" + month + "/" + year;


    if(isEarlierOrEqual(sDate,today))
    {
       alert('Invalid date, Please select only today or greater than today\'s date.');
       return false;
    }
    else
    {
        //alert('not correct');
        return true;
    }
} 

/*
##################################################################################
# Function Name : fnFillInnerHTML()
# Created By : Manish Sharma
# Created On : 06 June 2008
# Description : show the innerHTML data in to div.
# Parameter : id- div id where data will be show, data , which show into div
###################################################################################
*/ 

function fnFillInnerHTML(id,data)
{
    document.getElementById(id).innerHTML= data;
}

/*
######################################################################################
# Function Name : fnSetFieldValue()
# Created By : Manish Sharma
# Created On : 10 June 2008
# Description : set field value dynamically through javascript.
# Parameter : id- field id where value will be set, data which to be set as a value
#######################################################################################
*/ 

function fnSetFieldValue(id,data)
{
    document.getElementById(id).value= data;
}

/*
######################################################################
# Function Name : fnClearInnerHTML()
# Created By : Manish Sharma
# Created On : 06 June 2008
# Description : clear the innerHTML data from div.
# Parameter : id- div id which to be clear
######################################################################
*/ 

function fnClearInnerHTML(id)
{
    document.getElementById(id).innerHTML = '';
}

/*
#################################################################
# Function Name : fnGetFieldValue()
# Created By : Manish Sharma
# Created On : 06 June 2008
# Description : Function to return the form field value.
# Parameter : id- id of those field which value want to get. 
###################################################################
*/

function fnGetFieldValue(id)
{
    var vals = document.getElementById(id).value;
    return vals;
}
/*
#################################################################
# Function Name : fnGetFieldObject()
# Created By : Manish Sharma
# Created On : 09 June 2008
# Description : Function to return the form field object.
# Parameter : id- id of those field which value want to get. 
###################################################################
*/ 
function fnGetFieldObject(id)
{
    var objs = document.getElementById(id);
    return objs;
} 

/*
 ####################################################################################################
#  Function Name :fntoggleVendorDetails()
#  Created By: Manish Sharma
#  Created On: 16 May 2008
#  Parmater: record_id - particular record which toogle when click on the image
#            image_id  - Individual image id when click on the image and particular record toggle
#  Purpose :toggle the vendors details  on click of the event
######################################################################################################
*/  
function fntoggleVendorDetails(record_id,image_id)
 { 
    var rowid = document.getElementById(record_id);
    
    if(rowid.style.display=='none')
    {
        rowid.style.display='';
        document.getElementById(image_id).src="../images/minus.gif";    
    }
    else
    {
        rowid.style.display='none';
        document.getElementById(image_id).src="../images/plus.gif";
    }
}

/*
########################################################################
#  Function Name :fnFocusAndAlert()
#  Created By: Manish Sharma
#  Created On: 10 June 2008
#  Paramaeter : alert message and id of that field where focus show
#  Purpose : show alert message and focus on the field
########################################################################
*/  

function fnFocusAndAlert(alert_message , focus_id)
{
    alert(alert_message);
    fnPutFocus(focus_id); 
}

/*
#################################################################
# Function Name : no function global array for error string.
# Created by : Manish sharma
# Created On : 09 June 2008
# Description : Comman arry for error string in javascript 
##################################################################
*/
 
 var errorArray = new Array();
 // project.js
 // validation admin login, vendor admin login , vendro admin- add vendor validation
 errorArray[0] = 'Username can not be blank.';
 errorArray[1] = 'Password can not be blank.'; 
 
 errorArray[2] = 'Vendor already exist, please change vendor username.';
 errorArray[3]= 'First Name can not be blank.';
 errorArray[4] = 'Last Name can not be blank.';
 errorArray[5] = 'Company Name can not be blank.';
 errorArray[6] = 'Address can not be blank.';
 errorArray[7] = 'Phone Number can not be blank(No dashes or parenthesis).';
 errorArray[8] = 'Invalid email address, Please enter the valid email address like abc@domain.com.';
 errorArray[9] = 'EIN number can not be blank.';
 errorArray[10] = 'Vendor Logo can not be blank.';
 errorArray[11] = 'Email address can not be blank.';
                     
 errorArray[12] = 'Old password can not be blank.';  
 errorArray[13] = 'New password can not be blank.';  
 errorArray[14] = 'Confirm password can not be blank.';
 errorArray[15] = 'Password should be more than 4 and less than 15 character. '; 
 errorArray[16] = 'New password and Confirm new password are not same.'; 
 
 errorArray[17] = 'Please enter Service Name, Service Value and  Service Description, all fields are mandatory.'; 
 
 errorArray[18] = 'Location name can not be blank.';
 errorArray[19] = 'Location contact can not be blank.';
 errorArray[20] = 'Location email can not be blank.';
 errorArray[21] = 'Location address can not be blank.';
 errorArray[22] = 'City can not be blank.';
 errorArray[23] = 'State can not be blank.';
 errorArray[24] = 'Location phone number can not be blank (No dashes or parenthesis).';
 errorArray[25] = 'Location days of operation should be selected.';
 errorArray[26] = 'Please select "Are the Locations Hours the same every day" for location days of operation.';
 errorArray[27] = 'Please select A.M. Hours for location days of operation.';
 errorArray[28] = 'Please select A.M. Minute for location days of operation.';
 errorArray[29] = 'Please select P.M. Hours for location days of operation.';  
 errorArray[30] = 'Please select P.M. Minute for location days of operation.';  
 errorArray[31] = 'Self Parking days of operation should be selected.';  
 errorArray[32] = 'Please select "Are the Locations Hours the same every day" for Self Parking.';  
 errorArray[33] = 'Please select A.M. Hours for self parking.';  
 errorArray[34] = 'Please select A.M. Minute for self parking.';  
 errorArray[35] = 'Please select P.M. Hours for self parking.';  
 errorArray[36] = 'Please select P.M. Minute for self parking.';  
 errorArray[37] = 'Valet Parking days of operation should be selected.';  
 errorArray[38] = 'Please select "Are the Locations Hours the same every day" for Valet Parking.';  
 errorArray[39] = 'Please select A.M. Hours for valet parking.';  
 errorArray[40] = 'Please select A.M. Minute for valet parking.'; 
 errorArray[41] = 'Please select P.M. Hours for valet parking.';
 errorArray[42] = 'Please select P.M. Minute for valet parking.';
 errorArray[43] = 'Please select valet parking price.';
 errorArray[44] = 'Pre-assign Parking days of operation should be selected.';
 errorArray[45] = 'Please select "Are the Locations Hours the same every day" for Pre-assign Parking.'; 
 errorArray[46] = 'Please select A.M. Hours for pre-assign parking.'; 
 errorArray[47] = 'Please select A.M. Minute for pre-assign parking.'; 
 errorArray[48] = 'Please select P.M. Hours for pre-assign parking.'; 
 errorArray[49] = 'Please select P.M. Minute for pre-assign parking.'; 
 errorArray[50] = 'Please select pre-assign parking price.'; 
 errorArray[51] = 'Please select pre-assign spot reserved.'; 
 errorArray[52] = 'Please select pre-assign space number.'; 
 errorArray[53] = 'Please select self parking price.'; 
 
 errorArray[63] = 'Self Parking hours of operation should be in location hours range.';
 errorArray[64] = 'Valet Parking hours of operation should be in location hours range.';  
 errorArray[87] = 'Pre-assign Parking hours of operation should be in location hours range.'; 
 
 errorArray[104] = 'Please enter the " Tax Rate " of the location.';
 errorArray[105] = 'Tax Rate must be numerical.';
 
 errorArray[122] = 'Gratuity name can not be blank.';
 errorArray[123] = 'Gratuity description can not be blank.';
 
 
 
 // coupon.js
 
 errorArray[54] = 'Please select coupon offered by.';
 errorArray[55] = 'Please select vendor .';
 errorArray[56] = 'Prefix coupon number can not be blank.';
 errorArray[57] = 'Coupon name can not be blank.';
 errorArray[58] = 'Coupon description can not be blank.';
 errorArray[59] = 'Coupon expiration date can not be blank.' ;
 
 errorArray[60] = "Your browser does not support AJAX!" ;
 
 errorArray[61] = 'Coupon number already Exist.' ;
 errorArray[62] = 'Coupon already exist.' ;
 
 // discount.js
 
 errorArray[65] = 'Please Select discount offered by.'; 
 errorArray[66] = 'Please select Location.';
 
 errorArray[67] =  'Reward value can not be blank.';
 errorArray[68] = 'Number of parking reservations day can not be blank.' ;
 errorArray[69] =  'Discount parking value can not be blank.';
 
 errorArray[70] = 'Company Name and EIN already exist.';
 errorArray[71] = 'EIN number already exist.';
 
 errorArray[72] = "Value can not be blank.";
 errorArray[73] =  'First Time Customer Reward Value must be integer.';
 errorArray[74] = 'Please add assosiate coupon with discount. ';
 
 // user section
 
  errorArray[75] = 'Zipcode can not be blank.'; 
  errorArray[76] = 'Email address already exists! Please change the email address and try again. If you are a registered customer, please enter your login email and password in the "Customer Login" area above.';
  errorArray[77] = 'Password and Confirm Password are not same.';
  
  //user reservation
  errorArray[78] = 'Please correct check-in date .';
  errorArray[79] = 'Please correct check-out date.';
   
  errorArray[80] = 'Check-In date is earlier than Check-Out date.';
  errorArray[81] = 'Please select Check-In date.';
  errorArray[82] = 'Please select Check-Out date.'; 
  errorArray[83] = 'Please select Location.';
  
  errorArray[84] = 'Please select Check-In time.'; 
  errorArray[85] = 'Please select Check-Out time.'; 
  
  errorArray[86] = 'Prefix Coupon number length not more than 4 character.';
  
  errorArray[88] = 'Vendor To Customer Per Transaction value can not be blank.';
  errorArray[89] = 'Portal To Vendor Per Transaction value can not be blank.';
  errorArray[90] = 'Additional Portal To Vendor Charge Per Transaction value can not be blank.';
  errorArray[91] = 'Please enter correct URL eg. "http://www.example.com/pagename"';
  errorArray[92] = 'Discount value can not be blank.';
  errorArray[93] = 'Portal To Customer Per Transaction value can not be blank.';
  errorArray[94] = 'Graduity name can not be blank.';
  errorArray[95] = 'Graduity discription can not be blank.';
  
  errorArray[96] = 'Please enter credit card number.';
  errorArray[97] = 'Please enter card varification number.';
  //errorArray[98] = 'Please select card expiry year.';
  errorArray[99] = 'Please agree with service agreement.';
  
  errorArray[100] = 'Country name can not be blank.';  
  errorArray[101] = 'Atleast one pay option must be enabled.'; 
  errorArray[102] = 'Please select pay option.'
  errorArray[103] = 'Please select pay method.' 
  
  errorArray[106] = 'Please enter review title.' 
  errorArray[107] = 'Please enter review message.' 
  errorArray[108] = 'Please select rate for the vendor.'
  
  errorArray[109] = 'Please enter the disapproved reason.' 
  
  errorArray[110]='Please enter all spot name/number.'; 
  
  errorArray[111] = 'Number of hours can not be blank.' 
  
  errorArray[112]= 'Cancelation Charge can not be blank'
  
  errorArray[113] = 'Number of hours already exist.'
  
  errorArray[114] = 'Decline cancellation request reason can not be blank.'
  
  errorArray[115] = 'Approved refund amount can not be blank.';
  
  errorArray[116] = 'Check-in time should be greater than Check-out time.';
  
  errorArray[117] = 'Selected Month has expired.';
  
  errorArray[118] = 'Selected Year has expired.'; 
  
  errorArray[119] = ' "Free Shuttle" minutes can not be blank.';
  
  errorArray[120] = 'Please enter "Charge Name, Type of Charge, Value and Description, all fields are mandatory."';
  
  errorArray[121] = 'Invalid price format (e.g. $0.00). ';
  
  errorArray[124] = 'Password should be more than 6 and less than 15 character. ';
  
  errorArray[125] = 'Please enter the email address for varification.';
  
  errorArray[126] = 'Email address and Verify email address should be same.';
  
  errorArray[127] = 'Successfully unsubscribe newsletter.';
  errorArray[128] = 'Successfully subscribe newsletter.';
  
  errorArray[129] = 'Airport distance should be numeric.';
  
  errorArray[130] = 'Please select state .';
  errorArray[131] = 'Please select country .';
  
  errorArray[132] = 'Please enter province name.';
  
  errorArray[133] = 'Airport name can not be blank.';
  errorArray[134] = 'Airport abbrevation can not be blank.';
  
  errorArray[135] = 'Airport already exist.'; 
  errorArray[136] = 'Airport abbrevation already exist.';
  errorArray[137] = 'Please select "Are the Location Prices the same every day" for Self Parking.';
  errorArray[138] = 'Please select "Are the Location Prices the same every day" for Valet Parking.';
  errorArray[139] = 'Please select "Are the Location Prices the same every day" for Pre-assign Parking.'; 
  errorArray[140] = 'Please select user type.';
  errorArray[141] = 'User first name can not be blank.';
  errorArray[142] = 'User last name can not be blank.';
  
  errorArray[143] = 'Template name can not blank.';
  errorArray[144] = 'Template from address can not be blank.';
  errorArray[145] = 'Template reply to address can not be blank.';
  errorArray[146] = 'Temaplate subject can not be blank.';
  errorArray[147] = 'Template body can not be blank.';
  errorArray[148] = 'Select airport timezone.'; 
  errorArray[149] = 'Mailing list name can not be blank.'; 
  errorArray[150] = 'First name can not be blank.';  
  errorArray[151] = 'Last name can not be blank.';  
  errorArray[153] = 'Please select mailing list name.';  
  errorArray[152] = 'Customer email address can not be blank.'; 
  
  errorArray[154] = 'Mailing list name already exist.';
  
	errorArray[175] = 'Old password can not be blank';
  errorArray[176] = 'New password can not be blank';
  errorArray[177] = 'Confirm new password can not be blank';
  errorArray[178] = 'Password and confirm Password should be same';
   errorArray[179] = 'Password should be more than 4 and less than 15 character';
  
  var HELP_SIGNUP_MEMBER_OF = '<p style="color:#000000;">As a token of our appreciation to those who put themselves in harms way for our well-being, we are pleased to offer members of the US armed forces, peace officers, firefighters, and veterans a  discount on all reservations.</p><p style="color:#000000;">Once we receive your sign-up form and confirm your status, we will provide you with a special "Rewards Number" to use on all your future reservations with us. All you have to do is enter it in the "Discount Coupon Number (Optional)" field on the "Find Parking" section on the "Home" page.</p><p style="color:#000000;">NOTE: THE DISCOUNT IS NOT APPLICABLE FOR THIS RESERVATION, IF THIS IS YOUR FIRST TIME SIGNING-UP WITH US!</p>';
  
var ALTERNATIVE_MAIL_EXPLANATION = 'The "Alternative Email Address" you provide here will ONLY be used for email communications, such as reservation confirmations and news letters. However, your user name (used for login into the site) will remain the same as the email address you have provided initially on the sign-up form!'

 var HTTP_DOMAIN ="http://www.i-parkntravel.com";
 var HTTPS_DOMAIN ="https://www.i-parkntravel.com"; 

  
  
  
/*
################################################################################################################
# Function Name :fnAddOption() 
# Created By: Manish Sharma
# Created On: 07 July 2008
# Parameter : selectbox - select box id
#             text - selectbox option text -show
#             value - selectbox option text - value
# Purpose : show all value in reward discount field from  table.
#################################################################################################################
*/ 
function fnAddOption(selectbox,text,value )
{
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    selectbox.options.add(optn);
}

/*
################################################################################################################
# Function Name : Below four image swap function 
# Created By: Manish Sharma
# Created On: 02 August 2008
# Purpose : below four function is used in tabs presentation image swaping function
#################################################################################################################
*/ 

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} 
}


/* 
#########################################################################
# Function Name : fnJSFormSubmit()
# Created By : Manish Sharma
# Created On : 16 May 2008
# Description : function for submit form through javascript
# Parameter : formName - form name which is to submit
########################################################################## 
 */ 
function fnJSFormSubmit()
{
    if(fnReservSearchValidation())
    {
        document.reservation1.submit();
    }    
}


function fnShowProvience(id)
{
  var val = fnGetFieldValue(id);
  if(val=='notusa')
  {
       document.getElementById('Province').disabled=false;
       fnSetFieldValue('Province','');
 
  }
  else
  {
       
       document.getElementById('Province').disabled=true;
       fnSetFieldValue('Province',''); 
  }

}


/*
##################################################################
*/
function checkSearchForm()
{
	var form = document.searchcustomer;
	
	if(form.searchName.value != "" && form.searchEmail.value !="")
	{
		alert("Please search either by Name or Email, not with both the fields");	
		return false;
	}
}
 
// stop hiding
 --> 