 /* JavaScript for: http://www.time4trip.in/index.php

   1. http://www.time4trip.in/common/formValidation.js
   2. http://www.time4trip.in/common/image_flip.js
   3. http://www.time4trip.in/css/Magnonsolutions.js
   4. http://www.time4trip.in/lib/validation.js
   5. http://www.time4trip.in/lib/CalendarPopup.js
   6. http://www.time4trip.in/lib/calendaroperateSearch.js
   7. http://www.time4trip.in/lib/sitevalidation.js
   8. http://www.time4trip.in/lib/multipleRooms.js
   9. http://www.time4trip.in/lib/ht_search.js
  10. http://www.google.com/coop/cse/brand?form=cse-search-box<=en
  11. http://ads.ibibo.com/ad/www/delivery/ajs.php?zoneid=4048&target=_blank&block=1&blockcampaign=1&cb=33351279699&charset=UTF-8&loc=http%3A//www.time4trip.in/index.php
  12. inline script block #1
  13. inline script block #2
  14. inline script block #3
  15. inline script block #4
  16. inline script block #5
  17. inline script block #6

http://www.time4trip.in/common/formValidation.js
*/
/*	VALIDATION TYPE
	===============
	email										Whether field is valid email or not
	blank	 	  								Field must not be blank 
	blank_email								field must be email type as well as mandatory 
	numeric									field must have numeric value
	blank_numeric						field must be numeric as well as numeric
	http											url check if value exist
	blank_http								must have value and valid url 
	VALID_FILENAME					no special charcter allowed for file name except underscore and 
	BLANK_VALID_FILENAME
	radio_blank  define this validation on first radio option rest all will validated automatically. 
	blank_time checking time format 'hh:mm:ss' as well mandatory value
	time checking time format 'hh:mm:ss' if value exit
*/
var deselect=0;
var date_format;
date_format="YMD";
var extArr=new Array(".pdf",".doc",".txt",".rtf",".docx", ".ppt", ".xls");
var extArrImage=new Array(".jpg",".jpeg",".jpe",".gif",".png",".bmp",".pjpe",".pjpeg",".pjpg");		

function reloadParent() { 
opener.location.reload(true); 
setTimeout("self.close()",500); 
} 

function validate_form(frm)	//	FORM VALIDATION FUNCTION
{
	var alert_str="";
	var field_name="";
	var temp_ele,temp_flag;
	var frm_length=frm.length;
	temp_flag=0;
	var check=new String;
	with(frm)
	{
		for(var i=0;i < frm_length;i++)
		{
			//var re = new RegExp ('_', 'gi') ;
			//var field_name = elements[i].name.replace(re,' ');
			//field_name = word_capitalize(field_name);
			temp_ele=elements[i];
			//alert(temp_ele.accept+"  "+temp_ele.name);
			//alert(elements[i].accept +" id-> "+elements[i].id+" name-> "+elements[i].name+" maxlength-> "+elements[i].maxlength+" dir-> "+elements[i].dir+" accesskey-> "+elements[i].accesskey+" style-> "+elements[i].style+" title-> "+elements[i].title);
			check="";
			check=elements[i].accept;
			//	alert(check+"  "+elements[i].name+"  "+elements[i].size);	
			if(typeof check == "undefined" || check == "")
			{
				check=elements[i].accessKey;
			}
			if(typeof check == "undefined" || check == "")
			{
				check=elements[i].id;
			}
			//	alert(check+"  "+check.indexOf("blank_checkSize"));
			if(check.indexOf("blank_checkSize") >= 0)
			{
				check="blank_size";
				
				length1=elements[i].accessKey.substring(elements[i].accessKey.lastIndexOf('_')+1,elements[i].accessKey.length);
				length1=parseInt(length1,10);
			}
			else if(check.indexOf("checkSize") >= 0)
			{
				check="check_size";
				
				length1=elements[i].accessKey.substring(elements[i].accessKey.lastIndexOf('_')+1,elements[i].accessKey.length);
				length1=parseInt(length1,10);
			} 
			else if (check.indexOf("compare_") >= 0)
			{
				check="compare";
			}
			//	alert(check+"  "+check.indexOf("blank_checkSize"));
			if(check == "blank1" || check == "blank2" || check == "blank3" || check == "blank4" || check == "blank5" || check == "blank6" || check == "blank7" || check == "blank8" || check == "blank9" || check == "blank10")
				check='blank';

			if(elements[i].disabled== true)
				check="";
			switch(check)
			{
				case "file_type" :
				if(check_blank(elements[i].value)) 
				{
					if(!validFileType(elements[i].value,extArr)) 
					{
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);
						alert_str+=field_name+"  : Invalid File Type\n";
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
				break;
				case "blank_file_type" :
				if(!blankValidFileType(elements[i].value,extArr)) 
				{
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);
					alert_str+=field_name+"  : Blank / Invalid File Type\n";
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
				break;
			case "image_type" :
			if(check_blank(elements[i].value)) 
			{
				if(!validFileType(elements[i].value,extArrImage)) 
				{
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);
					alert_str+=field_name+"  : Invalid Image File Type\n";
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
			}
			break;
			case "blank_image_type" :
			if(!blankValidFileType(elements[i].value,extArrImage)) 
			{
				field_name = elements[i].title;
				if(field_name=="")
					field_name = word_capitalize(elements[i].name);
				alert_str+=field_name+"  : Blank / Invalid Image File Type\n";
				if(temp_flag==0)
				{
					temp_ele.focus();
					temp_flag=1;
				}
				}
			break;
				case "blank_size" :
				var error=new String;
				var length1;
				field_name=elements[i].title;
				if(field_name=="")
					field_name=word_capitalize(elements[i].name);

				error=check_blank_size(elements[i].value,length1,field_name);
				if(error) 
				{
					alert_str+=error+"\n";
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
				break;
				case "check_size" :
				var length1;
				if(elements[i].value.length > length1) 
				{
					size=length1+1;
					field_name=elements[i].title;
				if(field_name=="")
					field_name=word_capitalize(elements[i].name);
				alert_str+="Length of "+field_name+" must be less than "+size+"\n";
				if(temp_flag==0)
				{
					temp_ele.focus();
					temp_flag=1;
				}
			}
			break;
			case "TOC" :
			//alert(elements[i].checked);
			if(elements[i].checked == false)
			{
				alert_str+="Agree with our terms and condition.\n";
			}
			break;
			case "username" :
			if(error=isValidUserName(elements[i].value))
			{
				field_name=elements[i].title;
				if(field_name=="")
					field_name = error;
				alert_str+=field_name+"\n";
				if(temp_flag==0)
				{
					temp_ele.focus();
					temp_flag=1;
				}
			}
			break;
			case "password" :
				if(error1=isValidPassword(elements[i].value)) 
				{
					field_name=elements[i].title;
					if(field_name=="")
						field_name=word_capitalize(elements[i].name);
					alert_str+=error1+" "+field_name+"\n";
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
			break;
			case "email" :
				if(check_blank(elements[i].value)) 
				{
					if(!isValidMail(elements[i].value)) 
					{
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);
						alert_str+=field_name+"  : Invalid Email\n";
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
			break;
			
			case "blank" :
				if(!check_blank(elements[i].value)) 
				{
					//field_name = word_capitalize(elements[i].name);
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);

					//alert(temp_ele.type);
					if(temp_ele.type=="select-one" || temp_ele.type=="select-multiple")
						alert_str+="Please select the value for "+field_name+"\n";	
					else
						alert_str+="Please enter a value in "+field_name+"\n";	
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
			break;
			
			case "blank_email" :
				if(!check_blank_email(elements[i].value)) 
				{
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);
					alert_str+=field_name+" : Blank / Invalid \n"; 
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
			break;
				
			case "numeric" :
				if(elements[i].value)
				{
					if(!check_numeric(elements[i].value)) 
					{
						//field_name = word_capitalize(elements[i].name);
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);

						alert_str+=field_name+"  : Should Be Numeric\n"; 
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
			break;
			
			case "blank_numeric" :
				if(!check_blank_numeric(elements[i].value)) 
				{
					//field_name = word_capitalize(elements[i].name);
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);

					alert_str+=field_name+" : Blank / Not Numeric\n"; 
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
			break;
			
			case "VALID_FILENAME" :
				if(!valid_filename(elements[i].value)) 
				{
					field_name = elements[i].title;
					alert_str+=field_name;
					if(field_name=="")
					{
						field_name = word_capitalize(elements[i].name);
						alert_str+=field_name+" Invalid Data value \n   Allowed character list (a-z,A-Z,underscore(_))\n";
					}

					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
			break;
			
			case "BLANK_VALID_FILENAME" :
				if(!blank_valid_filename(elements[i].value)) 
				{
					//field_name = word_capitalize(elements[i].name);
					field_name = elements[i].title;
					alert_str+=field_name;
					if(field_name=="")
					{
						field_name = word_capitalize(elements[i].name);
						alert_str+=field_name+" Blank or Invalid character values \n    Allowed character list (a-z,A-Z,underscore(_))\n";
					}
					
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
				break;
			case "radio_blank":
				if(!check_radio(frm,elements[i].name))
				{
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);

					alert_str+=field_name+" : Not Selected\n"; 
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
				//i=i+elements[i].name.length-1;
			break;
			
			case "http" :
				if(check_blank(elements[i].value)) 
				{
					if(!isValidWebname(elements[i].value)) 
					{
						//field_name = word_capitalize(elements[i].name);
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);

						alert_str+=field_name+" : Invalid url\n"; 
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
			break;
			

			case "blank_http" :
				if(check_blank(elements[i].value)) 
				{
					if(!isValidWebname(elements[i].value)) 
					{
						//field_name = word_capitalize(elements[i].name);
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);

						alert_str+=field_name+" : Invalid url\n"; 
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
				else
				{
					//field_name = word_capitalize(elements[i].name);
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);

					//alert(temp_ele.type);
					alert_str+="Please enter a value in "+field_name+"\n";	
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
				break;

				case "blank_date" :
				if(check_blank(elements[i].value)) 
				{
					var date_error;
					if(date_error=checkDateFormat(elements[i].value,date_format)) 
					{
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);

						alert_str+=field_name+" : "+date_error+"\n"; 
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
				else
				{
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);

					alert_str+=field_name+": Blank or Invalid\n";	
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
				break;

				case "date" :
				if(check_blank(elements[i].value) && elements[i].value.length > 0) 
				{
					var date_error;
					if(date_error=checkDateFormat(elements[i].value,date_format)) 
					{
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);

						alert_str+=field_name+" : "+date_error+"\n"; 
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
				break;
				case "blank_time" :
				if(check_blank(elements[i].value)) 
				{
					var date_error;
					if(date_error=checkTimeFormat(elements[i].value)) 
					{
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);

						alert_str+=field_name+" : "+date_error+"\n"; 
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
				else
				{
					field_name = elements[i].title;
					if(field_name=="")
						field_name = word_capitalize(elements[i].name);

					alert_str+=field_name+": Blank or Invalid\n";	
					if(temp_flag==0)
					{
						temp_ele.focus();
						temp_flag=1;
					}
				}
				break;

				case "time" :
				if(check_blank(elements[i].value)) 
				{
					var date_error;
					if(date_error=checkTimeFormat(elements[i].value)) 
					{
						field_name = elements[i].title;
						if(field_name=="")
							field_name = word_capitalize(elements[i].name);

						alert_str+=field_name+" : "+date_error+"\n"; 
						if(temp_flag==0)
						{
							temp_ele.focus();
							temp_flag=1;
						}
					}
				}
				break;

				case "compare":
				if (check_blank(elements[i].value))
				{
					var accpt = elements[i].accept;
					var compWith = accpt.split("_");
					conpWith = compWith[1];
					compWith = eval("elements[i].form."+compWith+".value");
					if (elements[i].value != compWith)
					{
						field_name = elements[i].title;
						if (field_name == "")
							field_name = word_capitalize(elements[i].name);
						alert_str += field_name + " is not matching" + "\n";
						if (temp_flag == 0)
						{
							temp_ele.focus();
							temp_flag = 1;
						}
					}
				} 
				else 
				{
					field_name = elements[i].title;
					if (field_name == "")
						field_name = word_capitalize(elements[i].name);
					alert_str += "Please enter a value in " + field_name + "\n";
					if (temp_flag == 0)
					{
						temp_ele.focus();
						temp_flag = 1;
					}
				}

			}
		}
		if(alert_str)
			alert_str="Check Following :\n\n"+alert_str;
		return(alert_str);
	}
}

function addbookmark(bookmarkurl)
{
	var bookmarktitle="Bookmark";
	if(document.all)
		window.external.AddFavorite(bookmarkurl,"bookmarktitle");
	else if (window.sidebar)
	{	
		window.sidebar.addPanel(bookmarktitle, bookmarkurl, "")
	}
}

function check_blank(str)
{
	var re = new RegExp (' ', 'gi') ;
	var newstr = str.replace(re, '') ;
	if(newstr.length==0)
		return(false);
	else
		return(true);
}

function previewWin(obj)
{
	if(document.all)
	{
		previewLink = document.getElementById(obj).value;
	}
	else if(document.getElementById)
	{
		previewLink = 'file:///'+document.getElementById(obj).value;
	}

	if(document.getElementById(obj).value !=="")
	{
		var oPreview = window.open("/preview.html",'Preview','width=420,height=450');
		oPreview.focus();
	}
	else
		alert("Click \"Browse...\" to find photos on your computer.");
}

function previewContent(obj)
{
	if(document.all)
		previewLink = document.getElementById(obj).value;
	else if(document.getElementById)
		previewLink = document.getElementById(obj).value;
		//alert(previewLink);
	if(document.getElementById(obj).value !=="")
	{
		var oPreview = window.open('../previewContent.html','Preview','width=420,height=450');
		oPreview.focus();
	}
	else
		alert("Click \"Browse...\" to find photos on your computer.");
}

function browseWin(obj)
{
	if(document.all)
		previewLink = document.getElementById(obj).value;
	else if(document.getElementById)
		previewLink = document.getElementById(obj).value;
		//alert(previewLink);
	if(previewLink !=="")
	{
		var oPreview = window.open(previewLink,'Preview');
		oPreview.focus();
	}
	else
		alert("Please Enter URL to browse.");
}

function check_numeric ( n ) 
{
	var v = 1.0 * n ;
	if ( isNaN(v) )
		return false;
	else
		return true;
}

function check_blank_numeric(str)
{
	if(!check_blank(str))
		return(false);
	else if(!check_numeric(str))
		return(false);
	else
		return(true);
}

function check_blank_email(str)
{
	if(!check_blank(str))
		return(false);
	else if(!isValidMail(str))
		return(false);
	else
		return(true);
}

function check_radio(frm,element)
{
	flag=0;
	with(frm)
	{
		temp=eval(element+".length");
		for(i=0; i < temp; i++)
		{
			//alert(eval(element+"["+i+"].checked")+"  "+i);
			if(eval(element+"["+i+"].checked"))
			{
				flag=1;
				break;
			}
		}
	}
	if(flag==0)
		return false;
	else
		return true;
}

function valid_filename(myString)
{
	if(myString.match(/^[a-zA-Z0-9_ \ ]*$/) == null)
		return false;
	else
		return true;
}

function blank_valid_filename(myString)
{
	if(!check_blank(myString))
		return false;
	else if(!valid_filename(myString))
		return false;
	else
		return true;
}

function check_blank_size(myString,size,name)
{
	if(check_blank(myString) == false)
	{
		var abc="Please enter a value for "+word_capitalize(name);
		return abc;
	}
	else if(myString.length > size)
		return "Length of  "+word_capitalize(name)+" must be less than "+(parseInt(size,10)+1);
	else
		return "";
}

function isValidUserName(username)
{	
	m=new String(username);
	var userLength=m.length
	var isValid=0
	if(!check_blank(username))
	{
		return "Please Enter a value in Username";
	}
	else if(userLength < 5 || userLength > 25)
	{	
		return "Username length must be between 5 and 25.";
	}
	else
	{
		if(username.match(/^[a-zA-Z0-9_]*$/) == null)
			return "Invalid username allowed characters [a-z, A-Z, 0-9, _]";
		else
			return "";
	}
}

function isValidPassword(password)
{	
	m=new String(password);
	var passLength=m.length
	var isValid=0
	if(!check_blank(password))
	{
		return "Please Enter a value in ";
	}
	else if((passLength < 5 || passLength > 25) && 1==2)
	{	
		return "Password length must be between 5 and 25.";
	}
	/*else
	{
		if(password.match(/^[\'|\"|]*$/) == null)
			return "";
		else
			return "Invalid Password Spaces,Single Quotes,Double Quotes not allowed";
	}*/
	return "";
}

function isValidMail(mail)	
{
	m=new String(mail);
	var mailLength=m.length
	var totalDOT=0
	var totalROUTE=0
	var totalSPACE=0

	// Should not beging with a '.' or '@'
	if(m.charAt(0)=='@' || m.charAt(0) == '.')
	{	return false;		}

	// 
	for(ctr=1;ctr<=mailLength;ctr++)
	{	if (m.charAt(ctr)=='@')	{	totalROUTE++;	}	
		if (m.charAt(ctr)=='.')	{	totalDOT++;	}	
		if (m.charAt(ctr)==' ') {	totalSPACE++;	}
	}

	if (totalROUTE!=1)			//Checking for Multiple @
	{	return false;		}
	if(totalDOT<1)				//Checking for Route Domain
	{	return false;		}
	if(totalSPACE>0)			//No Embeded Space
	{	return false;		}
	
	//Checking for Invalid Characters

	for(ctr=0;ctr<=mailLength;ctr++)
	{	
		if (m.charAt(ctr)=='`')	return false;	
		else if (m.charAt(ctr)=='!')	return false;	
		else if (m.charAt(ctr)==' ') 	return false;	
		else if (m.charAt(ctr)=='#')	return false;	
		else if (m.charAt(ctr)=='$')	return false;	
		else if (m.charAt(ctr)=='%')	return false;	
		else if (m.charAt(ctr)=='^')	return false;	
		else if (m.charAt(ctr)=='&')	return false;	
		else if (m.charAt(ctr)=='*')	return false;	
		else if (m.charAt(ctr)=='(')	return false;	
		else if (m.charAt(ctr)==')')	return false;	
		else if (m.charAt(ctr)=='+')	return false;	
		else if (m.charAt(ctr)=='=')	return false;	
		else if (m.charAt(ctr)=='|')	return false;	
		else if (m.charAt(ctr)=='\\')	return false;	
		else if (m.charAt(ctr)=='{')	return false;	
		else if (m.charAt(ctr)=='}')	return false;	
		else if (m.charAt(ctr)=='[')	return false;	
		else if (m.charAt(ctr)==']')	return false;	
		else if (m.charAt(ctr)==':')	return false;
		else if (m.charAt(ctr)==';')	return false;	
		else if (m.charAt(ctr)=='"')	return false;	
		else if (m.charAt(ctr)=="'")	return false;	
		else if (m.charAt(ctr)=='<')	return false;	
		else if (m.charAt(ctr)=='>')	return false;	
		else if (m.charAt(ctr)==',')	return false;	
		else if (m.charAt(ctr)=='?')	return false;	
		else if (m.charAt(ctr)=='/')	return false;	
	}
	return true;
}


function newBigWindow(URL, WIN_NAME)
{	
	//alert(URL);
	var HEIGHT=screen.height;
	var POPUP_HEIGHT = HEIGHT-150;
	var POPUP_WIDTH = 890;

	var HEIGHT_POP=screen.height;
	HEIGHT_POP=(HEIGHT_POP/2) - (POPUP_HEIGHT/2);
	var WIDTH_POP=screen.width;
	WIDTH_POP=(WIDTH_POP/2) - (POPUP_WIDTH/2);
	open_win=window.open(URL, WIN_NAME, 'top='+HEIGHT_POP+', left='+WIDTH_POP+', width='+POPUP_WIDTH+',height='+POPUP_HEIGHT+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
	open_win.focus();
	//alert(open_win);
	return false;
}


function newBig2Window(URL, WIN_NAME)
{	
	//alert(URL);
	var HEIGHT=screen.height;
	var POPUP_HEIGHT = 400;
	var POPUP_WIDTH = 740;

	var HEIGHT_POP=screen.height;
	HEIGHT_POP=(HEIGHT_POP/2) - (POPUP_HEIGHT/2);
	var WIDTH_POP=screen.width;
	WIDTH_POP=(WIDTH_POP/2) - (POPUP_WIDTH/2);
	open_win=window.open(URL, WIN_NAME, 'top='+HEIGHT_POP+', left='+WIDTH_POP+', width='+POPUP_WIDTH+',height='+POPUP_HEIGHT+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
	open_win.focus();
	//alert(open_win);
	return false;
}


function newMediumWindow(URL, WIN_NAME)
{	
	//alert(URL);
	var HEIGHT=screen.height;
	var POPUP_HEIGHT = HEIGHT-150;
	var POPUP_WIDTH = 600;

	var HEIGHT_POP=screen.height;
	HEIGHT_POP=(HEIGHT_POP/2) - (POPUP_HEIGHT/2);
	var WIDTH_POP=screen.width;
	WIDTH_POP=(WIDTH_POP/2) - (POPUP_WIDTH/2);
	open_win=window.open(URL, WIN_NAME, 'top='+HEIGHT_POP+', left='+WIDTH_POP+', width='+POPUP_WIDTH+',height='+POPUP_HEIGHT+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
	open_win.focus();
	return false;
}

function newSmallWindow(URL, WIN_NAME)
{	
	var HEIGHT=screen.height;
	var POPUP_HEIGHT = HEIGHT-500;
	var POPUP_WIDTH = 500;

	var HEIGHT_POP=screen.height;
	HEIGHT_POP=(HEIGHT_POP/2) - (POPUP_HEIGHT/2);
	var WIDTH_POP=screen.width;
	WIDTH_POP=(WIDTH_POP/2) - (POPUP_WIDTH/2);
	open_win=window.open(URL, WIN_NAME, 'top='+HEIGHT_POP+', left='+WIDTH_POP+', width='+POPUP_WIDTH+',height='+POPUP_HEIGHT+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
	open_win.focus();
	return false;;
}

function MySmallWindow(URL, WIN_NAME, wt, ht)
{	
	var HEIGHT=screen.height;
	var POPUP_HEIGHT = HEIGHT-291;
	var POPUP_WIDTH = 500;
	src=URL;
	var HEIGHT_POP=screen.height;
	HEIGHT_POP=(HEIGHT_POP/2) - (POPUP_HEIGHT/2);
	var WIDTH_POP=screen.width;
	WIDTH_POP=(WIDTH_POP/2) - (POPUP_WIDTH/2);
	if(wt != "")
		POPUP_WIDTH=parseInt(wt)+18;
	if(ht != "")
		POPUP_HEIGHT=parseInt(ht)+29;
	window.open("../pop.html", WIN_NAME, 'top='+HEIGHT_POP+', left='+WIDTH_POP+', width='+POPUP_WIDTH+',height='+POPUP_HEIGHT+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
	return false;
}

function deleteConfirm(frm)
{
	var flag=0;
	with(frm)
	{
		for(i=0;i<frm.length;i++)
		{
			if((elements[i].type=='checkbox' || elements[i].type=='radio') && elements[i].checked)
			{		
				if(confirm("Are you sure to delete the selected record? "))
				{
					submit();
					return true;
				}
				else
					return false;
			}
		}
	}
	alert("No record selected");
	return false;
}


function SelectConfirm(frm)
{
	var flag=0;
	with(frm)
	{
		for(i=0;i<frm.length;i++)
		{
			if((elements[i].type=='checkbox' || elements[i].type=='radio') && elements[i].checked)
			{		
				//if(confirm("Are you sure to delete the selected record? "))
				//{
					submit();
					return true;
				//}
				//else
				//	return false;
			}
		}
	}
	alert("No record selected");
	return false;
}

function Confirmdelete(val)
{
	var flag=0;	
	if(confirm("Are you sure to delete this Image? "))
	{
		document.BuyPhotoForm.SUBMIT_DEL.value="delete";
		document.BuyPhotoForm.img_id.value=val;
		document.BuyPhotoForm.submit();
		return true;
	}


}

function ConfirmUpdate(val, status)
{
	var flag=0;	
	if(confirm("Are you sure to Update this Image Status? "))
	{
		document.BuyPhotoForm.SUBMIT_UPDATE.value="update";
		document.BuyPhotoForm.img_id.value=val;
		document.BuyPhotoForm.status.value=status;
		document.BuyPhotoForm.submit();
		return true;
	}
	

}


function redirect(param)
{
	location.href=param;
}


function word_capitalize(field_name1)
{
	var re = new RegExp ('_', 'gi');
	var field_name = field_name1.replace(re,' ');
	field_name = field_name.replace('[','');
	field_name = field_name.replace(']','');
	var ret_field_name="";
	var ar=field_name.split(" ");
	for(var i=0; i < ar.length; i++)
	{
		var temp=ar[i].charAt(0).toUpperCase()+ar[i].substr(1).toLowerCase();
		ret_field_name+=temp+" ";
	}
	return(ret_field_name);
}

// ON ENTER PRESSS FORM VALIDATIOAN AND FORM SUBMISSION

function checkEnter(e,frm_name)
{ //e is event object passed from function invocation
	var characterCode ;//literal character code will be stored in this variable

	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		//alert("e");
		e = e
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)
	{ //if generated character code is equal to ascii 13 (if enter key)
	//document.forms[0].submit() //submit the form
		validate_frm(frm_name);
		return false; 
	}
	else
	{
		return true;
	}
}

function check_all(frm)
{
	with(frm)
	{
		if(deselect==0)
		{
			for(i=0; i < frm.length; i++)
			{
				if(elements[i].type=='checkbox')
					elements[i].checked=true;
			}
			deselect=1;
		}
		else
		{
			for(i=0; i < frm.length; i++)
			{
				if(frm.elements[i].type=='checkbox')
					frm.elements[i].checked=false;
			}
			deselect=0;
		}
	}
}



function check_selected(frm)
{
	var flag="";
	with(frm)
	{
		for(i=0; i < frm.length; i++)
		{
			if(elements[i].type=='checkbox' || elements[i].type=='radio')
			{
				if(elements[i].checked==true)
				{
					flag=true;
					break;
				}
				else
					flag=false;
			}
		}
		if(flag==false)
		{
			alert("Please Select at least one row.")
			return false;
		}
		else
			return true;
	}
}

function check_phone(val)
{   
    var allowed_char= "0123456789!-_()@!";

    for (i = 0; i < val.length; i++)
    {   
        var c = val.charAt(i);
        if (allowed_char.indexOf(c) == -1)
		return false;
    }
    return true;
}

function close_func(close_check, loc)
{
	if(loc)
		eval("window."+loc).location.reload();
	if(close_check)
		window.close();
}

function isValidWebname(str)
{
	myString=new String();
	myString=str;
	if(!check_blank(myString)) 
		return false;
	//if(myString.match(/^(http)(s)?(:\/\/)[a-zA-Z0-9_./-\?\=\#\*]*$/i) == null)
	if(myString.match(/^(http)(s)?(:\/\/)[\S]*$/i) == null)
		return false;
	return true;
}

function CompareDates(D1,D2,msg)
{	var dt1 = new  String(D1)
	myAr1 = dt1.split('-');
	var dt2 = new  String(D2)
	myAr2 = dt2.split('-');

	var y1 = myAr1[0];
	var y2 = myAr2[0];
	var d1 = myAr1[2];
	var d2 = myAr2[2];
	var m1 = myAr1[1];
	var m2 = myAr2[1];

	//alert(y1+"  "+d1+"  "+m1+"  "+y2+"  "+d2+"  "+m2);
		
	if (eval(y1) > eval(y2))
	{	
		alert(msg); return false;	
	}
		if (eval(y1) == eval(y2))
		{	if (eval(m1) == eval(m2))
			{	if (eval(d1) > eval(d2))
				{	alert(msg); return false;	
				}
			}
			else 
			{	if (eval(m1) > eval(m2))	
				{	alert(msg); return false;	
				}
			}
		}
		return true;
}

function isValidDate(byear,bmonth,bday)
{	
		var yr=byear;
	    var mon=bmonth;
		
      	var day=bday;

		//Checking for Non-Numeric Values
     		if((isNaN(yr))||(isNaN(mon))||(isNaN(day)))
	      {	alert("Error! Invalid Date Format");
			return false;
	      }

		//Checking for Positive Numeric Values
		if((yr<1) || (mon<1) ||(day<1))
		{	alert("Error! Invalid Date Format")
			return false;
		}
		if (yr<1900)
		{	alert("Error! Year entered is too old")
			return false;
		}

		if (yr>9999)
		{	alert("Error! Enter year in 4 Digits")
			return false;
		}
	
    	if(mon>12)
	    {	alert("Error! Month Range 1-12.")
			return false;	
		}
    		if(day>31)
	      {	alert("Error! Day Range 1-31.")
			return false;
	      }
	
		//Checking for month having 30 days
		if(mon==4 || mon==6 || mon==9 || mon==11)
		{	if(day >30)
			{ 	alert("Error! Day Range 1-30 for the given month.")
				return false;
		      }
		}
	
		//Checking for February and Leap year
		if(mon==2)
		{	if(yr%4==0)
			{	if(day >29)
				{     alert("Error! Day Range 1-29 for the given month and year.")
					return false;
		      	}
			}
			else
			{	if(day >28)
				{	alert("Error! Day Range 1-28 for the given month and year.")
					return false;
	      		}
			}
		}
	     	return true;
}

function DoValidate(Dt)
{	
	var myDate = new  String(Dt)
	var SpaceExpr = /\s/;
	var SpacePos = myDate.search(SpaceExpr);
	if (SpacePos > -1)
	{	alert("No space allowed in a Date."); return false;
	}
	
	var dLength=myDate.length
	var totalSlash=0
	var totalChar=0
	var totalInvalids=0

	// Should not beging with a '/' or end with '/'
	if(myDate.charAt(0)=='-' || myDate.charAt(dLength) == '-')
	{	alert("Invalid Date");return false;		}

	// Scanning the String
	for(ctr=0;ctr<dLength;ctr++)
	{	Ch=myDate.charAt(ctr);
		if (Ch=='-')
		{	totalSlash++;	}			
		
		if (Ch!='-')
		{
			if (isNaN(Ch))	
			{	
				totalInvalids++;	
			}	
		}
		totalChar++;
	}
		
	if (totalSlash > 2)
	{	alert("Excess Separators used in the date."); return false;	}
	if (totalInvalids > 2)
	{	alert("Invalid Character present in Date."); return false;	}
	if (totalChar < 8)
	{	alert("Less Character present in Date."); return false;	}
	if (totalSlash==0)
	{	alert("Pleae use '-' (Dash) as Separator"); return false;	}	

	myArr = myDate.split('-');
	if (myArr.length < 3)
	{	alert("Invalid Date"); return false;	}

	if (!isValidDate(myArr[0],myArr[1],myArr[2]))//year,month date
	{	return false;	}

	return true;
}


	function checkDateFormat(date_string,format)
	{
		if(format == "YMD")
		{
			if(date_string.match(/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/) == null)
			//if(date_string.match(/^(19|20|30|40|50|60|70|80|90)\d\d[- /.](0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])$/) == null)
			{
				return("Invalid Date / Date Format");
			}
			else
			{
				myArr = date_string.split('-');
				var str;
				if(str=checkValidDate(parseInt(myArr[0],10),parseInt(myArr[1],10),parseInt(myArr[2],10)))
				{
					return str;
				}
			}
			return false;
		}
		else if(format == "DMY")
		{
			if(date_string.match(/^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$/) == null)
			//if(date_string.match(/^((0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[-/.]19|20|30|40|50|60|70|80|90)\d\d$/) == null)
			{
				return("Invalid Date / Date Format");
			}
			else
			{
				myArr = date_string.split('-');
				var str;
				if(str=checkValidDate(parseInt(myArr[2],10),parseInt(myArr[1],10),parseInt(myArr[0],10)))
				{
					return str;
				}
			}
			return false;
		}

		else if(format == "MDY")
		{
			if(date_string.match(/^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$/) == null)
			//if(date_string.match(/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[-/.](19|20|30|40|50|60|70|80|90)\d\d$/) == null)
			{
				return("Invalid Date Format");
			}
			else
			{
				myArr = date_string.split('-');
				var str;
				if(str=checkValidDate(parseInt(myArr[2],10),parseInt(myArr[0],10),parseInt(myArr[1],10)))
				{
					return str;
				}
			}
			return false;
		}

	}

	function checkTimeFormat(time_string)
	{
		if(time_string.match(/^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/) == null)
		{
			return("Invalid Time Format");
		}
		else
		{
			myArr = time_string.split(':');
			var str;
			if(str=checkValidTime(parseInt(myArr[0],10),parseInt(myArr[1],10),parseInt(myArr[2],10)))
			{
				return str;
			}
		}
		return "";
	}

	function checkValidTime(hour,minute,sec)
	{
		if(hour < 0 || hour > 23)
		{	
			return("Error! Hour Entered Is Invalid, Use [0-23]")
		}
		if(minute < 0 || minute > 59)
		{	
			return("Error! Minute Entered Is Invalid, Use [0-59]")
		}
		if(sec < 0 || sec > 59)
		{	
			return("Error! Seconds Entered Is Invalid, Use [0-59]")
		}

	}


	function checkValidDate(yr,mon,day)
	{
		if(yr < 1900)
		{	
			return("Error! Year entered is too old")
		}

		if(yr > 9999)
		{	
			return("Error! Enter year in 4 Digits")
		}

		if(mon > 12 || mon < 1)
		{	
			return("Error! Month Range 1-12.")
		}
		if(day > 31 || day < 1)
		{	
			return("Error! Day Range 1-31.")
		}
	
		if(mon == 4 || mon == 6 || mon == 9 || mon == 11)
		{	
			if(day > 30 || day < 1)
			{ 	
				return("Error! Day Range 1-30 for the given month.")
			}
		}

		if(mon==2)
		{	
			if(yr%4==0)
			{	
				if(day > 29 || day < 1)
				{     
					return("Error! Day Range 1-29 for the given month and year.")
				}
			}
			else
			{	
				if(day > 28 || day < 1)
				{	
					return("Error! Day Range 1-28 for the given month and year.")
				}
			}
		}
		return "";
	}

	function validate_frm(frm)
	{
		var str="";
		str=validate_form(frm);
		if(str)
		{
			alert(str);
			return false;
		}
		else
			return true;
	}


	function validate_frm_pass(frm,field1,field2)
	{
		var str="";
		with(frm)
		{
			str=validate_form(frm);
			if(str)
			{
				alert(str);
				return false;
			}
			else if(field1.value != field2.value)
			{
				alert("Value Of "+field1.name+" and "+field2.title+" not matching.");
				field1.focus();
				return false;
			}
			else
				return true;
		}
	}
	
	function post_data(action_php)
	{
		window.document.frm.action=action_php;
		if(action_php == "recipientGroup.php")
		{
			if(frm.newsletter_content)
			{
				var htmlvalue= new String();
				htmlvalue = SPAW_getHtmlValue('newsletter_content', thefield);
				window.document.frm.new_content.value=htmlvalue;
			}
		}
		window.document.frm.submit();
	}

	function checkAndOpenURL(fieldObj)
	{
		var str=new String;
		myString=fieldObj.value;
		if(!check_blank(myString)) 
		{
			alert("Blank "+fieldObj.title);
			fieldObj.focus();
			return false;
		}
		//if(myString.match(/^(http)(s)?(:\/\/)[a-zA-Z0-9_./-\=\?\#\*]*$/i) == null)
		if(myString.match(/^(http)(s)?(:\/\/)[\S]*$/i) == null)
		{
			alert("Invalid "+fieldObj.title);
			fieldObj.focus();
			return false;
		}
		else
		{
			window.open(fieldObj.value);
			return true;
		}
	}

	function post_data(action_php)
	{
		window.document.frm.action=action_php;
		window.document.frm.submit();
	}

	function validFileType(fileValue,extArray)
	{
		var allowSubmit;
		ext=fileValue.slice(fileValue.lastIndexOf(".")).toLowerCase();
		//alert(ext);
		for (var i = 0; i < extArray.length; i++) 
		{
			if (extArray[i]==ext) 
			{ 
				allowSubmit=true;
				break; 
			}
		}
		if (allowSubmit) 
			return true;
		else
			return false;
	}

	function blankValidFileType(myString,extArr)
	{
		if(!check_blank(myString))
			return false;
		else if(!validFileType(myString,extArr))
			return false;
		else
			return true;
	}


//////////TOOLTIP FUNCTIONS

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : 
window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : 
window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

function checkScrollAgree(frm,fieldname)
	{
		with(frm)
	  {
	    fieldname.checked=true;
		fieldname.value=true;
		fieldname.disabled=false;
	  }

	}

 /* http://www.time4trip.in/common/image_flip.js */
function showmenu()
{ 
document.getElementById("toolkit").className="on";
}

function hidemenu()
{
document.getElementById("toolkit").className="off";

}

function showmenua()
{ 
document.getElementById("toolkita").className="on";
}

function hidemenua()
{
document.getElementById("toolkita").className="off";

}


function showmenu3()
{ 
document.getElementById("toolkit3").className="on";
}

function hidemenu3()
{
document.getElementById("toolkit3").className="off";

}

function showmenu4()
{ 
document.getElementById("toolkit4").className="on";
document.getElementById("toolkit3").className="on";
}

function hidemenu4()
{
document.getElementById("toolkit4").className="off";
document.getElementById("toolkit3").className="off";

}

function showmenu5()
{ 
document.getElementById("toolkit5").className="on";
document.getElementById("toolkit3").className="on";
}

function hidemenu5()
{
document.getElementById("toolkit5").className="off";
document.getElementById("toolkit3").className="off";

}



//  Home Page Form Tab  //

function r()
{	

document.getElementById('round_trip').style.display="block";
document.getElementById('one_way').style.display="none";
document.getElementById('multi_city').style.display="none";

}
function o()
{	

document.getElementById('round_trip').style.display="none";
document.getElementById('one_way').style.display="block";
document.getElementById('multi_city').style.display="none";

}
function m()
{	

document.getElementById('round_trip').style.display="none";
document.getElementById('one_way').style.display="none";
document.getElementById('multi_city').style.display="block";

}

// Menu Image Flip  //
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 i_show(no_i)
{	

document.getElementById(no_i).style.display="block";

}
function i_hide(no_i)
{	

document.getElementById(no_i).style.display="none";

}

/* http://www.time4trip.in/css/Magnonsolutions.js */
// JavaScript Document
/************************************************************************************************************ 
(C) www.dhtmlgoodies.com, October 2005 
This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.    
Terms of use: 
You are free to use this script as long as the copyright message is kept intact. However, you may not 
redistribute, sell or repost it without our permission. 
Thank you! 
www.dhtmlgoodies.com 
Alf Magne Kalleland 
************************************************************************************************************/    
////////////////////////// DropDown Script Starts Here //////////////////////////	
var dhtmlgoodies_menu1Obj;   // Reference to the menu div 
var currentZIndex = 1000; 
var liIndex = 0; 
var visibleMenus = new Array(); 
var activeMenuItem = false; 
var timeBeforeAutoHide = 1200; // Microseconds from mouse leaves menu to auto hide. 
var dhtmlgoodies_menu1_arrow = 'images/arrow.gif'; 
var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false; 
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox')>=0?true:false; 
var navigatorVersion = navigator.appVersion.replace(/.*?MSIE ([0-9]\.[0-9]).*/g,'$1')/1; 
var menuBlockArray = new Array(); 
var menuParentOffsetLeft = false;    
// {{{ getStyle() 
/** 
* Return specific style attribute for an element 
* 
* @param Object el = Reference to HTML element 
* @param String property = Css property 
* @private 
*/        
function getStyle(el,property) 
{        
  if (document.defaultView && document.defaultView.getComputedStyle) { 
	 var retVal = null;              
	 var comp = document.defaultView.getComputedStyle(el, ''); 
	 if (comp){ 
		retVal = comp[property]; 
		if(!retVal){ 
		   var comp = document.defaultView.getComputedStyle(el, null); 
		   retVal = comp.getPropertyCSSValue(property); 
		}          
	 }    
	 if(retVal==null)retVal=''; 
	 return el.style[property] || retVal; 
  } 
  if (document.documentElement.currentStyle && MSIE){    
	 var value = el.currentStyle ? el.currentStyle[property] : null; 
	 return ( el.style[property] || value ); 
  } 
  return el.style[property];              
} 

function getTopPos(inputObj) 
{ 
var origInputObj = inputObj;
 var returnValue = inputObj.offsetTop; 
 if(inputObj.tagName=='LI' && inputObj.parentNode.className=='menuBlock1'){    
	var aTag = inputObj.getElementsByTagName('A')[0]; 
	if(aTag)returnValue += aTag.parentNode.offsetHeight; 
 } 
 var topOfMenuReached = false; 
 while((inputObj = inputObj.offsetParent) != null){ 
	if(inputObj.parentNode.id=='dhtmlgoodies_menu1')topOfMenuReached=true; 
	if(topOfMenuReached && !inputObj.className.match(/menuBlock/gi) || (!MSIE && origInputObj.parentNode.className=='menuBlock1')){ 
	   var style = getStyle(inputObj,'position'); 
	   if(style=='absolute' || style=='relative'){                
		  return returnValue;            
	   } 
	} 
	returnValue += inputObj.offsetTop;          
 } 
 return returnValue; 
} 

function getLeftPos(inputObj) 
{ 
 var returnValue = inputObj.offsetLeft; 
 var topOfMenuReached = false; 
 while((inputObj = inputObj.offsetParent) != null){ 
   if(inputObj.parentNode.id=='dhtmlgoodies_menu1')topOfMenuReached=true; 
	if(topOfMenuReached && !inputObj.className.match(/menuBlock/gi)){ 
	   var style = getStyle(inputObj,'position'); 
	   if(style=='absolute' || style=='relative')return returnValue; 
	} 
	returnValue += inputObj.offsetLeft; 
 } 
 return returnValue; 
} 

function showHideSub() 
{ 
  var attr = this.parentNode.getAttribute('currentDepth'); 
  if(navigator.userAgent.indexOf('Opera')>=0){ 
	 attr = this.parentNode.currentDepth; 
  } 
  this.className = 'currentDepth' + attr + 'over'; 
  if(activeMenuItem && activeMenuItem!=this){ 
	 activeMenuItem.className=activeMenuItem.className.replace(/over/,''); 
  } 
  activeMenuItem = this; 
  var numericIdThis = this.id.replace(/[^0-9]/g,''); 
  var exceptionArray = new Array(); 
  // Showing sub item of this LI 
  var sub = document.getElementById('subOf' + numericIdThis); 
  if(sub){ 
	 visibleMenus.push(sub); 
	 sub.style.display=''; 
	 sub.parentNode.className = sub.parentNode.className + 'over'; 
	 exceptionArray[sub.id] = true; 
  }    
  // Showing parent items of this one 
  var parent = this.parentNode; 
  while(parent && parent.id && parent.tagName=='UL'){ 
	 visibleMenus.push(parent); 
	 exceptionArray[parent.id] = true; 
	 parent.style.display=''; 
	 var li = document.getElementById('dhtmlgoodies_listItem' + parent.id.replace(/[^0-9]/g,'')); 
	 if(li.className.indexOf('over')<0)li.className = li.className + 'over'; 
	 parent = li.parentNode; 
  } 
  hideMenuItems(exceptionArray); 
} 

function hideMenuItems(exceptionArray) 
{ 
  /* 
  Hiding visible menu items 
  */ 
  var newVisibleMenuArray = new Array(); 
  for(var no=0;no<visibleMenus.length;no++){ 
	 if(visibleMenus[no].className!='menuBlock1' && visibleMenus[no].id){ 
		if(!exceptionArray[visibleMenus[no].id]){ 
		   var el = visibleMenus[no].getElementsByTagName('A')[0]; 
		   visibleMenus[no].style.display = 'none'; 
		   var li = document.getElementById('dhtmlgoodies_listItem' + visibleMenus[no].id.replace(/[^0-9]/g,'')); 
		   if(li.className.indexOf('over')>0)li.className = li.className.replace(/over/,''); 
		}else{              
		   newVisibleMenuArray.push(visibleMenus[no]); 
		} 
	 } 
  }        
  visibleMenus = newVisibleMenuArray;        
} 
var menuActive = true; 
var hideTimer = 0; 
function mouseOverMenu() 
{ 
  menuActive = true;        
} 

function mouseOutMenu() 
{ 
  menuActive = false; 
  timerAutoHide();    
} 

function timerAutoHide() 
{ 
  if(menuActive){ 
	 hideTimer = 0; 
	 return; 
  } 
  if(hideTimer<timeBeforeAutoHide){ 
	 hideTimer+=100; 
	 setTimeout('timerAutoHide()',99); 
  }else{ 
	 hideTimer = 0; 
	 autohideMenuItems();    
  } 
} 

function autohideMenuItems() 
{ 
  if(!menuActive){ 
	 hideMenuItems(new Array());    
	 if(activeMenuItem)activeMenuItem.className=activeMenuItem.className.replace(/over/,'');        
  } 
} 

function initSubMenus(inputObj,initOffsetLeft,currentDepth) 
{    
  var subUl = inputObj.getElementsByTagName('UL'); 
  if(subUl.length>0){ 
	 var ul = subUl[0]; 
	 ul.id = 'subOf' + inputObj.id.replace(/[^0-9]/g,''); 
	 ul.setAttribute('currentDepth' ,currentDepth); 
	 ul.currentDepth = currentDepth; 
	 ul.className='menuBlock' + currentDepth; 
	 ul.onmouseover = mouseOverMenu; 
	 ul.onmouseout = mouseOutMenu; 
	 currentZIndex+=1; 
	 ul.style.zIndex = currentZIndex; 
	 menuBlockArray.push(ul); 
	 ul = dhtmlgoodies_menu1Obj.appendChild(ul); 
	 var topPos = getTopPos(inputObj); 
	 var leftPos = getLeftPos(inputObj)/1 + initOffsetLeft/1;          
	 ul.style.position = 'absolute'; 
	 ul.style.left = leftPos + 'px'; 
	 ul.style.top = topPos + 'px'; 
	 var li = ul.getElementsByTagName('LI')[0]; 
	 while(li){ 
		if(li.tagName=='LI'){    
		   li.className='currentDepth' + currentDepth;                
		   li.id = 'dhtmlgoodies_listItem' + liIndex; 
		   liIndex++;              
		   var uls = li.getElementsByTagName('UL'); 
		   li.onmouseover = showHideSub; 
		   if(uls.length>0){ 
			  var offsetToFunction = li.getElementsByTagName('A')[0].offsetWidth+2; 
			  if(navigatorVersion<6 && MSIE)offsetToFunction+=15;   // MSIE 5.x fix 
			  initSubMenus(li,offsetToFunction,(currentDepth+1)); 
		   }    
		   if(MSIE){ 
			var a = li.getElementsByTagName('A')[0]; 
			  a.style.width=li.offsetWidth+'px'; 
			  a.style.display='block';
		   }                
		} 
		li = li.nextSibling; 
	 } 
	 ul.style.display = 'none';    
	 if(!document.all){ 
		//dhtmlgoodies_menu1Obj.appendChild(ul); 
	 } 
  }    
} 

function resizeMenu() 
{ 
  var offsetParent = getLeftPos(dhtmlgoodies_menu1Obj); 
	
  for(var no=0;no<menuBlockArray.length;no++){ 
	 var leftPos = menuBlockArray[no].style.left.replace('px','')/1; 
	 menuBlockArray[no].style.left = leftPos + offsetParent - menuParentOffsetLeft + 'px'; 
  } 
  menuParentOffsetLeft = offsetParent; 
} 
/* 
Initializing menu 
*/ 
function initDhtmlGoodiesMenu() 
{ 
  dhtmlgoodies_menu1Obj = document.getElementById('dhtmlgoodies_menu1'); 
  var aTags = dhtmlgoodies_menu1Obj.getElementsByTagName('A'); 
  for(var no=0;no<aTags.length;no++){          
	 var subUl = aTags[no].parentNode.getElementsByTagName('UL'); 
	 if(subUl.length>0 && aTags[no].parentNode.parentNode.parentNode.id != 'dhtmlgoodies_menu1'){ 
		/*var img = document.createElement('IMG'); 
		img.src = dhtmlgoodies_menu1_arrow; 
		aTags[no].appendChild(img);   */           
	 } 
  } 
  var mainMenu = dhtmlgoodies_menu1Obj.getElementsByTagName('UL')[0]; 
  mainMenu.className='menuBlock1'; 
  mainMenu.style.zIndex = currentZIndex; 
  mainMenu.setAttribute('currentDepth' ,1); 
  mainMenu.currentDepth = '1'; 
  mainMenu.onmouseover = mouseOverMenu; 
  mainMenu.onmouseout = mouseOutMenu;        
  var mainMenuItemsArray = new Array(); 
  var mainMenuItem = mainMenu.getElementsByTagName('LI')[0]; 
  mainMenu.style.height = mainMenuItem.offsetHeight + 2 + 'px'; 
  while(mainMenuItem){ 
	 mainMenuItem.className='currentDepth1'; 
	 mainMenuItem.id = 'dhtmlgoodies_listItem' + liIndex; 
	 mainMenuItem.onmouseover = showHideSub; 
	 liIndex++;              
	 if(mainMenuItem.tagName=='LI'){ 
		mainMenuItem.style.cssText = 'float:left;';    
		mainMenuItem.style.styleFloat = 'left'; 
		mainMenuItemsArray[mainMenuItemsArray.length] = mainMenuItem; 
		initSubMenus(mainMenuItem,0,2); 
	 }          
	 mainMenuItem = mainMenuItem.nextSibling; 
  } 
  for(var no=0;no<mainMenuItemsArray.length;no++){ 
	 initSubMenus(mainMenuItemsArray[no],0,2);          
  } 
  menuParentOffsetLeft = getLeftPos(dhtmlgoodies_menu1Obj);    
  window.onresize = resizeMenu;    
  dhtmlgoodies_menu1Obj.style.visibility = 'visible';    
}
////////////////////////// DropDown Script Ends Here //////////////////////////	






/* http://www.time4trip.in/lib/validation.js */

var today=new Date();
var todate=today.getDate();
var tomonth=today.getMonth();
var toyear=today.getFullYear();
var checkOK = "0123456789";

function isDate1(dt)
{
        var dtCh= "/";
        var daysInMonth = DaysArray(12)
  	var pos1=dt.indexOf(dtCh)
  	var pos2=dt.indexOf(dtCh,pos1+1)
  	var strMonth=dt.substring(0,pos1)
  	var strDay=dt.substring(pos1+1,pos2)
  	var strYear=dt.substring(pos2+1)
  	var strYr=strYear
  	if (strDay.charAt(0)=="0" && strDay.length>1) var strDay=strDay.substring(1)
  	if (strMonth.charAt(0)=="0" && strMonth.length>1) var strMonth=strMonth.substring(1)
  	for (var i = 1; i <= 3; i++) {
  		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
  	}
  	month=parseInt(strMonth)
  	day=parseInt(strDay)
  	year=parseInt(strYr)
  	if (strMonth.length<1 || month<1 || month>12){
  		alert("Please enter a valid month")
  		return false
  	}
  	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
  		alert("Please enter a valid day")
  		return false
  	}
  	return true    
}



function stripCharsInBag(s, bag)
{
        var i;
        var returnString = "";
        // Search through string's characters one by one.
        // If character is not in bag, append to returnString.
        for (i = 0; i < s.length; i++)
        {   
	    var c = s.charAt(i);
	    if (bag.indexOf(c) == -1) returnString += c;
        }
        return returnString;
}

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}




function myfunction()
{
	document.searchform.submit();
}

function CityCheck(indicator)
{

	   var iscity=false;
	   var city=document.searchform.strCity
	   for(i=0;i<indicator;i++)
	   {
		if(city[i].checked)
		{
		   iscity=true;
		}     
	   }
	   if(city[indicator].checked)
	   {

		 if(document.searchform.strOtherCity.value!="")
		 {
		    iscity=true;
		 }
	   }

	   if(iscity==false)
	   {
		   alert("Please enter City Name");
		   document.searchform.strOtherCity.focus();
		   return false;
	       }

	   else
	   {
		    myfunction()
	   } 
}


function DateCheck()
{
var j;
	if(document.searchform.strDestinationType[0].checked)
	{
		j=0;
	}
	
	if(document.searchform.strDestinationType[1].checked)
	{
		j=1;		
	}
	
	if(j==0)
	{
	        
	        document.searchform.strOtherCity.value=document.searchform.strOtherCity0.value;
	
		document.searchform.strCheckindate.value=document.searchform.strCheckindate0.value;
		document.searchform.strCheckinmonth.value=document.searchform.strCheckinmonth0.value;
		document.searchform.strCheckinyear.value=document.searchform.strCheckinyear0.value;
		
		document.searchform.strCheckoutdate.value=document.searchform.strCheckoutdate0.value;
		document.searchform.strCheckoutmonth.value=document.searchform.strCheckoutmonth0.value;
		document.searchform.strCheckoutyear.value=document.searchform.strCheckoutyear0.value;
				
		
	}
	
	if(j==1)
	{
		document.searchform.strOtherCity.value=document.searchform.strOtherCity1.value;
		
		document.searchform.strCheckindate.value=document.searchform.strCheckindate1.value;
		document.searchform.strCheckinmonth.value=document.searchform.strCheckinmonth1.value;
		document.searchform.strCheckinyear.value=document.searchform.strCheckinyear1.value;
	
		document.searchform.strCheckoutdate.value=document.searchform.strCheckoutdate1.value;
		document.searchform.strCheckoutmonth.value=document.searchform.strCheckoutmonth1.value;
		document.searchform.strCheckoutyear.value=document.searchform.strCheckoutyear1.value;
	}
	
		
	var iscity=false;
	var Checkindate=document.searchform.strCheckindate.value;
	
	var Checkinmonth=document.searchform.strCheckinmonth.value;
	Checkinmonth=Number(Checkinmonth);
	
	var Checkinyear=document.searchform.strCheckinyear.value;
	var Checkoutdate=document.searchform.strCheckoutdate.value;
	
	var Checkoutmonth=document.searchform.strCheckoutmonth.value;
	Checkoutmonth=Number(Checkoutmonth);
	
	var Checkoutyear=document.searchform.strCheckoutyear.value;
	var presentday=new Date(toyear,tomonth,todate);
	var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
	var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
	var city=document.searchform.strCity
	var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
	var diff=difference/1000/60/60/24;
	var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear

	  for(i=j*9;i<(8*(j+1))+j;i++)
	  {
	     if(city[i].checked)
	     {
		iscity=true;
	     }


	  }


	  if(city[(8*(j+1))+j].checked)
	  {

	      if(document.searchform.strOtherCity.value!="")
	      {
		 iscity=true;
	      }
	  }
		

	
	if(iscity==false)
	{
	alert("Please enter City Name");

		if(j==0)
		{
		document.searchform.strOtherCity0.focus();
		}
		if(j==1)
		{
		document.searchform.strOtherCity1.focus();
		}

	return false;
	}


	else if(isDate1(dt)==false)
	{
	return false;
	}
	else if(startdate<presentday)
	{
	alert(" CheckIn Date Should Be Higher Than Today's Date");
	return false;
	}
	else if(enddate < startdate)
	{
	alert(" End Date Should Be Higher Than  Start Date");
	return false;
	}

	else if(diff>30)
	{
	alert("Sorry You Cannot Do  Booking For More Than 30 Days");
	return false;
	}

	else
	{
		return true;
	} 
		
}


function Checkhotel(i)
{
    var Checkindate=document.forms[i].strCheckindate.value;
    var Checkinmonth=document.forms[i].strCheckinmonth.value;
    Checkinmonth=Number(Checkinmonth);
    var Checkinyear=document.forms[i].strCheckinyear.value;
    var Checkoutdate=document.forms[i].strCheckoutdate.value;
    var Checkoutmonth=document.forms[i].strCheckoutmonth.value;
    Checkoutmonth=Number(Checkoutmonth);
    var Checkoutyear=document.forms[i].strCheckoutyear.value;

    var presentday=new Date(toyear,tomonth,todate);
    var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
    var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
   
   
    var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
    var diff=difference/1000/60/60/24;
    var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear
    if(isDate1(dt)==false)
    {
           return false;
    }
    
    else if(startdate<presentday)
    {
       alert(" Check-In-Date Should Be Higher Than Current Date");
       return false;
    }
    else if(enddate < startdate)
    {
        alert(" Check-Out-Date Should Be Higher Than  Check-In-Date");
        return false;
    }
    
        else if(diff>30)
        {
              alert("Sorry You Cannot Do  Booking For More Than 30 Days");
              return false;
    }
  
  
    else
    {
         return true;
    } 
}


function othercity(i)
{
   document.searchform.strCity[(i*9)+8].checked=true;
}

function text(i)
{
   document.searchform.strOtherCity[i].focus();
}


function carothercity(i)
{
   document.carsearchform.strCarCity[(i*9)+8].checked=true;
}


function cartext(i)
{
   document.carsearchform.strCarOtherCity[i].focus();
}




function setCheckOutDate(i)
{

  var checkindate;
  var checkinmonth;
  var checkinyear;
  var checkout;
  
    if(i==0)
    {
    
	checkindate=document.searchform.strCheckindate0.value;
	checkinmonth=Number(document.searchform.strCheckinmonth0.value)-1;
	checkinyear=document.searchform.strCheckinyear0.value;
	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)

	document.searchform.strCheckoutdate0.value = checkout.getDate();
	document.searchform.strCheckoutmonth0.value = (checkout.getMonth()+1);
	document.searchform.strCheckoutyear0.value = checkout.getYear();
    }
    
    else if(i==1)
    {
    	checkindate=document.searchform.strCheckindate1.value;
    	checkinmonth=Number(document.searchform.strCheckinmonth1.value)-1;
    	checkinyear=document.searchform.strCheckinyear1.value;
    	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
    
    	document.searchform.strCheckoutdate1.value = checkout.getDate();
    	document.searchform.strCheckoutmonth1.value = (checkout.getMonth()+1);
    	document.searchform.strCheckoutyear1.value = checkout.getYear();
    }
    
    else 
    {
	checkindate=document.searchform.strCheckindate.value;
	checkinmonth=Number(document.searchform.strCheckinmonth.value)-1;
	checkinyear=document.searchform.strCheckinyear.value;
	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)

	document.searchform.strCheckoutdate.value = checkout.getDate();
	document.searchform.strCheckoutmonth.value = (checkout.getMonth()+1);
	document.searchform.strCheckoutyear.value = checkout.getYear();
    }
   
      
}

function setCheckOutDateFlight(i)
 {
      var checkindate;
        var checkinmonth;
        var checkinyear;
  var checkout;
      if(i==2)
      {
          	checkindate=document.flightsearchForm.departureDay0.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth0.value)-1;
          	checkinyear=now.getFullYear();
          	//checkinyear=document.flightsearchForm.strCheckinyear1.value;
          	
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay0.value = checkout.getDate();
          	document.flightsearchForm.returnMonth0.value = (checkout.getMonth()+1);
          	checkout=now.getFullYear();
          	//document.flightsearchForm.strCheckoutyear1.value = checkout.getYear();
      }
      if(i==3)
      {
          	checkindate=document.flightsearchForm.departureDay0.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth0.value)-1;
          	checkinyear=document.flightsearchForm.departureYear0.value;
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay0.value = checkout.getDate();
          	document.flightsearchForm.returnMonth0.value = (checkout.getMonth()+1);
          	document.flightsearchForm.returnYear0.value = checkout.getYear();
          } if(i==4)
          {
          	checkindate=document.flightsearchForm.departureDay1.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth1.value)-1;
          	checkinyear=now.getFullYear();
          	//checkinyear=document.flightsearchForm.strCheckinyear1.value;
          	
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay1.value = checkout.getDate();
          	document.flightsearchForm.returnMonth1.value = (checkout.getMonth()+1);
          	checkout=now.getFullYear();
          	//document.flightsearchForm.strCheckoutyear1.value = checkout.getYear();
          } if(i==5)
          {
          	checkindate=document.flightsearchForm.departureDay1.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth1.value)-1;
          	checkinyear=document.flightsearchForm.departureYear1.value;
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay1.value = checkout.getDate();
          	document.flightsearchForm.returnMonth1.value = (checkout.getMonth()+1);
          	document.flightsearchForm.returnYear1.value = checkout.getYear();
    }
 }


function setCheckOutDate1(i)
{
   var checkindate=document.searchform[i].strCheckindate.value;
   var checkinmonth=Number(document.searchform[i].strCheckinmonth.value)-1;
   var checkinyear=document.searchform[i].strCheckinyear.value;
   var checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
   document.searchform[i].strCheckoutdate.value = checkout.getDate();
   document.searchform[i].strCheckoutmonth.value = (checkout.getMonth()+1);
   document.searchform[i].strCheckoutyear.value = checkout.getYear();
   
}




function formsubmit(index,count)
{         
           if(indicator<1)
	   {
	       document.MoreInfoForm.submit();
	   }
	   else
	   {
	       document.MoreInfoForm[Number(index)].submit();
	   }
}

function formsubmitcity(index)
{
   if((document.MoreInfoForm.length)!=1)
   {
       document.MoreInfoForm[index].submit();
   }
   else
   {
       document.MoreInfoForm.submit();
   }
}


function CarDateCheck()
{
	  var j;
	  if(document.carsearchform.strHireType[0].checked)
	  {
	      j=0;
	     
	      if(document.carsearchform.strDays.value.length==0)
	      {
	          alert("Please Enter No. Of Days");
	          document.carsearchform.strDays.focus();
	          return false;
	      }
	     
	      else if(Number(document.carsearchform.strDays.value)>30)
	      {
	          alert("No. Of Days Should be less than 30 days");
	          document.carsearchform.strDays.focus();
	          return false;
	      }
	      else if(Number(document.carsearchform.strDays.value)==0)
	      {
		       alert("No. of days should not be zero");
		       document.carsearchform.strDays.focus();
		       return false;
              }
	     
	      
	      var check = document.carsearchform.strDays.value;
	      var allValid = true;
	      var allNum = "";
	      var l=0;
              for (i = 0;  i < check.length;  i++)
	      {
			ch = check.charAt(i);
			for (k = 0;  k < checkOK.length;  k++)
			if (ch == checkOK.charAt(k))
			break;
			if (k == checkOK.length)
			{
			    allValid = false;
				break;
			}
              }
	      if (!allValid)
	      {
			alert("Please enter only digit characters in the No. Of Days field.");
			return false;
	      }
		 
	  }
  
	  else if(document.carsearchform.strHireType[1].checked)
	  {
              if(document.carsearchform.airport[0].checked)
	      {
		  j=1;
		  if(document.carsearchform.strDropPoint.value.length==0)
		  {
		           alert("Please Enter Drop Point");
		           document.carsearchform.strDropPoint.focus();
		           return false;
		  }
              }
	      else if(document.carsearchform.airport[1].checked)
	      {
		  j=2;
		  if(document.carsearchform.strPickUpPoint.value.length==0)
		  {
		            alert("Please Enter PickUp Point");
		            document.carsearchform.strPickUpPoint.focus();
		            return false;
		  }
	      }
          }
       
	  if(j==0)
	  {
	   	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity0.value;
	   	document.carsearchform.strPeople.value=document.carsearchform.strPeople0.value;
	   	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate0.value;
	   	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth0.value;
	   	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear0.value;
	   	
	   	
	  }
	 
	  if(j==1)
	  {
	     	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity1.value;
	     	document.carsearchform.strPeople.value=document.carsearchform.strPeople1.value;
	     	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate1.value;
	     	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth1.value;
	     	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear1.value;
	     	document.carsearchform.strFlightDetail1.value=document.carsearchform.strFlightDetail11.value;
	     	document.carsearchform.strFlightDetail2.value=document.carsearchform.strFlightDetail21.value;
	     	if(document.carsearchform.strFlightDetail1.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail11.focus();
		     return false;
	    	}

	        else if(document.carsearchform.strFlightDetail2.value.length==0)
	        { 
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail21.focus();
		     return false;
	        }
	     
	  }
	  if(j==2)
	  {
	     	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity2.value;
	     	document.carsearchform.strPeople.value=document.carsearchform.strPeople2.value;
	     	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate2.value;
	     	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth2.value;
	     	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear2.value;
	     	document.carsearchform.strFlightDetail1.value=document.carsearchform.strFlightDetail12.value;
	     	document.carsearchform.strFlightDetail2.value=document.carsearchform.strFlightDetail22.value;
	     	if(document.carsearchform.strFlightDetail1.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail12.focus();
		     return false;
	     	}
		else if(document.carsearchform.strFlightDetail2.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail22.focus();
		     return false;
	   	}
	     
	  }
	  var iscity=false;
	  var Checkindate=document.carsearchform.strCheckindate.value;
	  var Checkinmonth=document.carsearchform.strCheckinmonth.value;
	  Checkinmonth=Number(Checkinmonth);
	  var Checkinyear=document.carsearchform.strCheckinyear.value;
	  var presentday=new Date(toyear,tomonth,todate+2);
	  var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear  
	  
	  var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
	  var city=document.carsearchform.strCarCity
	 
	  for(i=j*9;i<(8*(j+1))+j;i++)
	  {
	     if(city[i].checked)
	     {
	        iscity=true;
	     }
	     
	       
	  }
  
    
	  if(city[(8*(j+1))+j].checked)
	  {
	      
	      if(document.carsearchform.strCarOtherCity.value!="")
	      {
	         iscity=true;
	      }
	  }
	  if(iscity==false)
	    {
	        alert("Please enter City Name");
	        return false;
	  }
	  else if(isDate1(dt)==false)
	  {
	         return false;
          }
	  
	  else if(startdate<presentday)
	  {
	     alert(" Bookin Time Should Be 48 Hour Before Renting Time");
	     return false;
	  }
	  
	  
	  else if(document.carsearchform.strPeople.value.length==0)
	  {
	    alert("Please Enter No. Of People");
	    
	    return false;
	  }
	  
	  
	  var check = document.carsearchform.strPeople.value;
	  
	  allValid = true;
	  var allNum = "";
	  var l=0;
          for (i = 0;  i < check.length;  i++)
	  {
	    	ch = check.charAt(i);
			for (l = 0;  l < checkOK.length;  l++)
			if (ch == checkOK.charAt(l))
			break;
			if (l == checkOK.length)
			{
			    allValid = false;
				break;
			}
          }
          if (!allValid)
	  {
		alert("Please enter only digit characters in the No. Of People field.");
		return false;
	  }
  
	  
	  else
	  {
	     return true;
	  } 
}

function Checkcarrental()
{
  	  var Checkindate=document.carsearchform.strCheckindate.value;
  	  var Checkinmonth=document.carsearchform.strCheckinmonth.value;
  	  Checkinmonth=Number(Checkinmonth);
  	  var Checkinyear=document.carsearchform.strCheckinyear.value;
	  var presentday=new Date(toyear,tomonth,todate+2);
  	  var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
  	  var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear 
  
	  if(startdate<presentday)
	  {
	     alert(" Bookin Time  Should Be AtLeast 48 hour from Renting Time");
	     return false;
	  }

	  else if(document.carsearchform.strDays.value.length==0)
	  {
		 alert("Please Enter No. Of Days");
		 document.carsearchform.strDays.focus();
		 return false;
	  }

	  else if(Number(document.carsearchform.strDays.value)>30)
	  {
		alert("No. Of Days Should be less than 30 days");
		document.carsearchform.strDays.focus();
		return false;
	  }

	  else if(document.carsearchform.strPeople.value.length==0)
	  {
	    alert("Please Enter No. Of People");
	    document.carsearchform.strPeople.focus();
	    return false;
	  } 

	  else if(isDate1(dt)==false)
	  {
		 return false;
	  }
  

	  var checkday = document.carsearchform.strDays.value;
	  var allValidday = true;
	  for (i = 0;  i < checkday.length;  i++)
	  {
		ch = checkday.charAt(i);
		for (k = 0;  k < checkOK.length;  k++)
		if (ch == checkOK.charAt(k))
		break;
		if (k == checkOK.length)
		{
		    allValidday = false;
			break;
		}
	  }
	  if (!allValidday)
	  {
		alert("Please enter only digit characters in the No. Of Days field.");
		return false;
	  }
  
	  var checkpeople= document.carsearchform.strPeople.value;
	  allValidpeople = true;
	  for (i = 0;  i < checkpeople.length;  i++)
	  {
		ch = checkpeople.charAt(i);
		for (l = 0;  l < checkOK.length;  l++)
		if (ch == checkOK.charAt(l))
		break;
		if (l == checkOK.length)
		{
			allValidpeople = false;
			break;
		}
	  }
          if (!allValidpeople)
	  {
		alert("Please enter only digit characters in the No. Of People field.");
		return false;
	  }

	  else
	  {
	     return true;
	  } 
}




function switchImg(what,newImg)
{ 
	if (document.images)
	{	
		document.images[what].src = eval(newImg + ".src");
	}
}
/*if (document.images) 
{
	var img1On = new Image(); img1On.src = "images/india_1on.gif";
	var img1Off = new Image(); img1Off.src = "images/india_1off.gif";
	var img2On = new Image(); img2On.src = "images/india_2on.gif";
	var img2Off = new Image(); img2Off.src = "images/india_2off.gif";
	var img3On = new Image(); img3On.src = "images/india_3on.gif";
	var img3Off = new Image(); img3Off.src = "images/india_3off.gif";
	var img4On = new Image(); img4On.src = "images/india_4on.gif";
	var img4Off = new Image(); img4Off.src = "images/india_4off.gif";
	var img5On = new Image(); img5On.src = "images/india_5on.gif";
	var img5Off = new Image(); img5Off.src = "images/india_5off.gif";
	var img6On = new Image(); img6On.src = "images/india_6on.gif";
	var img6Off = new Image(); img6Off.src = "images/india_6off.gif";
	var img7On = new Image(); img7On.src = "images/india_7on.gif";
	var img7Off = new Image(); img7Off.src = "images/india_7off.gif";
	var img8On = new Image(); img8On.src = "images/india_8on.gif";
	var img8Off = new Image(); img8Off.src = "images/india_8off.gif";
}*/

function checkSelectPage(indicator)
{

	if(toyear<1900)
        {
      		toyear=toyear+1900;
        }
    	var reportingpoint = document.carBookingForm.arrReportingPoint
   	var date=document.carBookingForm.arrDD;
    	var month=document.carBookingForm.arrMM;
    	var year=document.carBookingForm.arrYY;
    	var presentday=new Date(toyear,tomonth,todate);
        if(indicator==1)
    	{
         	year1=year.value;
         	if(year1<1900)
      		{
      			year1=Number(year.value)+1900;
       		}
         	var startdate=new Date(year1,(month.value)-1,date.value);
         	if(startdate<presentday)
      		{ 
           		alert("Date should be greater than today's date");
           		date.focus();
           		return false;
      		}   
        	if(reportingpoint.value.length==0)
      		{
        		alert("Please enter reporting point");
        		reportingpoint.focus();
        		return false;
      		}
        }
    
    	else
    	{
         	for(i=0;i<indicator;i++)
      		{ 
     			if(reportingpoint[i].value.length==0)
      			{
        			alert("Please enter reporting point");
        			reportingpoint[i].focus();
        			return false;
      			}
     		}
     
     		if(indicator==2)
     		{
        		var firstday=new Date(year[0].value,(month[0].value)-1,date[0].value);
        		var secondday=new Date(year[1].value,(month[1].value)-1,date[1].value);
        		var finalday=new Date(year[0].value,(month[0].value)-1,Number(date[0].value)+30);
        		if(firstday<presentday)
        		{
          			alert("Date should be greater than today's date");
          			date[0].focus();
          			return false;
        		}
			if(firstday>secondday)
			{
			       alert("Date should be greater than previous date");
			    	date[1].focus();
			    	return false;
			}
			if(secondday>finalday)
			{
			    alert("Renting date should not be more than 30 days from First renting date");
			    date[1].focus();
			    return false;
			}
        
     		}
    		else if(indicator>2)
    		{
        		var firstday=new Date(year[0].value,(month[0].value)-1,date[0].value);
			var secondday=new Date(year[1].value,(month[1].value)-1,date[1].value);
			var lastdate=new Date(year[indicator-1].value,(month[indicator-1].value)-1,date[indicator-1].value);
			var secondlastdate=new Date(year[indicator-2].value,(month[indicator-2].value)-1,date[indicator-2].value);
			var finalday=new Date(year[0].value,(month[0].value)-1,Number(date[0].value)+30);

			if(firstday<presentday)
			{
			  alert("Date should be greater than today's date");
			  date[0].focus();
			  return false;
			}
			if(firstday>secondday)
			{
			    alert("Date should be less than next date");
			    date[0].focus();
			    return false;
			}
			if(lastdate<secondlastdate)
			{
			       alert("Date should be greater than previous date");
			    date[indicator-1].focus();
			    return false;
			}
			if(lastdate>finalday)
			{
			    alert("Renting date should not be more than 30 days from First Renting Date");
			    date[indicator-1].focus();
			    return false;
			}
     			for(i=1;i<indicator-1;i++)
      			{
          			var enddate=new Date(year[i+1].value,(month[i+1].value)-1,date[i+1].value);
          			var startdate=new Date(year[i].value,(month[i].value)-1,date[i].value);
          			var previousdate=new Date(year[i-1].value,(month[i-1].value)-1,date[i-1].value);
          			if(startdate>enddate)
          			{
            				alert("Date should be in-between previous date and next date");
           				 date[i+1].focus();
            				return false;
          			}
          			if(startdate<previousdate)
            			{
                			alert("Date should be in-between previous date and next date");
                			date[i].focus();
             				return false; 
         			}
         			if(startdate<presentday)
				{
				    alert("Date should be greater than today's date");
				    date[i].focus();
				    return false;
				}  
         			if(enddate>finalday)
            			{
             				alert("Renting date should not be more than 30 days from First renting date");
             				date[i+1].focus();
             				return false;
            			} 
            		}
    		}
         
   	}
   	return true;
}

function carothercity(i)
{
   document.carsearchform.strCarCity[(i*9)+8].checked=true;
}


function cartext(i)
{
   document.carsearchform.strCarOtherCity[i].focus();
}


function isInteger(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 false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function desiyaIndiaDate(i)

{
    var startdate=new Date(toyear,tomonth,todate+1);
    var enddate=new Date(toyear,tomonth,todate+2);
    
    for(var j=0;j<i;j++)
    {
    	document.searchform[j].strCheckindate.value = startdate.getDate();
    	document.searchform[j].strCheckinmonth.value = startdate.getMonth()+1;
    	document.searchform[j].strCheckinyear.value = startdate.getFullYear();
    
    	document.searchform[j].strCheckoutdate.value = enddate.getDate();
    	document.searchform[j].strCheckoutmonth.value = enddate.getMonth()+1;
    	document.searchform[j].strCheckoutyear.value = enddate.getFullYear();
   }
}

function CarCityCheck(indicator)
{
   
   var iscity=false;
   var city=document.carsearchform.strCarCity
   for(i=0;i<indicator;i++)
   {
        if(city[i].checked)
        {
           iscity=true;
        }     
   }
   if(city[indicator].checked)
   {
         
         if(document.carsearchform.strCarOtherCity.value!="")
         {
            iscity=true;
         }
   }
   if(iscity==false)
   {
           alert("Please enter City Name");
           document.carsearchform.strCarOtherCity.focus();
           return false;
   }
       
   else
   {
            document.carsearchform.submit();
   } 
}






  
/* http://www.time4trip.in/lib/CalendarPopup.js */
// Temporary, to stop linking directly to the js file
// Remove these lines before using this code (this will be removed soon)
if (window.location.href.indexOf("spiralsolutions")>-1) { alert("Please stop linking directly to the JS file on mattkruse.com! Please copy the JS files to your server instead!"); window.location.href="http://www.mattkruse.com/"; }

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================


/* SOURCE FILE: AnchorPosition.js */

/* 
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition. 
   Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.
*/ 

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}

/* SOURCE FILE: date.js */

// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
//                 perfectly with SimpleDateFormat formats, but 
//                 backwards-compatability was required.

// ------------------------------------------------------------------
// These functions use the same 'format' strings as the 
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
// 
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
//  "MMM d, y" matches: January 01, 2000
//                      Dec 1, 1900
//                      Nov 20, 00
//  "M/d/yy"   matches: 01/20/00
//                      9/2/00
//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}

/* SOURCE FILE: PopupWindow.js */

/* 
PopupWindow.js
Author: Matt Kruse
Last modified: 02/16/04

DESCRIPTION: This object allows you to easily and quickly popup a window
in a certain place. The window can either be a DIV or a separate browser
window.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 
window with <STYLE> tags may cause errors.

USAGE:
// Create an object for a WINDOW popup
var win = new PopupWindow(); 

// Create an object for a DIV window using the DIV named 'mydiv'
var win = new PopupWindow('mydiv'); 

// Set the window to automatically hide itself when the user clicks 
// anywhere else on the page except the popup
win.autoHide(); 

// Show the window relative to the anchor name passed in
win.showPopup(anchorname);

// Hide the popup
win.hidePopup();

// Set the size of the popup window (only applies to WINDOW popups
win.setSize(width,height);

// Populate the contents of the popup window that will be shown. If you 
// change the contents while it is displayed, you will need to refresh()
win.populate(string);

// set the URL of the window, rather than populating its contents
// manually
win.setUrl("http://www.site.com/");

// Refresh the contents of the popup
win.refresh();

// Specify how many pixels to the right of the anchor the popup will appear
win.offsetX = 50;

// Specify how many pixels below the anchor the popup will appear
win.offsetY = 100;

NOTES:
1) Requires the functions in AnchorPosition.js

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.

4) When a PopupWindow object is created, a handler for 'onmouseup' is
   attached to any event handler you may have already defined. Do NOT define
   an event handler for 'onmouseup' after you define a PopupWindow object or
   the autoHide() will not work correctly.
*/ 

// Set the position of the popup window based on the anchor
function PopupWindow_getXYPosition(anchorname) {
	var coordinates;
	if (this.type == "WINDOW") {
		coordinates = getAnchorWindowPosition(anchorname);
		}
	else {
		coordinates = getAnchorPosition(anchorname);
		}
	this.x = coordinates.x;
	this.y = coordinates.y;
	}
// Set width/height of DIV/popup window
function PopupWindow_setSize(width,height) {
	this.width = width;
	this.height = height;
	}
// Fill the window with contents
function PopupWindow_populate(contents) {
	this.contents = contents;
	this.populated = false;
	}
// Set the URL to go to
function PopupWindow_setUrl(url) {
	this.url = url;
	}
// Set the window popup properties
function PopupWindow_setWindowProperties(props) {
	this.windowProperties = props;
	}
// Refresh the displayed contents of the popup
function PopupWindow_refresh() {
	if (this.divName != null) {
		// refresh the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).innerHTML = this.contents;
			}
		else if (this.use_css) { 
			document.all[this.divName].innerHTML = this.contents;
			}
		else if (this.use_layers) { 
			var d = document.layers[this.divName]; 
			d.document.open();
			d.document.writeln(this.contents);
			d.document.close();
			}
		}
	else {
		if (this.popupWindow != null && !this.popupWindow.closed) {
			if (this.url!="") {
				this.popupWindow.location.href=this.url;
				}
			else {
				this.popupWindow.document.open();
				this.popupWindow.document.writeln(this.contents);
				this.popupWindow.document.close();
			}
			this.popupWindow.focus();
			}
		}
	}
// Position and show the popup, relative to an anchor object
function PopupWindow_showPopup(anchorname) {
	this.getXYPosition(anchorname);
	this.x += this.offsetX;
	this.y += this.offsetY;
	if (!this.populated && (this.contents != "")) {
		this.populated = true;
		this.refresh();
		}
	if (this.divName != null) {
		// Show the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).style.left = this.x + "px";
			document.getElementById(this.divName).style.top = this.y + "px";
			document.getElementById(this.divName).style.visibility = "visible";
			}
		else if (this.use_css) {
			document.all[this.divName].style.left = this.x;
			document.all[this.divName].style.top = this.y;
			document.all[this.divName].style.visibility = "visible";
			}
		else if (this.use_layers) {
			document.layers[this.divName].left = this.x;
			document.layers[this.divName].top = this.y;
			document.layers[this.divName].visibility = "visible";
			}
		}
	else {
		if (this.popupWindow == null || this.popupWindow.closed) {
			// If the popup window will go off-screen, move it so it doesn't
			if (this.x<0) { this.x=0; }
			if (this.y<0) { this.y=0; }
			if (screen && screen.availHeight) {
				if ((this.y + this.height) > screen.availHeight) {
					this.y = screen.availHeight - this.height;
					}
				}
			if (screen && screen.availWidth) {
				if ((this.x + this.width) > screen.availWidth) {
					this.x = screen.availWidth - this.width;
					}
				}
			var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
			this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
			}
		this.refresh();
		}
	}
// Hide the popup
function PopupWindow_hidePopup() {
	if (this.divName != null) {
		if (this.use_gebi) {
			document.getElementById(this.divName).style.visibility = "hidden";
			}
		else if (this.use_css) {
			document.all[this.divName].style.visibility = "hidden";
			}
		else if (this.use_layers) {
			document.layers[this.divName].visibility = "hidden";
			}
		}
	else {
		if (this.popupWindow && !this.popupWindow.closed) {
			this.popupWindow.close();
			this.popupWindow = null;
			}
		}
	}
// Pass an event and return whether or not it was the popup DIV that was clicked
function PopupWindow_isClicked(e) {
	if (this.divName != null) {
		if (this.use_layers) {
			var clickX = e.pageX;
			var clickY = e.pageY;
			var t = document.layers[this.divName];
			if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
				return true;
				}
			else { return false; }
			}
		else if (document.all) { // Need to hard-code this to trap IE for error-handling
			var t = window.event.srcElement;
			while (t.parentElement != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentElement;
				}
			return false;
			}
		else if (this.use_gebi && e) {
			var t = e.originalTarget;
			while (t.parentNode != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentNode;
				}
			return false;
			}
		return false;
		}
	return false;
	}

// Check an onMouseDown event to see if we should hide
function PopupWindow_hideIfNotClicked(e) {
	if (this.autoHideEnabled && !this.isClicked(e)) {
		this.hidePopup();
		}
	}
// Call this to make the DIV disable automatically when mouse is clicked outside it
function PopupWindow_autoHide() {
	this.autoHideEnabled = true;
	}
// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
function PopupWindow_hidePopupWindows(e) {
	for (var i=0; i<popupWindowObjects.length; i++) {
		if (popupWindowObjects[i] != null) {
			var p = popupWindowObjects[i];
			p.hideIfNotClicked(e);
			}
		}
	}
// Run this immediately to attach the event listener
function PopupWindow_attachListener() {
	if (document.layers) {
		document.captureEvents(Event.MOUSEUP);
		}
	window.popupWindowOldEventListener = document.onmouseup;
	if (window.popupWindowOldEventListener != null) {
		document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
		}
	else {
		document.onmouseup = PopupWindow_hidePopupWindows;
		}
	}
// CONSTRUCTOR for the PopupWindow object
// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
function PopupWindow() {
	if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
	if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
	if (!window.listenerAttached) {
		window.listenerAttached = true;
		PopupWindow_attachListener();
		}
	this.index = popupWindowIndex++;
	popupWindowObjects[this.index] = this;
	this.divName = null;
	this.popupWindow = null;
	this.width=0;
	this.height=0;
	this.populated = false;
	this.visible = false;
	this.autoHideEnabled = false;
	
	this.contents = "";
	this.url="";
	this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
	if (arguments.length>0) {
		this.type="DIV";
		this.divName = arguments[0];
		}
	else {
		this.type="WINDOW";
		}
	this.use_gebi = false;
	this.use_css = false;
	this.use_layers = false;
	if (document.getElementById) { this.use_gebi = true; }
	else if (document.all) { this.use_css = true; }
	else if (document.layers) { this.use_layers = true; }
	else { this.type = "WINDOW"; }
	this.offsetX = 0;
	this.offsetY = 0;
	// Method mappings
	this.getXYPosition = PopupWindow_getXYPosition;
	this.populate = PopupWindow_populate;
	this.setUrl = PopupWindow_setUrl;
	this.setWindowProperties = PopupWindow_setWindowProperties;
	this.refresh = PopupWindow_refresh;
	this.showPopup = PopupWindow_showPopup;
	this.hidePopup = PopupWindow_hidePopup;
	this.setSize = PopupWindow_setSize;
	this.isClicked = PopupWindow_isClicked;
	this.autoHide = PopupWindow_autoHide;
	this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
	}

/* SOURCE FILE: lib/CalendarPopup.js */

// HISTORY
// ------------------------------------------------------------------
// March 29, 2004: Added check in select() method for the form field
//      being disabled. If it is, just return and don't do anything.
// March 24, 2004: Fixed bug - when month name and abbreviations were
//      changed, date format still used original values.
// January 26, 2004: Added support for drop-down month and year
//      navigation (Thanks to Chris Reid for the idea)
// September 22, 2003: Fixed a minor problem in YEAR calendar with
//      CSS prefix.
// August 19, 2003: Renamed the function to get styles, and made it
//      work correctly without an object reference
// August 18, 2003: Changed showYearNavigation and 
//      showYearNavigationInput to optionally take an argument of
//      true or false
// July 31, 2003: Added text input option for year navigation.
//      Added a per-calendar CSS prefix option to optionally use 
//      different styles for different calendars.
// July 29, 2003: Fixed bug causing the Today link to be clickable 
//      even though today falls in a disabled date range.
//      Changed formatting to use pure CSS, allowing greater control
//      over look-and-feel options.
// June 11, 2003: Fixed bug causing the Today link to be unselectable
//      under certain cases when some days of week are disabled
// March 14, 2003: Added ability to disable individual dates or date
//      ranges, display as light gray and strike-through
// March 14, 2003: Removed dependency on graypixel.gif and instead 
///     use table border coloring
// March 12, 2003: Modified showCalendar() function to allow optional
//      start-date parameter
// March 11, 2003: Modified select() function to allow optional
//      start-date parameter
/* 
DESCRIPTION: This object implements a popup calendar to allow the user to
select a date, month, quarter, or year.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.
The calendar can be modified to work for any location in the world by 
changing which weekday is displayed as the first column, changing the month
names, and changing the column headers for each day.

USAGE:
// Create a new CalendarPopup object of type WINDOW
var cal = new CalendarPopup(); 

// Create a new CalendarPopup object of type DIV using the DIV named 'mydiv'
var cal = new CalendarPopup('mydiv'); 

// Easy method to link the popup calendar with an input box. 
cal.select(inputObject, anchorname, dateFormat);
// Same method, but passing a default date other than the field's current value
cal.select(inputObject, anchorname, dateFormat, '01/02/2000');
// This is an example call to the popup calendar from a link to populate an 
// input box. Note that to use this, date.js must also be included!!
<A HREF="#" onClick="cal.select(document.forms[0].date,'anchorname','MM/dd/yyyy'); return false;">Select</A>

// Set the type of date select to be used. By default it is 'date'.
cal.setDisplayType(type);

// When a date, month, quarter, or year is clicked, a function is called and
// passed the details. You must write this function, and tell the calendar
// popup what the function name is.
// Function to be called for 'date' select receives y, m, d
cal.setReturnFunction(functionname);
// Function to be called for 'month' select receives y, m
cal.setReturnMonthFunction(functionname);
// Function to be called for 'quarter' select receives y, q
cal.setReturnQuarterFunction(functionname);
// Function to be called for 'year' select receives y
cal.setReturnYearFunction(functionname);

// Show the calendar relative to a given anchor
cal.showCalendar(anchorname);

// Hide the calendar. The calendar is set to autoHide automatically
cal.hideCalendar();

// Set the month names to be used. Default are English month names
cal.setMonthNames("January","February","March",...);

// Set the month abbreviations to be used. Default are English month abbreviations
cal.setMonthAbbreviations("Jan","Feb","Mar",...);

// Show navigation for changing by the year, not just one month at a time
cal.showYearNavigation();

// Show month and year dropdowns, for quicker selection of month of dates
cal.showNavigationDropdowns();

// Set the text to be used above each day column. The days start with 
// sunday regardless of the value of WeekStartDay
cal.setDayHeaders("S","M","T",...);

// Set the day for the first column in the calendar grid. By default this
// is Sunday (0) but it may be changed to fit the conventions of other
// countries.
cal.setWeekStartDay(1); // week is Monday - Saturday

// Set the weekdays which should be disabled in the 'date' select popup. You can
// then allow someone to only select week end dates, or Tuedays, for example
cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week

// Selectively disable individual days or date ranges. Disabled days will not
// be clickable, and show as strike-through text on current browsers.
// Date format is any format recognized by parseDate() in date.js
// Pass a single date to disable:
cal.addDisabledDates("2003-01-01");
// Pass null as the first parameter to mean "anything up to and including" the
// passed date:
cal.addDisabledDates(null, "01/02/03");
// Pass null as the second parameter to mean "including the passed date and
// anything after it:
cal.addDisabledDates("Jan 01, 2003", null);
// Pass two dates to disable all dates inbetween and including the two
cal.addDisabledDates("January 01, 2003", "Dec 31, 2003");

// When the 'year' select is displayed, set the number of years back from the 
// current year to start listing years. Default is 2.
// This is also used for year drop-down, to decide how many years +/- to display
cal.setYearSelectStartOffset(2);

// Text for the word "Today" appearing on the calendar
cal.setTodayText("Today");

// The calendar uses CSS classes for formatting. If you want your calendar to
// have unique styles, you can set the prefix that will be added to all the
// classes in the output.
// For example, normal output may have this:
//     <SPAN CLASS="cpTodayTextDisabled">Today<SPAN>
// But if you set the prefix like this:
cal.setCssPrefix("Test");
// The output will then look like:
//     <SPAN CLASS="TestcpTodayTextDisabled">Today<SPAN>
// And you can define that style somewhere in your page.

// When using Year navigation, you can make the year be an input box, so
// the user can manually change it and jump to any year
cal.showYearNavigationInput();

// Set the calendar offset to be different than the default. By default it
// will appear just below and to the right of the anchorname. So if you have
// a text box where the date will go and and anchor immediately after the
// text box, the calendar will display immediately under the text box.
cal.offsetX = 20;
cal.offsetY = 20;

NOTES:
1) Requires the functions in AnchorPosition.js and PopupWindow.js

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.

4) When a CalendarPopup object is created, a handler for 'onmouseup' is
   attached to any event handler you may have already defined. Do NOT define
   an event handler for 'onmouseup' after you define a CalendarPopup object 
   or the autoHide() will not work correctly.
   
5) The calendar popup display uses style sheets to make it look nice.

*/ 

// CONSTRUCTOR for the CalendarPopup Object
function CalendarPopup() {
	var c;
	if (arguments.length>0) {
		c = new PopupWindow(arguments[0]);
		}
	else {
		c = new PopupWindow();
		c.setSize(150,175);
		}
	c.offsetX = -152;
	c.offsetY = 25;
	c.autoHide();
	// Calendar-specific properties
	c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	c.dayHeaders = new Array("S","M","T","W","T","F","S");
	c.returnFunction = "CP_tmpReturnFunction";
	c.returnMonthFunction = "CP_tmpReturnMonthFunction";
	c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";
	c.returnYearFunction = "CP_tmpReturnYearFunction";
	c.weekStartDay = 0;
	c.isShowYearNavigation = false;
	c.displayType = "date";
	c.disabledWeekDays = new Object();
	c.disabledDatesExpression = "";
	c.yearSelectStartOffset = 2;
	c.currentDate = null;
	c.todayText="Today";
	c.cssPrefix="";
	c.isShowNavigationDropdowns=false;
	c.isShowYearNavigationInput=false;
	window.CP_calendarObject = null;
	window.CP_targetInput = null;
	window.CP_dateFormat = "MM/dd/yyyy";
	// Method mappings
	c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;
	c.setReturnFunction = CP_setReturnFunction;
	c.setReturnMonthFunction = CP_setReturnMonthFunction;
	c.setReturnQuarterFunction = CP_setReturnQuarterFunction;
	c.setReturnYearFunction = CP_setReturnYearFunction;
	c.setMonthNames = CP_setMonthNames;
	c.setMonthAbbreviations = CP_setMonthAbbreviations;
	c.setDayHeaders = CP_setDayHeaders;
	c.setWeekStartDay = CP_setWeekStartDay;
	c.setDisplayType = CP_setDisplayType;
	c.setDisabledWeekDays = CP_setDisabledWeekDays;
	c.addDisabledDates = CP_addDisabledDates;
	c.setYearSelectStartOffset = CP_setYearSelectStartOffset;
	c.setTodayText = CP_setTodayText;
	c.showYearNavigation = CP_showYearNavigation;
	c.showCalendar = CP_showCalendar;
	c.hideCalendar = CP_hideCalendar;
	c.getStyles = getCalendarStyles;
	c.refreshCalendar = CP_refreshCalendar;
	c.getCalendar = CP_getCalendar;
	c.select = CP_select;
	c.setCssPrefix = CP_setCssPrefix;
	c.showNavigationDropdowns = CP_showNavigationDropdowns;
	c.showYearNavigationInput = CP_showYearNavigationInput;
	c.copyMonthNamesToWindow();
	// Return the object
	return c;
	}
function CP_copyMonthNamesToWindow() {
	// Copy these values over to the date.js 
	if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) {
		window.MONTH_NAMES = new Array();
		for (var i=0; i<this.monthNames.length; i++) {
			window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i];
		}
		for (var i=0; i<this.monthAbbreviations.length; i++) {
			window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i];
		}
	}
}
// Temporary default functions to be called when items clicked, so no error is thrown
function CP_tmpReturnFunction(y,m,d) { 
	if (window.CP_targetInput!=null) {
		var dt = new Date(y,m-1,d,0,0,0);
		if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); }
		window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);
		}
	else {
		alert('Use setReturnFunction() to define which function will get the clicked results!'); 
		}
	}
function CP_tmpReturnMonthFunction(y,m) { 
	alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); 
	}
function CP_tmpReturnQuarterFunction(y,q) { 
	alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); 
	}
function CP_tmpReturnYearFunction(y) { 
	alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); 
	}

// Set the name of the functions to call to get the clicked item
function CP_setReturnFunction(name) { this.returnFunction = name; }
function CP_setReturnMonthFunction(name) { this.returnMonthFunction = name; }
function CP_setReturnQuarterFunction(name) { this.returnQuarterFunction = name; }
function CP_setReturnYearFunction(name) { this.returnYearFunction = name; }

// Over-ride the built-in month names
function CP_setMonthNames() {
	for (var i=0; i<arguments.length; i++) { this.monthNames[i] = arguments[i]; }
	this.copyMonthNamesToWindow();
	}

// Over-ride the built-in month abbreviations
function CP_setMonthAbbreviations() {
	for (var i=0; i<arguments.length; i++) { this.monthAbbreviations[i] = arguments[i]; }
	this.copyMonthNamesToWindow();
	}

// Over-ride the built-in column headers for each day
function CP_setDayHeaders() {
	for (var i=0; i<arguments.length; i++) { this.dayHeaders[i] = arguments[i]; }
	}

// Set the day of the week (0-7) that the calendar display starts on
// This is for countries other than the US whose calendar displays start on Monday(1), for example
function CP_setWeekStartDay(day) { this.weekStartDay = day; }

// Show next/last year navigation links
function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true; }

// Which type of calendar to display
function CP_setDisplayType(type) {
	if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year") { alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false; }
	this.displayType=type;
	}

// How many years back to start by default for year display
function CP_setYearSelectStartOffset(num) { this.yearSelectStartOffset=num; }

// Set which weekdays should not be clickable
function CP_setDisabledWeekDays() {
	this.disabledWeekDays = new Object();
	for (var i=0; i<arguments.length; i++) { this.disabledWeekDays[arguments[i]] = true; }
	}
	
// Disable individual dates or ranges
// Builds an internal logical test which is run via eval() for efficiency
function CP_addDisabledDates(start, end) {
	if (arguments.length==1) { end=start; }
	if (start==null && end==null) { return; }
	if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; }
	if (start!=null) { start = parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}
	if (end!=null) { end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}
	if (start==null) { this.disabledDatesExpression+="(ds<="+end+")"; }
	else if (end  ==null) { this.disabledDatesExpression+="(ds>="+start+")"; }
	else { this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")"; }
	}
	
// Set the text to use for the "Today" link
function CP_setTodayText(text) {
	this.todayText = text;
	}

// Set the prefix to be added to all CSS classes when writing output
function CP_setCssPrefix(val) { 
	this.cssPrefix = val; 
	}

// Show the navigation as an dropdowns that can be manually changed
function CP_showNavigationDropdowns() { this.isShowNavigationDropdowns = (arguments.length>0)?arguments[0]:true; }

// Show the year navigation as an input box that can be manually changed
function CP_showYearNavigationInput() { this.isShowYearNavigationInput = (arguments.length>0)?arguments[0]:true; }

// Hide a calendar object
function CP_hideCalendar() {
	if (arguments.length > 0) { window.popupWindowObjects[arguments[0]].hidePopup(); }
	else { this.hidePopup(); }
	}

// Refresh the contents of the calendar display
function CP_refreshCalendar(index) {
	var calObject = window.popupWindowObjects[index];
	if (arguments.length>1) { 
		calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));
		}
	else {
		calObject.populate(calObject.getCalendar());
		}
	calObject.refresh();
	}

// Populate the calendar and display it
function CP_showCalendar(anchorname) {
	if (arguments.length>1) {
		if (arguments[1]==null||arguments[1]=="") {
			this.currentDate=new Date();
			}
		else {
			this.currentDate=new Date(parseDate(arguments[1]));
			}
		}
	this.populate(this.getCalendar());
	this.showPopup(anchorname);
	}

// Simple method to interface popup calendar with a text-entry box
function CP_select(inputobj, linkname, format) {
	var selectedDate=(arguments.length>3)?arguments[3]:null;
	if (!window.getDateFromFormat) {
		alert("calendar.select: To use this method you must also include 'date.js' for date formatting");
		return;
		}
	if (this.displayType!="date"&&this.displayType!="week-end") {
		alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");
		return;
		}
	if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 
		alert("calendar.select: Input object passed is not a valid form input object"); 
		window.CP_targetInput=null;
		return;
		}
	if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input!
	window.CP_targetInput = inputobj;
	window.CP_calendarObject = this;
	this.currentDate=null;
	var time=0;
	if (selectedDate!=null) {
		time = getDateFromFormat(selectedDate,format)
		}
	else if (inputobj.value!="") {
		time = getDateFromFormat(inputobj.value,format);
		}
	if (selectedDate!=null || inputobj.value!="") {
		if (time==0) { this.currentDate=null; }
		else { this.currentDate=new Date(time); }
		}
	window.CP_dateFormat = format;
	this.showCalendar(linkname);
	}
	
// Get style block needed to display the calendar correctly
function getCalendarStyles() {
	var result = "";
	var p = "";
	if (this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!="") { p=this.cssPrefix; }
	result += "<STYLE>\n";
	result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n";
	result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n";
	result += "TD."+p+"cpDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0 0 1 0; }\n";
	result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate  { text-align:right; text-decoration:none; }\n";
	result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n";
	result += "."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n";
	result += "."+p+"cpOtherMonthDate { color:#808080; }\n";
	result += "TD."+p+"cpCurrentDate { color:white; background-color: #C0C0C0; border-width:1; border:solid thin #800000; }\n";
	result += "TD."+p+"cpCurrentDateDisabled { border-width:1; border:solid thin #FFAAAA; }\n";
	result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled { border:solid thin #C0C0C0; border-width:1 0 0 0;}\n";
	result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled { height:20px; }\n";
	result += "A."+p+"cpTodayText { color:black; }\n";
	result += "."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n";
	
	result += "</STYLE>\n";
	return result;
	}

// Return a string containing all the calendar code to be displayed
function CP_getCalendar() {
	var now = new Date();
	// Reference to window
	if (this.type == "WINDOW") { var windowref = "window.opener."; }
	else { var windowref = ""; }
	var result = "";
	// If POPUP, write entire HTML document
	if (this.type == "WINDOW") {
		result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";
		result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';
		}
	else {
		result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';
		result += '<TR><TD ALIGN=CENTER>\n';
		result += '<CENTER>\n';
		}
	// Code for DATE display (default)
	// -------------------------------
	if (this.displayType=="date" || this.displayType=="week-end") {
		if (this.currentDate==null) { this.currentDate = now; }
		if (arguments.length > 0) { var month = arguments[0]; }
			else { var month = this.currentDate.getMonth()+1; }
		if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; }
			else { var year = this.currentDate.getFullYear(); }
		var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
		if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) {
			daysinmonth[2] = 29;
			}
		var current_month = new Date(year,month-1,1);
		var display_year = year;
		var display_month = month;
		var display_date = 1;
		var weekday= current_month.getDay();
		var offset = 0;
		
		offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;
		if (offset > 0) {
			display_month--;
			if (display_month < 1) { display_month = 12; display_year--; }
			display_date = daysinmonth[display_month]-offset+1;
			}
		var next_month = month+1;
		var next_month_year = year;
		if (next_month > 12) { next_month=1; next_month_year++; }
		var last_month = month-1;
		var last_month_year = year;
		if (last_month < 1) { last_month=12; last_month_year--; }
		var date_class;
		if (this.type!="WINDOW") {
			result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
			}
		result += '<TR>\n';
		var refresh = windowref+'CP_refreshCalendar';
		var refreshLink = 'javascript:' + refresh;
		if (this.isShowNavigationDropdowns) {
			result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';
			for( var monthCounter=1; monthCounter<=12; monthCounter++ ) {
				var selected = (monthCounter==month) ? 'SELECTED' : '';
				result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';
				}
			result += '</select></TD>';
			result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>';

			result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';
			for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) {
				var selected = (yearCounter==year) ? 'SELECTED' : '';
				result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';
				}
			result += '</select></TD>';
			}
		else {
			if (this.isShowYearNavigation) {
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');"><</A></TD>';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">></A></TD>';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>';

				result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');"><</A></TD>';
				if (this.isShowYearNavigationInput) {
					result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';
					}
				else {
					result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';
					}
				result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">></A></TD>';
				}
			else {
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');"><<</A></TD>\n';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">>></A></TD>\n';
				}
			}
		result += '</TR></TABLE>\n';
		result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';
		result += '<TR>\n';
		for (var j=0; j<7; j++) {

			result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';
			}
		result += '</TR>\n';
		for (var row=1; row<=6; row++) {
			result += '<TR>\n';
			for (var col=1; col<=7; col++) {
				var disabled=false;
				if (this.disabledDatesExpression!="") {
					var ds=""+display_year+LZ(display_month)+LZ(display_date);
					eval("disabled=("+this.disabledDatesExpression+")");
					}
				var dateClass = "";
				if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) {
					dateClass = "cpCurrentDate";
					}
				else if (display_month == month) {
					dateClass = "cpCurrentMonthDate";
					}
				else {
					dateClass = "cpOtherMonthDate";
					}
				if (disabled || this.disabledWeekDays[col-1]) {
					result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';
					}
				else {
					var selected_date = display_date;
					var selected_month = display_month;
					var selected_year = display_year;
					if (this.displayType=="week-end") {
						var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);
						d.setDate(d.getDate() + (7-col));
						selected_year = d.getYear();
						if (selected_year < 1000) { selected_year += 1900; }
						selected_month = d.getMonth()+1;
						selected_date = d.getDate();
						}
					result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';
					}
				display_date++;
				if (display_date > daysinmonth[display_month]) {
					display_date=1;
					display_month++;
					}
				if (display_month > 12) {
					display_month=1;
					display_year++;
					}
				}
			result += '</TR>';
			}
		var current_weekday = now.getDay() - this.weekStartDay;
		if (current_weekday < 0) {
			current_weekday += 7;
			}
		result += '<TR>\n';
		result += '	<TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';
		if (this.disabledDatesExpression!="") {
			var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());
			eval("disabled=("+this.disabledDatesExpression+")");
			}
		if (disabled || this.disabledWeekDays[current_weekday+1]) {
			result += '		<SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';
			}
		else {
			result += '		<A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';
			}
		result += '		<BR>\n';
		result += '	</TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';
	}

	// Code common for MONTH, QUARTER, YEAR
	// ------------------------------------
	if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") {
		if (arguments.length > 0) { var year = arguments[0]; }
		else { 
			if (this.displayType=="year") {	var year = now.getFullYear()-this.yearSelectStartOffset; }
			else { var year = now.getFullYear(); }
			}
		if (this.displayType!="year" && this.isShowYearNavigation) {
			result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
			result += '<TR>\n';
			result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');"><<</A></TD>\n';
			result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';
			result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">>></A></TD>\n';
			result += '</TR></TABLE>\n';
			}
		}
		
	// Code for MONTH display 
	// ----------------------
	if (this.displayType=="month") {
		// If POPUP, write entire HTML document
		result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
		for (var i=0; i<4; i++) {
			result += '<TR>';
			for (var j=0; j<3; j++) {
				var monthindex = ((i*3)+j);
				result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';
				}
			result += '</TR>';
			}
		result += '</TABLE></CENTER></TD></TR></TABLE>\n';
		}
	
	// Code for QUARTER display
	// ------------------------
	if (this.displayType=="quarter") {
		result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';
		for (var i=0; i<2; i++) {
			result += '<TR>';
			for (var j=0; j<2; j++) {
				var quarter = ((i*2)+j+1);
				result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';
				}
			result += '</TR>';
			}
		result += '</TABLE></CENTER></TD></TR></TABLE>\n';
		}

	// Code for YEAR display
	// ---------------------
	if (this.displayType=="year") {
		var yearColumnSize = 4;
		result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
		result += '<TR>\n';
		result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');"><<</A></TD>\n';
		result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">>></A></TD>\n';
		result += '</TR></TABLE>\n';
		result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
		for (var i=0; i<yearColumnSize; i++) {
			for (var j=0; j<2; j++) {
				var currentyear = year+(j*yearColumnSize)+i;
				result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';
				}
			result += '</TR>';
			}
		result += '</TABLE></CENTER></TD></TR></TABLE>\n';
		}
	// Common
	if (this.type == "WINDOW") {
		result += "</BODY></HTML>\n";
		}
	return result;
	}

/* http://www.time4trip.in/lib/calendaroperateSearch.js */
      var now = new Date();
      now.setDate(now.getDate()-1);
      
      function getDateString(y_obj,m_obj,d_obj) 
      {
	    
 		var y = y_obj.options[y_obj.selectedIndex].value;
 		var m = m_obj.options[m_obj.selectedIndex].value;
 		m=m-1;
 		var d = d_obj.options[d_obj.selectedIndex].value;
 		if (y=="" || m=="") { return null; }
 		if (d=="") { d=1; }
 		m=Number(m)+1;
 		return str= y+'-'+m+'-'+d;
     }  
          
      
      
      var cal10 = new CalendarPopup();
      cal10.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
 	  cal10.setReturnFunction("setMultipleValues4");
 	  function setMultipleValues4(y,m,d) 
	  {
		document.searchform.CheckInYear.value=y;
		document.searchform.CheckInMonth.value=m;
		document.searchform.CheckInDate.value=d;
	  }
       
      function getmonth()
        {
      		var month1=Number(document.searchform.CheckInMonth);
     		return month1; 
        }
       
        
        
        var cal11 = new CalendarPopup();
       	cal11.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
     	cal11.setReturnFunction("setMultipleValues5");
     	function setMultipleValues5(y,m,d) 
	    {
     	
     		document.searchform.CheckOutYear.value=y;
     		document.searchform.CheckOutMonth.value=m;
     		document.searchform.CheckOutDate.value=d;
     	   
     	}
     
       function getmonthout()
       {
     		var month1=Number(document.searchform.CheckOutMonth)+1;
     		return month1; 
       }
       
       
       
         
         
         var cal12 = new CalendarPopup();
         cal12.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
         cal12.setReturnFunction("setMultipleValues6");
         function setMultipleValues6(y,m,d) 
       	 {
       	 
		document.searchform[0].CheckInYear.value=y;
		document.searchform[0].CheckInMonth.value=m;
		document.searchform[0].CheckInDate.value=d;

         }
              
       
          
       
         
       
         function getmonth0()
         {
		var month1=Number(document.searchform[0].CheckInMonth);
		return month1; 
         }
              
         var cal13 = new CalendarPopup();
         cal13.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
         cal13.setReturnFunction("setMultipleValues7");
         function setMultipleValues7(y,m,d) 
       	 {
            	
		document.searchform[0].CheckOutYear.value=y;
		document.searchform[0].CheckOutMonth.value=m;
		document.searchform[0].CheckOutDate.value=d;
            	   
         }
            
         function getmonthout0()
         {
		var month1=Number(document.searchform[0].CheckOutMonth)+1;
		return month1; 
         }
       
       
       
       
         var cal21 = new CalendarPopup();
         cal21.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
	 cal21.setReturnFunction("setMultipleValues8");
	 function setMultipleValues8(y,m,d) 
       	 {
       	 
       	 		document.searchform[1].CheckInYear.value=y;
       	 		document.searchform[1].CheckInMonth.value=m;
       	 		document.searchform[1].CheckInDate.value=d;
       	 }
              
         function getmonth1()
         {
		var month1=Number(document.searchform[1].CheckInMonth);
		return month1; 
         }

         var cal22 = new CalendarPopup();
	 cal22.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
	 cal22.setReturnFunction("setMultipleValues9");
	 function setMultipleValues9(y,m,d) 
       	 {
            	
		document.searchform[1].CheckOutYear.value=y;
		document.searchform[1].CheckOutMonth.value=m;
		document.searchform[1].CheckOutDate.value=d;
         }
            
         function getmonthout1()
         {
         
		var month1=Number(document.searchform[1].CheckOutMonth)+1;
		return month1; 
         }
         
         
         
         var cal23 = new CalendarPopup();
	          cal23.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
	 	 cal23.setReturnFunction("setMultipleValues10");
	 	 function setMultipleValues10(y,m,d) 
	        	 {
	        	 
	        	 		document.searchform[2].CheckInYear.value=y;
	        	 		document.searchform[2].CheckInMonth.value=m;
	        	 		document.searchform[2].CheckInDate.value=d;
	        	 }
	               
	          function getmonth2()
	          {
	 		var month1=Number(document.searchform[2].CheckInMonth);
	 		return month1; 
	          }
	 
	         var cal24 = new CalendarPopup();
	 	 cal24.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
	 	 cal24.setReturnFunction("setMultipleValues11");
	 	 function setMultipleValues11(y,m,d) 
	        	 {
	             	
	 		document.searchform[2].CheckOutYear.value=y;
	 		document.searchform[2].CheckOutMonth.value=m;
	 		document.searchform[2].CheckOutDate.value=d;
	          }
	             
	          function getmonthout2()
	          {
	          
	 		var month1=Number(document.searchform[2].CheckOutMonth)+1;
	 		return month1; 
                   }
                 var cal25 = new CalendarPopup();
		 cal25.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal25.setReturnFunction("setMultipleValues12");
		 function setMultipleValues12(y,m,d) 
			 {

					document.searchform[3].CheckInYear.value=y;
					document.searchform[3].CheckInMonth.value=m;
					document.searchform[3].CheckInDate.value=d;
			 }

		  function getmonth3()
		  {
			var month1=Number(document.searchform[3].CheckInMonth);
			return month1; 
		  }

		 var cal26= new CalendarPopup();
		 cal26.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal26.setReturnFunction("setMultipleValues13");
		 function setMultipleValues13(y,m,d) 
			 {

			document.searchform[3].CheckOutYear.value=y;
			document.searchform[3].CheckOutMonth.value=m;
			document.searchform[3].CheckOutDate.value=d;
		  }

		  function getmonthout3()
		  {

			var month1=Number(document.searchform[3].CheckOutMonth)+1;
			return month1; 
                   }
                 var cal27 = new CalendarPopup();
		 cal27.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal27.setReturnFunction("setMultipleValues14");
		 function setMultipleValues14(y,m,d) 
			 {

					document.searchform[4].CheckInYear.value=y;
					document.searchform[4].CheckInMonth.value=m;
					document.searchform[4].CheckInDate.value=d;
			 }

		  function getmonth4()
		  {
			var month1=Number(document.searchform[4].CheckInMonth);
			return month1; 
		  }

		 var cal28= new CalendarPopup();
		 cal28.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal28.setReturnFunction("setMultipleValues15");
		 function setMultipleValues15(y,m,d) 
			 {

			document.searchform[4].CheckOutYear.value=y;
			document.searchform[4].CheckOutMonth.value=m;
			document.searchform[4].CheckOutDate.value=d;
		  }

		  function getmonthout4()
		  {

			var month1=Number(document.searchform[4].CheckOutMonth)+1;
			return month1; 
                   }     
                 var cal29 = new CalendarPopup();
		 cal29.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal29.setReturnFunction("setMultipleValues16");
		 function setMultipleValues16(y,m,d) 
			 {

					document.searchform[5].CheckInYear.value=y;
					document.searchform[5].CheckInMonth.value=m;
					document.searchform[5].CheckInDate.value=d;
			 }

		  function getmonth5()
		  {
			var month1=Number(document.searchform[5].CheckInMonth);
			return month1; 
		  }

		 var cal30= new CalendarPopup();
		 cal30.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal30.setReturnFunction("setMultipleValues17");
		 function setMultipleValues17(y,m,d) 
			 {

			document.searchform[5].CheckOutYear.value=y;
			document.searchform[5].CheckOutMonth.value=m;
			document.searchform[5].CheckOutDate.value=d;
		  }

		  function getmonthout5()
		  {

			var month1=Number(document.searchform[5].CheckOutMonth)+1;
			return month1; 
                   }  
                  var cal31 = new CalendarPopup();
		 cal31.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal31.setReturnFunction("setMultipleValues18");
		 function setMultipleValues18(y,m,d) 
			 {

					document.searchform[6].CheckInYear.value=y;
					document.searchform[6].CheckInMonth.value=m;
					document.searchform[6].CheckInDate.value=d;
			 }

		  function getmonth6()
		  {
			var month1=Number(document.searchform[6].CheckInMonth);
			return month1; 
		  }

		 
		 
		 
		 var cal32= new CalendarPopup();
		 cal32.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal32.setReturnFunction("setMultipleValues19");
		 function setMultipleValues19(y,m,d) 
			 {

			document.searchform[6].CheckOutYear.value=y;
			document.searchform[6].CheckOutMonth.value=m;
			document.searchform[6].CheckOutDate.value=d;
		  }

		  function getmonthout6()
		  {

			var month1=Number(document.searchform[6].CheckOutMonth)+1;
			return month1; 
                   }  
                   
                   
         var cal33= new CalendarPopup();
		 cal33.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal33.setReturnFunction("setMultipleValues20");
		 function setMultipleValues20(y,m,d) 
			 {

			document.carsearchform.strCheckinyear0.value=y;
			document.carsearchform.strCheckinmonth0.value=m;
			document.carsearchform.strCheckindate0.value=d;
		  }

		  function getmonthin7()
		  {

			var month1=Number(document.carsearchform.CheckInMonth0)+1;
			return month1; 
         }   
         
         
         
         var cal34= new CalendarPopup();
		 cal34.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
		 cal34.setReturnFunction("setMultipleValues21");
		 function setMultipleValues21(y,m,d) 
			 {

			document.carsearchform.strCheckinyear1.value=y;
			document.carsearchform.strCheckinmonth1.value=m;
			document.carsearchform.strCheckindate1.value=d;
		  }

		  function getmonthin8()
		  {

			var month1=Number(document.carsearchform.strCheckinmonth1)+1;
			return month1; 
         }
         
         var cal35= new CalendarPopup();
	 cal35.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
	 cal35.setReturnFunction("setMultipleValues22");
	 function setMultipleValues22(y,m,d) 
	 {

		document.carsearchform.strCheckinyear2.value=y;
		document.carsearchform.strCheckinmonth2.value=m;
		document.carsearchform.strCheckindate2.value=d;
	  }

	  function getmonthin9()
	  {

		var month1=Number(document.carsearchform.strCheckinmonth2)+1;
		return month1; 
         }            
               
               
               
         var cal50= new CalendarPopup();
	 cal50.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
	 cal50.setReturnFunction("setMultipleValues23");
	 var days;
	 function setMultipleValues23(y,m,d) 
	 {
	        document.carBookingForm.arrYY[days].value=y;
		document.carBookingForm.arrMM[days].value=m;
		document.carBookingForm.arrDD[days].value=d;
	  }

	  function getmonth50(day)
	  {
	     days=day;
             var month1=Number(document.carBookingForm.arrMM[day])+1;
			return month1; 
         }               
                   
		
	   
<!--  Below code is for Flight for -->



      var cal51 = new CalendarPopup();
      cal51.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
      cal51.setReturnFunction("setMultipleValues51");
      function setMultipleValues51(y,m,d) 
      {
	    alert("ok");
	    document.AvailRequester.departureMonth.value=m;
	    document.AvailRequester.departureDay.value=d;
       }
       
      function getmonth51()
        {
              
      		var month1=Number(document.AvailRequester.departureMonth);
     		return month1; 
        }
       
        
        
        var cal52 = new CalendarPopup();
       	cal52.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
     	cal52.setReturnFunction("setMultipleValues52");
     	function setMultipleValues52(y,m,d) 
	    {
     	
     		
     		document.AvailRequester.returnMonth.value=m;
     		document.AvailRequester.returnDay.value=d;
     	   
     	}
     
       function getmonthout52()
       {
     		var month1=Number(document.AvailRequester.returnMonth)+1;
     		return month1; 
       }
       
       
  
/* http://www.time4trip.in/lib/sitevalidation.js */
function othercity()
{
	document.searchform.strCity[8].checked=true;
}

function text()
{
	document.searchform.strOtherCity.focus();
}





function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var today=new Date();
var todate=today.getDate();
var tomonth=today.getMonth();
var toyear=today.getFullYear();
var checkOK = "0123456789";

//Leap year (Uma Chatterjee - 2.1.2006)
function leapYearCheck(y) {	
	if ( ( (y%4==0)&&(y%100 != 0) ) || (y%400==0) ) { 
		return true;
	} else {
		return false;
	}
}

//Days of month (Uma Chatterjee - 2.1.2006)
function addDays(datefield, num) {
	
	var numDays=Number(monthDays[num]);
	if(leapYearCheck(toyear) && (num==1)) {		
		numDays=29;
	}
	
	datefield.options.length=0;
	for(i=1; i<=numDays; i++) {
		datefield.options[datefield.options.length]=new Option(i, i);
	}
	
	if(datefield.options[0].value=="")
		datefield.remove(0);
		
}


function isDate1(dt)
{
        var dtCh= "/";
        var daysInMonth = DaysArray(12)
  	var pos1=dt.indexOf(dtCh)
  	var pos2=dt.indexOf(dtCh,pos1+1)
  	var strMonth=dt.substring(0,pos1)
  	var strDay=dt.substring(pos1+1,pos2)
  	var strYear=dt.substring(pos2+1)
  	var strYr=strYear
  	if (strDay.charAt(0)=="0" && strDay.length>1) var strDay=strDay.substring(1)
  	if (strMonth.charAt(0)=="0" && strMonth.length>1) var strMonth=strMonth.substring(1)
  	for (var i = 1; i <= 3; i++) {
  		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
  	}
  	month=parseInt(strMonth)
  	day=parseInt(strDay)
  	year=parseInt(strYr)
  	if (strMonth.length<1 || month<1 || month>12){
  		alert("Please enter a valid month")
  		return false
  	}
  	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
  		alert("Please enter a valid day")
  		return false
  	}
  	return true    
}



function stripCharsInBag(s, bag)
{
        var i;
        var returnString = "";
        // Search through string's characters one by one.
        // If character is not in bag, append to returnString.
        for (i = 0; i < s.length; i++)
        {   
	    var c = s.charAt(i);
	    if (bag.indexOf(c) == -1) returnString += c;
        }
        return returnString;
}

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function myfunction()
{
	document.searchform.submit();
}

function CityCheck(indicator)
{
   var iscity=false;
   var city=document.searchform.strCity
   for(i=0;i<indicator;i++)
   {
        if(city[i].checked)
        {
           iscity=true;
        }     
   }
   if(city[indicator].checked)
   {
         
         if(document.searchform.strOtherCity.value!="")
         {
            iscity=true;
         }
   }
   if(iscity==false)
   {
           alert("Please enter City Name");
           document.searchform.strOtherCity.focus();
           return false;
       }
       
   else
   {
            myfunction()
   } 
}


function DateCheck()
{        
  	var iscity=false;
  	var Checkindate=document.searchform.CheckInDate.value;
  	var Checkinmonth=document.searchform.CheckInMonth.value;
  	Checkinmonth=Number(Checkinmonth);
  	var Checkinyear=document.searchform.CheckInYear.value;
  	var Checkoutdate=document.searchform.CheckOutDate.value;
  	var Checkoutmonth=document.searchform.CheckOutMonth.value;
  	Checkoutmonth=Number(Checkoutmonth);
    var Checkoutyear=document.searchform.CheckOutYear.value;
    var presentday=new Date(toyear,tomonth,todate);
    var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
    var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
    
    var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
    var diff=difference/1000/60/60/24;
    var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear
      
  

  	if(isDate1(dt)==false)
  	{
       		return false;
  	}
  	else if(startdate<presentday)
  	{
     		alert(" CheckIn Date Should Be Higher Than Today's Date");
     		return false;
  	}
  	else if(enddate < startdate)
  	{
    		alert(" End Date Should Be Higher Than  Start Date");
    		return false;
  	}
  
  	else if(diff>30)
  	{
      		alert("Sorry You Cannot Do  Booking For More Than 30 Days");
      		return false;
  	}
   
  	else
  	{
  	        document.searchform.checkIn.value=Checkinmonth+"/"+Checkindate+"/"+Checkinyear;
  	        document.searchform.checkOut.value=Checkoutmonth+"/"+Checkoutdate+"/"+Checkoutyear;
  	        return true;
  	} 
}






function DateCheck2()
{        
  	var Checkindate=document.searchform.CheckInDate.value;
  	var Checkinmonth=document.searchform.CheckInMonth.value;
  	Checkinmonth=Number(Checkinmonth);
  	var Checkinyear=document.searchform.CheckInYear.value;
  	var Checkoutdate=document.searchform.CheckOutDate.value;
  	var Checkoutmonth=document.searchform.CheckOutMonth.value;
  	Checkoutmonth=Number(Checkoutmonth);
        var Checkoutyear=document.searchform.CheckOutYear.value;
        var presentday=new Date(toyear,tomonth,todate);
        var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
        var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
        var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
        var diff=difference/1000/60/60/24;
        var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear

  	if(isDate1(dt)==false)
  	{
       		return false;
  	}
  	else if(startdate<presentday)
  	{
     		alert(" CheckIn Date Should Be Higher Than Today's Date");
     		return false;
  	}
  	else if(enddate < startdate)
  	{
    		alert(" End Date Should Be Higher Than  Start Date");
    		return false;
  	}
  
  	else if(diff>30)
  	{
      		alert("Sorry You Cannot Do  Booking For More Than 30 Days");
      		return false;
  	}
   
  	else
  	{
     		return true;
  	} 
}

function DateCheckTravelguru()
{   
	if(document.searchform.strOtherCity.value==null || document.searchform.strOtherCity.value=="")
	{
    	for(var i=0;i<document.searchform.strCity.length;i++){
    		if(document.searchform.strCity[i].checked){
    			document.searchform.hotelCity.value=document.searchform.strCity[i].value;		
    		}
    	}
    	
	}
    else{
    	document.searchform.hotelCity.value=document.searchform.strOtherCity.value;	
    	
    }
    document.searchform.CheckInDate.value=document.searchform.strCheckindate.value;
	document.searchform.CheckInMonth.value=document.searchform.strCheckinmonth.value;
	document.searchform.CheckInYear.value=document.searchform.strCheckinyear.value;
	
	document.searchform.CheckOutDate.value=document.searchform.strCheckoutdate.value;
	document.searchform.CheckOutMonth.value=document.searchform.strCheckoutmonth.value;
	document.searchform.CheckOutYear.value=document.searchform.strCheckoutyear.value;
		
	var iscity=false;
  	var Checkindate=document.searchform.CheckInDate.value;
  	var Checkinmonth=document.searchform.CheckInMonth.value;
  	Checkinmonth=Number(Checkinmonth);
  	var Checkinyear=document.searchform.CheckInYear.value;
  	var Checkoutdate=document.searchform.CheckOutDate.value;
  	var Checkoutmonth=document.searchform.CheckOutMonth.value;
  	Checkoutmonth=Number(Checkoutmonth);
    var Checkoutyear=document.searchform.CheckOutYear.value;
    var presentday=new Date(toyear,tomonth,todate);
    var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
    var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
    var city=document.searchform.strCity;
    var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
    var diff=difference/1000/60/60/24;
    var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear
    for(i=0;i<8;i++)
    {
        if(city[i].checked)
        {
        	iscity=true;
        }
		
    }
    if(city[8].checked)
  	{
  			if(document.searchform.strOtherCity.value!="")
      		{
      			iscity=true;
      		}
  	}
  	if(iscity==false)
	{
			alert("Please enter City Name");
			document.searchform.strOtherCity.focus();
			return false;
	}
  	else if(isDate1(dt)==false)
  	{
       		return false;
  	}
  	else if(startdate<presentday)
  	{
     		alert(" CheckIn Date Should Be Higher Than Today's Date");
     		return false;
  	}
  	else if(enddate < startdate)
  	{
    		alert(" End Date Should Be Higher Than  Start Date");
    		return false;
  	}
  
  	else if(diff>30)
  	{
      		alert("Sorry You Cannot Do  Booking For More Than 30 Days");
      		return false;
  	}
	else
  	{		return true;
  	} 
}





function Checkhotel(i)
{
    var Checkindate=document.forms[i].CheckInDate.value;
    var Checkinmonth=document.forms[i].CheckInMonth.value;
    Checkinmonth=Number(Checkinmonth);
    var Checkinyear=document.forms[i].CheckInYear.value;
    var Checkoutdate=document.forms[i].CheckOutDate.value;
    var Checkoutmonth=document.forms[i].CheckOutMonth.value;
    Checkoutmonth=Number(Checkoutmonth);
    var Checkoutyear=document.forms[i].CheckOutYear.value;

    var presentday=new Date(toyear,tomonth,todate);
    var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
    var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
   
   
    var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
    var diff=difference/1000/60/60/24;
    var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear
    if(isDate1(dt)==false)
    {
           return false;
    }
    
    else if(startdate<presentday)
    {
       alert(" Check-In-Date Should Be Higher Than Current Date");
       return false;
    }
    else if(enddate < startdate)
    {
        alert(" Check-Out-Date Should Be Higher Than  Check-In-Date");
        return false;
    }
    
        else if(diff>30)
        {
              alert("Sorry You Cannot Do  Booking For More Than 30 Days");
              return false;
    }
  
  
    else
    {
         return true;
    } 
}

function carothercity(i)
{
   document.carsearchform.strCarCity[(i*9)+8].checked=true;
}


function cartext(i)
{
   document.carsearchform.strCarOtherCity[i].focus();
}


//Leap year, month days (Uma Chatterjee - 2.1.2006)
monthDays=new Array("31", "28", "31", "30", "31",  "30", "31", "31", "30", "31", "30", "31");

//Leap year, month days (Uma Chatterjee - 2.1.2006)
function setCheckOutDateNew()
{
		var d=Number(document.searchform.strCheckindate.value);
		var m=Number(document.searchform.strCheckinmonth.value);
		var y=Number(document.searchform.strCheckinyear.value);
		var checkoutDay=d+1;
		var nextMonth=m;
		var checkoutYear=y;
		
		if(leapYearCheck(y)) {		
			monthDays[1]="29";
		} else {
			monthDays[1]="28";
		}
		
		if(leapYearCheck(y) && m==2) {
			addDays(document.searchform.strCheckindate, m-1);
			addDays(document.searchform.strCheckoutdate, m-1);
		}		
		
		
		if(document.searchform.strCheckinmonth.options.length!=monthDays[m-1]) {
			addDays(document.searchform.strCheckindate, m-1);
			addDays(document.searchform.strCheckoutdate, m-1);
		}
		
		if(checkoutDay > monthDays[m-1]) {
			nextMonth=m+1;
			if(nextMonth>12) {
				nextMonth=1;			
				checkoutYear+=1;
			}
			addDays(document.searchform.strCheckoutdate, nextMonth-1);
			checkoutDay=checkoutDay-monthDays[m-1];
		}
		
		if(d>monthDays[m-1]) {
			d=monthDays[m-1];
			checkoutDay=1;
		}
		
		document.searchform.strCheckinyear.value=y;
		document.searchform.strCheckinmonth.value=m;
		document.searchform.strCheckindate.value=d;
		
		document.searchform.strCheckoutyear.value=checkoutYear;
		document.searchform.strCheckoutmonth.value=nextMonth;
		document.searchform.strCheckoutdate.value=checkoutDay;
		
}

//Leap year, month days (Uma Chatterjee - 2.1.2006)
function setDates() {
	if(leapYearCheck(document.searchform.strCheckoutyear.value)) {		
		monthDays[1]="29";
	} else {
		monthDays[1]="28";
	}	
	var checkoutdate=document.searchform.strCheckoutdate.value;
	addDays(document.searchform.strCheckoutdate, document.searchform.strCheckoutmonth.selectedIndex);
	if(checkoutdate>document.searchform.strCheckoutdate.options.length) {
		document.searchform.strCheckoutdate.value=document.searchform.strCheckoutdate.options.length;
	} else {
		document.searchform.strCheckoutdate.value=checkoutdate;
	}
}

function setCheckOutDate()
{
   var checkindate=document.searchform.CheckInDate.value;
   var checkinmonth=Number(document.searchform.CheckInMonth.value)-1;
   var checkinyear=document.searchform.CheckInYear.value;
   var checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
   document.searchform.CheckOutDate.value = checkout.getDate();
   document.searchform.CheckOutMonth.value = (checkout.getMonth()+1);
   document.searchform.CheckOutYear.value = checkout.getYear();
   
}


function setCheckOutDate1(i)
{
   var checkindate=document.searchform[i].strCheckindate.value;
   var checkinmonth=Number(document.searchform[i].strCheckinmonth.value)-1;
   var checkinyear=document.searchform[i].strCheckinyear.value;
   var checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
   document.searchform[i].strCheckoutdate.value = checkout.getDate();
   document.searchform[i].strCheckoutmonth.value = (checkout.getMonth()+1);
   document.searchform[i].strCheckoutyear.value = checkout.getYear();
   
}

function formsubmit(index,count)
{    
           alert(indicator);
           if(indicator<1)
	   {
	       document.MoreInfoForm.submit();
	   }
	   else
	   {
	       document.MoreInfoForm[Number(index)].submit();
	   }
}

function formsubmitcity(index)
{
   if((document.MoreInfoForm.length)!=1)
   {
       document.MoreInfoForm[index].submit();
   }
   else
   {
       document.MoreInfoForm.submit();
   }
}


function CarDateCheck()
{
	  var j;
	  
	  if(document.carsearchform.strHireType[0].checked)
	  {
	      j=0;
	      if(document.carsearchform.strDays.value.length==0)
	      {
	          alert("Please Enter No. Of Days");
	          document.carsearchform.strDays.focus();
	          return false;
	      }
	     
	      else if(Number(document.carsearchform.strDays.value)>30)
	      {
	          alert("No. Of Days Should be less than 30 days");
	          document.carsearchform.strDays.focus();
	          return false;
	      }
	      else if(Number(document.carsearchform.strDays.value)==0)
	      {
		       alert("No. of days should not be zero");
		       document.carsearchform.strDays.focus();
		       return false;
              }	     
	      
	      var check = document.carsearchform.strDays.value;
	      var allValid = true;
	      var allNum = "";
	      var l=0;
              for (i = 0;  i < check.length;  i++)
	      {
			ch = check.charAt(i);
			for (k = 0;  k < checkOK.length;  k++)
			if (ch == checkOK.charAt(k))
			break;
			if (k == checkOK.length)
			{
			    allValid = false;
				break;
			}
              }
	      if (!allValid)
	      {
			alert("Please enter only digit characters in the No. Of Days field.");
			return false;
	      }
		 
	  }
  
	  else if(document.carsearchform.strHireType[1].checked)
	  {
                if(document.carsearchform.airport[0].checked)
				{
		              j=1;
					  if(document.carsearchform.strDropPoint.value.length==0)
					  {
							   alert("Please Enter Drop Point");
							   document.carsearchform.strDropPoint.focus();
							   return false;
					  }
                }
			    else if(document.carsearchform.airport[1].checked)
			    {
					j=2;
				   if(document.carsearchform.strPickUpPoint.value.length==0)
				   {
							alert("Please Enter PickUp Point");
							document.carsearchform.strPickUpPoint.focus();
							return false;
				   }
			    }
      }
	
       
	  if(j==0)
	  {
                
	   	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity0.value;
	   	document.carsearchform.strPeople.value=document.carsearchform.strPeople0.value;
	   	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate0.value;
	   	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth0.value;
	   	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear0.value;
	  }
	 
	  if(j==1)
	  {		   
	     	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity1.value;
	     	document.carsearchform.strPeople.value=document.carsearchform.strPeople1.value;
		document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate1.value;
		document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth1.value;
	     	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear1.value;
	     	document.carsearchform.strFlightDetail1.value=document.carsearchform.strFlightDetail11.value;
	     	document.carsearchform.strFlightDetail2.value=document.carsearchform.strFlightDetail21.value;
	     	if(document.carsearchform.strFlightDetail1.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail11.focus();
		     return false;
	    	}

	        else if(document.carsearchform.strFlightDetail2.value.length==0)
	        { 
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail21.focus();
		     return false;
	        }	     
	  }
	  if(j==2)
	  {
	     	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity2.value;
	     	document.carsearchform.strPeople.value=document.carsearchform.strPeople2.value;
	     	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate2.value;
	     	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth2.value;
	     	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear2.value;
	     	document.carsearchform.strFlightDetail1.value=document.carsearchform.strFlightDetail12.value;
	     	document.carsearchform.strFlightDetail2.value=document.carsearchform.strFlightDetail22.value;
	     	if(document.carsearchform.strFlightDetail1.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail12.focus();
		     return false;
	     	}
		else if(document.carsearchform.strFlightDetail2.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail22.focus();
		     return false;
	   	}
	     
	  }
	  var iscity=false;
	  var Checkindate=document.carsearchform.strCheckindate.value;
	  var Checkinmonth=document.carsearchform.strCheckinmonth.value;
	  Checkinmonth=Number(Checkinmonth);
	  var Checkinyear=document.carsearchform.strCheckinyear.value;
	  var presentday=new Date(toyear,tomonth,todate+2);
	  var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear  
	  
	  var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
	  var city=document.carsearchform.strCarCity
	 
	  for(i=j*9;i<(8*(j+1))+j;i++)
	  {
	     if(city[i].checked)
	     {
	        iscity=true;
	     }
	     
	       
	  }
  
    
	  if(city[(8*(j+1))+j].checked)
	  {
	      
	      if(document.carsearchform.strCarOtherCity.value!="")
	      {
	         iscity=true;
	      }
	  }
	  if(iscity==false)
	    {
	        alert("Please enter City Name");
	        return false;
	  }
	  else if(isDate1(dt)==false)
	  {
	         return false;
          }
	  
	  else if(startdate<presentday)
	  {
	     alert(" Bookin Time Should Be 48 Hour Before Renting Time");
	     return false;
	  }
	  
	  
	  else if(document.carsearchform.strPeople.value.length==0)
	  {
	    alert("Please Enter No. Of People");
	    
	    return false;
	  }
	  
	  
	  var check = document.carsearchform.strPeople.value;
	  
	  allValid = true;
	  var allNum = "";
	  var l=0;
          for (i = 0;  i < check.length;  i++)
	  {
	    	ch = check.charAt(i);
			for (l = 0;  l < checkOK.length;  l++)
			if (ch == checkOK.charAt(l))
			break;
			if (l == checkOK.length)
			{
			    allValid = false;
				break;
			}
          }
          if (!allValid)
	  {
		alert("Please enter only digit characters in the No. Of People field.");
		return false;
	  }
  
	  
	  else
	  {
	     return true;
	  } 
}

function Checkcarrental()
{
  	  var Checkindate=document.carsearchform.strCheckindate.value;
  	  var Checkinmonth=document.carsearchform.strCheckinmonth.value;
  	  Checkinmonth=Number(Checkinmonth);
  	  var Checkinyear=document.carsearchform.strCheckinyear.value;
	  var presentday=new Date(toyear,tomonth,todate+2);
  	  var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
  	  var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear 
  
	  if(startdate<presentday)
	  {
	     alert(" Bookin Time  Should Be AtLeast 48 hour from Renting Time");
	     return false;
	  }

	  else if(document.carsearchform.strDays.value.length==0)
	  {
		 alert("Please Enter No. Of Days");
		 document.carsearchform.strDays.focus();
		 return false;
	  }

	  else if(Number(document.carsearchform.strDays.value)>30)
	  {
		alert("No. Of Days Should be less than 30 days");
		document.carsearchform.strDays.focus();
		return false;
	  }

	  else if(document.carsearchform.strPeople.value.length==0)
	  {
	    alert("Please Enter No. Of People");
	    document.carsearchform.strPeople.focus();
	    return false;
	  } 

	  else if(isDate1(dt)==false)
	  {
		 return false;
	  }
  

	  var checkday = document.carsearchform.strDays.value;
	  var allValidday = true;
	  for (i = 0;  i < checkday.length;  i++)
	  {
		ch = checkday.charAt(i);
		for (k = 0;  k < checkOK.length;  k++)
		if (ch == checkOK.charAt(k))
		break;
		if (k == checkOK.length)
		{
		    allValidday = false;
			break;
		}
	  }
	  if (!allValidday)
	  {
		alert("Please enter only digit characters in the No. Of Days field.");
		return false;
	  }
  
	  var checkpeople= document.carsearchform.strPeople.value;
	  allValidpeople = true;
	  for (i = 0;  i < checkpeople.length;  i++)
	  {
		ch = checkpeople.charAt(i);
		for (l = 0;  l < checkOK.length;  l++)
		if (ch == checkOK.charAt(l))
		break;
		if (l == checkOK.length)
		{
			allValidpeople = false;
			break;
		}
	  }
          if (!allValidpeople)
	  {
		alert("Please enter only digit characters in the No. Of People field.");
		return false;
	  }

	  else
	  {
	     return true;

	  } 
}




function switchImg(what,newImg)
{ 
	if (document.images)
	{	
		document.images[what].src = eval(newImg + ".src");
	}
}

/*if (document.images) 
{
	var img1On = new Image(); img1On.src = "images/india_1on.gif";
	var img1Off = new Image(); img1Off.src = "images/india_1off.gif";
	var img2On = new Image(); img2On.src = "images/india_2on.gif";
	var img2Off = new Image(); img2Off.src = "images/india_2off.gif";
	var img3On = new Image(); img3On.src = "images/india_3on.gif";
	var img3Off = new Image(); img3Off.src = "images/india_3off.gif";
	var img4On = new Image(); img4On.src = "images/india_4on.gif";
	var img4Off = new Image(); img4Off.src = "images/india_4off.gif";
	var img5On = new Image(); img5On.src = "images/india_5on.gif";
	var img5Off = new Image(); img5Off.src = "images/india_5off.gif";
	var img6On = new Image(); img6On.src = "images/india_6on.gif";
	var img6Off = new Image(); img6Off.src = "images/india_6off.gif";
	var img7On = new Image(); img7On.src = "images/india_7on.gif";
	var img7Off = new Image(); img7Off.src = "images/india_7off.gif";
	var img8On = new Image(); img8On.src = "images/india_8on.gif";
	var img8Off = new Image(); img8Off.src = "images/india_8off.gif";
}
*/
function checkSelectPage(indicator)
{

	if(toyear<1900)
        {
      		toyear=toyear+1900;
        }
    	var reportingpoint = document.carBookingForm.arrReportingPoint
   	var date=document.carBookingForm.arrDD;
    	var month=document.carBookingForm.arrMM;
    	var year=document.carBookingForm.arrYY;
    	var presentday=new Date(toyear,tomonth,todate);
        if(indicator==1)
    	{
         	year1=year.value;
         	if(year1<1900)
      		{
      			year1=Number(year.value)+1900;
       		}
         	var startdate=new Date(year1,(month.value)-1,date.value);
         	if(startdate<presentday)
      		{ 
           		alert("Date should be greater than today's date");
           		date.focus();
           		return false;
      		}   
        	if(reportingpoint.value.length==0)
      		{
        		alert("Please enter reporting point");
        		reportingpoint.focus();
        		return false;
      		}
        }
    
    	else
    	{
         	for(i=0;i<indicator;i++)
      		{ 
     			if(reportingpoint[i].value.length==0)
      			{
        			alert("Please enter reporting point");
        			reportingpoint[i].focus();
        			return false;
      			}
     		}
     
     		if(indicator==2)
     		{
        		var firstday=new Date(year[0].value,(month[0].value)-1,date[0].value);
        		var secondday=new Date(year[1].value,(month[1].value)-1,date[1].value);
        		var finalday=new Date(year[0].value,(month[0].value)-1,Number(date[0].value)+30);
        		if(firstday<presentday)
        		{
          			alert("Date should be greater than today's date");
          			date[0].focus();
          			return false;
        		}
			if(firstday>secondday)
			{
			       alert("Date should be greater than previous date");
			    	date[1].focus();
			    	return false;
			}
			if(secondday>finalday)
			{
			    alert("Renting date should not be more than 30 days from First renting date");
			    date[1].focus();
			    return false;
			}
        
     		}
    		else if(indicator>2)
    		{
        		var firstday=new Date(year[0].value,(month[0].value)-1,date[0].value);
			var secondday=new Date(year[1].value,(month[1].value)-1,date[1].value);
			var lastdate=new Date(year[indicator-1].value,(month[indicator-1].value)-1,date[indicator-1].value);
			var secondlastdate=new Date(year[indicator-2].value,(month[indicator-2].value)-1,date[indicator-2].value);
			var finalday=new Date(year[0].value,(month[0].value)-1,Number(date[0].value)+30);

			if(firstday<presentday)
			{
			  alert("Date should be greater than today's date");
			  date[0].focus();
			  return false;
			}
			if(firstday>secondday)
			{
			    alert("Date should be less than next date");
			    date[0].focus();
			    return false;
			}
			if(lastdate<secondlastdate)
			{
			       alert("Date should be greater than previous date");
			    date[indicator-1].focus();
			    return false;
			}
			if(lastdate>finalday)
			{
			    alert("Renting date should not be more than 30 days from First Renting Date");
			    date[indicator-1].focus();
			    return false;
			}
     			for(i=1;i<indicator-1;i++)
      			{
          			var enddate=new Date(year[i+1].value,(month[i+1].value)-1,date[i+1].value);
          			var startdate=new Date(year[i].value,(month[i].value)-1,date[i].value);
          			var previousdate=new Date(year[i-1].value,(month[i-1].value)-1,date[i-1].value);
          			if(startdate>enddate)
          			{
            				alert("Date should be in-between previous date and next date");
           				 date[i+1].focus();
            				return false;
          			}
          			if(startdate<previousdate)
            			{
                			alert("Date should be in-between previous date and next date");
                			date[i].focus();
             				return false; 
         			}
         			if(startdate<presentday)
				{
				    alert("Date should be greater than today's date");
				    date[i].focus();
				    return false;
				}  
         			if(enddate>finalday)
            			{
             				alert("Renting date should not be more than 30 days from First renting date");
             				date[i+1].focus();
             				return false;
            			} 
            		}
    		}
         
   	}
   	return true;
}


function isInteger(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 false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function desiyaIndiaDate(i)

{
    var startdate=new Date(toyear,tomonth,todate+1);
    var enddate=new Date(toyear,tomonth,todate+2);
    
    for(var j=0;j<i;j++)
    {
    	document.searchform[j].strCheckindate.value = startdate.getDate();
    	document.searchform[j].strCheckinmonth.value = startdate.getMonth()+1;
    	document.searchform[j].strCheckinyear.value = startdate.getFullYear();
    
    	document.searchform[j].strCheckoutdate.value = enddate.getDate();
    	document.searchform[j].strCheckoutmonth.value = enddate.getMonth()+1;
    	document.searchform[j].strCheckoutyear.value = enddate.getFullYear();
   }
}






  
/* http://www.time4trip.in/lib/multipleRooms.js */
/* Scripts for generating multiple rooms for search */

function showRoomsSearched(roomNo,fld)
{	
	showRooms(roomNo,fld.strRooms)
	for(var i=1;i<=Number(roomNo);i++)
	{
		if(i==1)
		{	
			showRoomsChildren(i,fld.strChildrenRoom1);
			fld.strChildrenRoom1.onchange();
		}
		if(i==2)
		{	
			showRoomsChildren(i,fld.strChildrenRoom2);
			fld.strChildrenRoom2.onchange();
		}
		if(i==3)
		{	
			showRoomsChildren(i,fld.strChildrenRoom3);
			fld.strChildrenRoom3.onchange();
		}
		if(i==4)
		{	
			showRoomsChildren(i,fld.strChildrenRoom4);
			fld.strChildrenRoom4.onchange();
		}
	
	}
	
}
function showRooms(roomNo,fld)
{

	switch(fld.value)
	{
		case '1':
		document.getElementById('tdname_1').style.display='none';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='none';
		document.getElementById('room3').style.display='none';
		document.getElementById('room4').style.display='none';
		document.getElementById('childrenAge').style.display='none';
		break;
		
		case '2':
		document.getElementById('tdname_1').style.display='block';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='block';
		document.getElementById('room3').style.display='none';
		document.getElementById('room4').style.display='none';
		document.getElementById('roomChild3').style.display='none';
		document.getElementById('roomChild4').style.display='none';
		break;
		
		case '3':
		document.getElementById('tdname_1').style.display='block';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='block';
		document.getElementById('room3').style.display='block';
		document.getElementById('room4').style.display='none';		
		document.getElementById('roomChild4').style.display='none';
		break;
		
		case '4':
		document.getElementById('tdname_1').style.display='block';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='block';
		document.getElementById('room3').style.display='block';
		document.getElementById('room4').style.display='block';
		break;
		
		case '5':
		document.getElementById('tdname_1').style.display='block';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='block';
		document.getElementById('room3').style.display='block';
		document.getElementById('room4').style.display='block';
		break;
		
		case '6':
		document.getElementById('tdname_1').style.display='block';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='block';
		document.getElementById('room3').style.display='block';
		document.getElementById('room4').style.display='block';
		break;
		
		case '7':
		document.getElementById('tdname_1').style.display='block';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='block';
		document.getElementById('room3').style.display='block';
		document.getElementById('room4').style.display='block';
		break;
		
		case '8':
		document.getElementById('tdname_1').style.display='block';
		document.getElementById('room1').style.display='block';
		document.getElementById('room2').style.display='block';
		document.getElementById('room3').style.display='block';
		document.getElementById('room4').style.display='block';
		break;
		
	}
}

function showRoomsVides(roomNo,fld)
{

	switch(fld.value)
	{
		case '1':
		document.getElementById('tdname_1Vides').style.display='none';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='none';
		document.getElementById('room3Vides').style.display='none';
		document.getElementById('room4Vides').style.display='none';
		document.getElementById('room5Vides').style.display='none';
		document.getElementById('room6Vides').style.display='none';
		document.getElementById('room7Vides').style.display='none';
		document.getElementById('room8Vides').style.display='none';
		
		document.getElementById('childrenAgeVides').style.display='none';
		break;
		
		case '2':
		document.getElementById('tdname_1Vides').style.display='block';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='block';
		document.getElementById('room3Vides').style.display='none';
		document.getElementById('room4Vides').style.display='none';
		document.getElementById('room5Vides').style.display='none';
		document.getElementById('room6Vides').style.display='none';
		document.getElementById('room7Vides').style.display='none';
		document.getElementById('room8Vides').style.display='none';
		
		document.getElementById('roomChild3Vides').style.display='none';
		document.getElementById('roomChild4Vides').style.display='none';
		document.getElementById('roomChild5Vides').style.display='none';
		document.getElementById('roomChild6Vides').style.display='none';
		document.getElementById('roomChild7Vides').style.display='none';
		document.getElementById('roomChild8Vides').style.display='none';
		break;
		
		case '3':
		document.getElementById('tdname_1Vides').style.display='block';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='block';
		document.getElementById('room3Vides').style.display='block';
		document.getElementById('room4Vides').style.display='none';
		document.getElementById('room5Vides').style.display='none';
		document.getElementById('room6Vides').style.display='none';
		document.getElementById('room7Vides').style.display='none';
		document.getElementById('room8Vides').style.display='none';
		
		document.getElementById('roomChild4Vides').style.display='none';
		document.getElementById('roomChild5Vides').style.display='none';
		document.getElementById('roomChild6Vides').style.display='none';
		document.getElementById('roomChild7Vides').style.display='none';
		document.getElementById('roomChild8Vides').style.display='none';
		break;
		
		case '4':
		document.getElementById('tdname_1Vides').style.display='block';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='block';
		document.getElementById('room3Vides').style.display='block';
		document.getElementById('room4Vides').style.display='block';
		document.getElementById('room5Vides').style.display='none';
		document.getElementById('room6Vides').style.display='none';
		document.getElementById('room7Vides').style.display='none';
		document.getElementById('room8Vides').style.display='none';
		
		document.getElementById('roomChild5Vides').style.display='none';
		document.getElementById('roomChild6Vides').style.display='none';
		document.getElementById('roomChild7Vides').style.display='none';
		document.getElementById('roomChild8Vides').style.display='none';
		break;
		
		case '5':
		document.getElementById('tdname_1Vides').style.display='block';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='block';
		document.getElementById('room3Vides').style.display='block';
		document.getElementById('room4Vides').style.display='block';
		document.getElementById('room5Vides').style.display='block';
		document.getElementById('room6Vides').style.display='none';
		document.getElementById('room7Vides').style.display='none';
		document.getElementById('room8Vides').style.display='none';
		
		document.getElementById('roomChild6Vides').style.display='none';
		document.getElementById('roomChild7Vides').style.display='none';
		document.getElementById('roomChild8Vides').style.display='none';
		break;
		
		case '6':
		document.getElementById('tdname_1Vides').style.display='block';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='block';
		document.getElementById('room3Vides').style.display='block';
		document.getElementById('room4Vides').style.display='block';
		document.getElementById('room5Vides').style.display='block';
		document.getElementById('room6Vides').style.display='block';
		document.getElementById('room7Vides').style.display='none';
		document.getElementById('room8Vides').style.display='none';
		
		document.getElementById('roomChild7Vides').style.display='none';
		document.getElementById('roomChild8Vides').style.display='none';
		break;
		
		case '7':
		document.getElementById('tdname_1Vides').style.display='block';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='block';
		document.getElementById('room3Vides').style.display='block';
		document.getElementById('room4Vides').style.display='block';
		document.getElementById('room5Vides').style.display='block';
		document.getElementById('room6Vides').style.display='block';
		document.getElementById('room7Vides').style.display='block';
		document.getElementById('room8Vides').style.display='none';
		
		document.getElementById('roomChild8Vides').style.display='none';
		break;
		
		case '8':
		document.getElementById('tdname_1Vides').style.display='block';
		document.getElementById('room1Vides').style.display='block';
		document.getElementById('room2Vides').style.display='block';
		document.getElementById('room3Vides').style.display='block';
		document.getElementById('room4Vides').style.display='block';
		document.getElementById('room5Vides').style.display='block';
		document.getElementById('room6Vides').style.display='block';
		document.getElementById('room7Vides').style.display='block';
		document.getElementById('room8Vides').style.display='block';
		break;
		
	}
}
function showRoomsChildren(roomNo,fld)
{
	switch(roomNo)
	{
		case '1':
		document.getElementById('childrenAge').style.display='block';
		document.getElementById('roomChild1').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('childrenAge').style.display='none';
			document.getElementById('roomChild1').style.display='none';
			break;
			
			case '1':
			document.getElementById('r1c1').style.display='block';
			document.getElementById('r1c2').style.display='none';
			document.getElementById('r1c3').style.display='none';
			break;
			
			case '2':
			document.getElementById('r1c1').style.display='block';
			document.getElementById('r1c2').style.display='block';
			document.getElementById('r1c3').style.display='none';
			break;
			
			case '3':
			document.getElementById('r1c1').style.display='block';
			document.getElementById('r1c2').style.display='block';
			document.getElementById('r1c3').style.display='block';
			break;
			
		}
		break;
		
		case '2':
		document.getElementById('childrenAge').style.display='block';
		document.getElementById('roomChild2').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild2').style.display='none';
			break;
			
			case '1':
			document.getElementById('r2c1').style.display='block';
			document.getElementById('r2c2').style.display='none';
			document.getElementById('r2c3').style.display='none';
			break;
			
			case '2':
			document.getElementById('r2c1').style.display='block';
			document.getElementById('r2c2').style.display='block';
			document.getElementById('r2c3').style.display='none';
			break;
			
			case '3':
			document.getElementById('r2c1').style.display='block';
			document.getElementById('r2c2').style.display='block';
			document.getElementById('r2c3').style.display='block';
			break;
			
		}
		break;
		
		case '3':
		document.getElementById('childrenAge').style.display='block';
		document.getElementById('roomChild3').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild3').style.display='none';
			break;
			
			case '1':
			document.getElementById('r3c1').style.display='block';
			document.getElementById('r3c2').style.display='none';
			document.getElementById('r3c3').style.display='none';
			break;
			
			case '2':
			document.getElementById('r3c1').style.display='block';
			document.getElementById('r3c2').style.display='block';
			document.getElementById('r3c3').style.display='none';
			break;
			
			case '3':
			document.getElementById('r3c1').style.display='block';
			document.getElementById('r3c2').style.display='block';
			document.getElementById('r3c3').style.display='block';
			break;
	
		}
		break;
		
		case '4':
		document.getElementById('childrenAge').style.display='block';
		document.getElementById('roomChild4').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild4').style.display='none';
			break;
			
			case '1':
			document.getElementById('r4c1').style.display='block';
			document.getElementById('r4c2').style.display='none';
			document.getElementById('r4c3').style.display='none';
			break;
			
			case '2':
			document.getElementById('r4c1').style.display='block';
			document.getElementById('r4c2').style.display='block';
			document.getElementById('r4c3').style.display='none';
			break;
			
			case '3':
			document.getElementById('r4c1').style.display='block';
			document.getElementById('r4c2').style.display='block';
			document.getElementById('r4c3').style.display='block';
			break;

		}
		break;
	}
}

function showRoomsChildrenVides(roomNo,fld)
{
	switch(roomNo)
	{
		case '1':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild1Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('childrenAgeVides').style.display='none';
			document.getElementById('roomChild1Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r1c1Vides').style.display='block';
			document.getElementById('r1c2Vides').style.display='none';
			document.getElementById('r1c3Vides').style.display='none';
			document.getElementById('r1c4Vides').style.display='none';
			document.getElementById('r1c5Vides').style.display='none';
			document.getElementById('r1c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r1c1Vides').style.display='block';
			document.getElementById('r1c2Vides').style.display='block';
			document.getElementById('r1c3Vides').style.display='none';
			document.getElementById('r1c4Vides').style.display='none';
			document.getElementById('r1c5Vides').style.display='none';
			document.getElementById('r1c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r1c1Vides').style.display='block';
			document.getElementById('r1c2Vides').style.display='block';
			document.getElementById('r1c3Vides').style.display='block';
			document.getElementById('r1c4Vides').style.display='none';
			document.getElementById('r1c5Vides').style.display='none';
			document.getElementById('r1c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r1c1Vides').style.display='block';
			document.getElementById('r1c2Vides').style.display='block';
			document.getElementById('r1c3Vides').style.display='block';
			document.getElementById('r1c4Vides').style.display='block';
			document.getElementById('r1c5Vides').style.display='none';
			document.getElementById('r1c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r1c1Vides').style.display='block';
			document.getElementById('r1c2Vides').style.display='block';
			document.getElementById('r1c3Vides').style.display='block';
			document.getElementById('r1c4Vides').style.display='block';
			document.getElementById('r1c5Vides').style.display='block';
			document.getElementById('r1c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r1c1Vides').style.display='block';
			document.getElementById('r1c2Vides').style.display='block';
			document.getElementById('r1c3Vides').style.display='block';
			document.getElementById('r1c4Vides').style.display='block';
			document.getElementById('r1c5Vides').style.display='block';
			document.getElementById('r1c6Vides').style.display='block';
			break;
			
		}
		break;
		
		case '2':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild2Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild2Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r2c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='none';
			document.getElementById('r2c3Vides').style.display='none';
			document.getElementById('r2c4Vides').style.display='none';
			document.getElementById('r2c5Vides').style.display='none';
			document.getElementById('r2c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r2c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='block';
			document.getElementById('r2c3Vides').style.display='none';
			document.getElementById('r2c4Vides').style.display='none';
			document.getElementById('r2c5Vides').style.display='none';
			document.getElementById('r2c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r2c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='block';
			document.getElementById('r2c3Vides').style.display='block';
			document.getElementById('r2c4Vides').style.display='none';
			document.getElementById('r2c5Vides').style.display='none';
			document.getElementById('r2c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r2c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='block';
			document.getElementById('r2c3Vides').style.display='block';
			document.getElementById('r2c4Vides').style.display='block';
			document.getElementById('r2c5Vides').style.display='none';
			document.getElementById('r2c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r2c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='block';
			document.getElementById('r2c3Vides').style.display='block';
			document.getElementById('r2c4Vides').style.display='block';
			document.getElementById('r2c5Vides').style.display='block';
			document.getElementById('r2c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r2c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='block';
			document.getElementById('r2c3Vides').style.display='block';
			document.getElementById('r2c4Vides').style.display='block';
			document.getElementById('r2c5Vides').style.display='block';
			document.getElementById('r2c6Vides').style.display='block';
			break;
			
		}
		break;
		
		case '3':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild3Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild3Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r3c1Vides').style.display='block';
			document.getElementById('r3c2Vides').style.display='none';
			document.getElementById('r3c3Vides').style.display='none';
			document.getElementById('r3c4Vides').style.display='none';
			document.getElementById('r3c5Vides').style.display='none';
			document.getElementById('r3c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r3c1Vides').style.display='block';
			document.getElementById('r3c2Vides').style.display='block';
			document.getElementById('r3c3Vides').style.display='none';
			document.getElementById('r3c4Vides').style.display='none';
			document.getElementById('r3c5Vides').style.display='none';
			document.getElementById('r3c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r3c1Vides').style.display='block';
			document.getElementById('r3c2Vides').style.display='block';
			document.getElementById('r3c3Vides').style.display='block';
			document.getElementById('r3c4Vides').style.display='none';
			document.getElementById('r3c5Vides').style.display='none';
			document.getElementById('r3c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r3c1Vides').style.display='block';
			document.getElementById('r3c2Vides').style.display='block';
			document.getElementById('r3c3Vides').style.display='block';
			document.getElementById('r3c4Vides').style.display='block';
			document.getElementById('r3c5Vides').style.display='none';
			document.getElementById('r3c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r3c1Vides').style.display='block';
			document.getElementById('r3c2Vides').style.display='block';
			document.getElementById('r3c3Vides').style.display='block';
			document.getElementById('r3c4Vides').style.display='block';
			document.getElementById('r3c5Vides').style.display='block';
			document.getElementById('r3c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r3c1Vides').style.display='block';
			document.getElementById('r3c2Vides').style.display='block';
			document.getElementById('r3c3Vides').style.display='block';
			document.getElementById('r3c4Vides').style.display='block';
			document.getElementById('r3c5Vides').style.display='block';
			document.getElementById('r3c6Vides').style.display='block';
			break;
			
			
		}
		break;
		
		case '4':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild4Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild4Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r4c1Vides').style.display='block';
			document.getElementById('r4c2Vides').style.display='none';
			document.getElementById('r4c3Vides').style.display='none';
			document.getElementById('r4c4Vides').style.display='none';
			document.getElementById('r4c5Vides').style.display='none';
			document.getElementById('r4c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r4c1Vides').style.display='block';
			document.getElementById('r4c2Vides').style.display='block';
			document.getElementById('r4c3Vides').style.display='none';
			document.getElementById('r4c4Vides').style.display='none';
			document.getElementById('r4c5Vides').style.display='none';
			document.getElementById('r4c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r4c1Vides').style.display='block';
			document.getElementById('r4c2Vides').style.display='block';
			document.getElementById('r4c3Vides').style.display='block';
			document.getElementById('r4c4Vides').style.display='none';
			document.getElementById('r4c5Vides').style.display='none';
			document.getElementById('r4c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r4c1Vides').style.display='block';
			document.getElementById('r4c2Vides').style.display='block';
			document.getElementById('r4c3Vides').style.display='block';
			document.getElementById('r4c4Vides').style.display='block';
			document.getElementById('r4c5Vides').style.display='none';
			document.getElementById('r4c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r4c1Vides').style.display='block';
			document.getElementById('r4c2Vides').style.display='block';
			document.getElementById('r4c3Vides').style.display='block';
			document.getElementById('r4c4Vides').style.display='block';
			document.getElementById('r4c5Vides').style.display='block';
			document.getElementById('r4c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r4c1Vides').style.display='block';
			document.getElementById('r4c2Vides').style.display='block';
			document.getElementById('r4c3Vides').style.display='block';
			document.getElementById('r4c4Vides').style.display='block';
			document.getElementById('r4c5Vides').style.display='block';
			document.getElementById('r4c6Vides').style.display='block';
			break;
			
			
		}
		break;
		
		case '5':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild5Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild5Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r5c1Vides').style.display='block';
			document.getElementById('r5c2Vides').style.display='none';
			document.getElementById('r5c3Vides').style.display='none';
			document.getElementById('r5c4Vides').style.display='none';
			document.getElementById('r5c5Vides').style.display='none';
			document.getElementById('r5c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r5c1Vides').style.display='block';
			document.getElementById('r5c2Vides').style.display='block';
			document.getElementById('r5c3Vides').style.display='none';
			document.getElementById('r5c4Vides').style.display='none';
			document.getElementById('r5c5Vides').style.display='none';
			document.getElementById('r5c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r5c1Vides').style.display='block';
			document.getElementById('r5c2Vides').style.display='block';
			document.getElementById('r5c3Vides').style.display='block';
			document.getElementById('r5c4Vides').style.display='none';
			document.getElementById('r5c5Vides').style.display='none';
			document.getElementById('r5c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r5c1Vides').style.display='block';
			document.getElementById('r5c2Vides').style.display='block';
			document.getElementById('r5c3Vides').style.display='block';
			document.getElementById('r5c4Vides').style.display='block';
			document.getElementById('r5c5Vides').style.display='none';
			document.getElementById('r5c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r5c1Vides').style.display='block';
			document.getElementById('r5c2Vides').style.display='block';
			document.getElementById('r5c3Vides').style.display='block';
			document.getElementById('r5c4Vides').style.display='block';
			document.getElementById('r5c5Vides').style.display='block';
			document.getElementById('r5c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r5c1Vides').style.display='block';
			document.getElementById('r5c2Vides').style.display='block';
			document.getElementById('r5c3Vides').style.display='block';
			document.getElementById('r5c4Vides').style.display='block';
			document.getElementById('r5c5Vides').style.display='block';
			document.getElementById('r5c6Vides').style.display='block';
			break;
			
			
		}
		break;
		
		case '6':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild6Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild6Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r6c1Vides').style.display='block';
			document.getElementById('r6c2Vides').style.display='none';
			document.getElementById('r6c3Vides').style.display='none';
			document.getElementById('r6c4Vides').style.display='none';
			document.getElementById('r6c5Vides').style.display='none';
			document.getElementById('r6c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r6c1Vides').style.display='block';
			document.getElementById('r6c2Vides').style.display='block';
			document.getElementById('r6c3Vides').style.display='none';
			document.getElementById('r6c4Vides').style.display='none';
			document.getElementById('r6c5Vides').style.display='none';
			document.getElementById('r6c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r6c1Vides').style.display='block';
			document.getElementById('r6c2Vides').style.display='block';
			document.getElementById('r6c3Vides').style.display='block';
			document.getElementById('r6c4Vides').style.display='none';
			document.getElementById('r6c5Vides').style.display='none';
			document.getElementById('r6c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r6c1Vides').style.display='block';
			document.getElementById('r6c2Vides').style.display='block';
			document.getElementById('r6c3Vides').style.display='block';
			document.getElementById('r6c4Vides').style.display='block';
			document.getElementById('r6c5Vides').style.display='none';
			document.getElementById('r6c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r6c1Vides').style.display='block';
			document.getElementById('r6c2Vides').style.display='block';
			document.getElementById('r6c3Vides').style.display='block';
			document.getElementById('r6c4Vides').style.display='block';
			document.getElementById('r6c5Vides').style.display='block';
			document.getElementById('r6c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r6c1Vides').style.display='block';
			document.getElementById('r6c2Vides').style.display='block';
			document.getElementById('r6c3Vides').style.display='block';
			document.getElementById('r6c4Vides').style.display='block';
			document.getElementById('r6c5Vides').style.display='block';
			document.getElementById('r6c6Vides').style.display='block';
			break;
			
			
		}
		break;
		
		case '7':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild7Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild7Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r7c1Vides').style.display='block';
			document.getElementById('r7c2Vides').style.display='none';
			document.getElementById('r7c3Vides').style.display='none';
			document.getElementById('r7c4Vides').style.display='none';
			document.getElementById('r7c5Vides').style.display='none';
			document.getElementById('r7c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r7c1Vides').style.display='block';
			document.getElementById('r7c2Vides').style.display='block';
			document.getElementById('r7c3Vides').style.display='none';
			document.getElementById('r7c4Vides').style.display='none';
			document.getElementById('r7c5Vides').style.display='none';
			document.getElementById('r7c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r7c1Vides').style.display='block';
			document.getElementById('r7c2Vides').style.display='block';
			document.getElementById('r7c3Vides').style.display='block';
			document.getElementById('r7c4Vides').style.display='none';
			document.getElementById('r7c5Vides').style.display='none';
			document.getElementById('r7c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r7c1Vides').style.display='block';
			document.getElementById('r7c2Vides').style.display='block';
			document.getElementById('r7c3Vides').style.display='block';
			document.getElementById('r7c4Vides').style.display='block';
			document.getElementById('r7c5Vides').style.display='none';
			document.getElementById('r7c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r7c1Vides').style.display='block';
			document.getElementById('r7c2Vides').style.display='block';
			document.getElementById('r7c3Vides').style.display='block';
			document.getElementById('r7c4Vides').style.display='block';
			document.getElementById('r7c5Vides').style.display='block';
			document.getElementById('r7c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r7c1Vides').style.display='block';
			document.getElementById('r7c2Vides').style.display='block';
			document.getElementById('r7c3Vides').style.display='block';
			document.getElementById('r7c4Vides').style.display='block';
			document.getElementById('r7c5Vides').style.display='block';
			document.getElementById('r7c6Vides').style.display='block';
			break;
			
			
		}
		break;
		
		case '8':
		document.getElementById('childrenAgeVides').style.display='block';
		document.getElementById('roomChild8Vides').style.display='block';
		switch(fld.value)
		{
			case '0':
			document.getElementById('roomChild8Vides').style.display='none';
			break;
			
			case '1':
			document.getElementById('r8c1Vides').style.display='block';
			document.getElementById('r8c2Vides').style.display='none';
			document.getElementById('r8c3Vides').style.display='none';
			document.getElementById('r8c4Vides').style.display='none';
			document.getElementById('r8c5Vides').style.display='none';
			document.getElementById('r8c6Vides').style.display='none';
			break;
			
			case '2':
			document.getElementById('r8c1Vides').style.display='block';
			document.getElementById('r8c2Vides').style.display='block';
			document.getElementById('r8c3Vides').style.display='none';
			document.getElementById('r8c4Vides').style.display='none';
			document.getElementById('r8c5Vides').style.display='none';
			document.getElementById('r8c6Vides').style.display='none';
			break;
			
			case '3':
			document.getElementById('r8c1Vides').style.display='block';
			document.getElementById('r8c2Vides').style.display='block';
			document.getElementById('r8c3Vides').style.display='block';
			document.getElementById('r8c4Vides').style.display='none';
			document.getElementById('r8c5Vides').style.display='none';
			document.getElementById('r8c6Vides').style.display='none';
			break;
			
			case '4':
			document.getElementById('r8c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='block';
			document.getElementById('r8c3Vides').style.display='block';
			document.getElementById('r8c4Vides').style.display='block';
			document.getElementById('r8c5Vides').style.display='none';
			document.getElementById('r8c6Vides').style.display='none';
			break;
			
			case '5':
			document.getElementById('r8c1Vides').style.display='block';
			document.getElementById('r2c2Vides').style.display='block';
			document.getElementById('r8c3Vides').style.display='block';
			document.getElementById('r8c4Vides').style.display='block';
			document.getElementById('r8c5Vides').style.display='block';
			document.getElementById('r8c6Vides').style.display='none';
			break;
			
			case '6':
			document.getElementById('r8c1Vides').style.display='block';
			document.getElementById('r8c2Vides').style.display='block';
			document.getElementById('r8c3Vides').style.display='block';
			document.getElementById('r8c4Vides').style.display='block';
			document.getElementById('r8c5Vides').style.display='block';
			document.getElementById('r8c6Vides').style.display='block';
			break;
			
		}
		break;
		
	}
}
/* http://www.time4trip.in/lib/ht_search.js */

      var now = new Date();
      now.setDate(now.getDate()-1);

      function getDateString1(y_obj,m_obj,d_obj)
      {
                var y= now.getYear();
                if (y < 1900)
		{
                   y += 1900;
                }
 		var m = m_obj.options[m_obj.selectedIndex].value;
 		m=m;
 		var d = d_obj.options[d_obj.selectedIndex].value;
 		if (y=="" || m=="") { return null; }
 		if (d=="") { d=1; }
 		m=Number(m)+1;
 		return str= y+'-'+m+'-'+d;
     }

   var cal51 = new CalendarPopup();
         cal51.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
         cal51.setReturnFunction("setMultipleValues51");
         function setMultipleValues51(y,m,d)
         {
   	    document.searchform.strCheckinmonth.value=m;
   	    document.searchform.strCheckindate.value=d;

          }

         function getmonth51()
           {
                   var month1=Number(document.searchform.strCheckinmonth);

         		return month1;
           }



           var cal52 = new CalendarPopup();
          	cal52.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
        	cal52.setReturnFunction("setMultipleValues52");
        	function setMultipleValues52(y,m,d)
   	    {


        		document.searchform.strCheckoutmonth.value=m;
        		document.searchform.strCheckoutdate.value=d;

        	}

          function getmonthout52()
          {
        		var month1=Number(document.searchform.strCheckoutmonth)+1;
        		return month1;
       }
       function search()
       {
       	var ckinday = document.searchform.CheckInDate.value;
	   	var ckinmonth = document.searchform.CheckInMonth.value;
	   	var ckinyear = document.searchform.CheckInYear.value;
		document.searchform.checkIn.value = ckinmonth + "/" + ckinday + "/" + ckinyear;
		//alert(ckinmonth + "/" + ckinday + "/" + ckinyear);
	   	var ckoutday = document.searchform.CheckOutDate.value;
	   	var ckoutmonth = document.searchform.CheckOutMonth.value;
	   	var ckoutyear = document.searchform.CheckOutYear.value;
		document.searchform.checkOut.value = ckoutmonth + "/" + ckoutday + "/" + ckoutyear;
		//alert(ckoutmonth + "/" + ckoutday + "/" + ckoutyear);
       }
	   
	    function showHideTd(fld)
       {
       	switch(fld.value)
       	{
       		case '0':
       		document.getElementById('child').style.display='none';
       		document.getElementById('child1').style.display='none';
       		document.getElementById('child2').style.display='none';
       		document.getElementById('child3').style.display='none';
       		document.getElementById('child4').style.display='none';
       		document.getElementById('child5').style.display='none';
       		document.getElementById('child6').style.display='none';
       		break;
       		case '1':
       		document.getElementById('child').style.display='block';
       		document.getElementById('child1').style.display='block';
       		document.getElementById('child2').style.display='none';
       		document.getElementById('child3').style.display='none';
       		document.getElementById('child4').style.display='none';
       		document.getElementById('child5').style.display='none';
       		document.getElementById('child6').style.display='none';
       		break;
       		case '2':
       		document.getElementById('child').style.display='block';
       		document.getElementById('child1').style.display='block';
       		document.getElementById('child2').style.display='block';
       		document.getElementById('child3').style.display='none';
       		document.getElementById('child4').style.display='none';
       		document.getElementById('child5').style.display='none';
       		document.getElementById('child6').style.display='none';
       		break;
       		case '3':
       		document.getElementById('child').style.display='block';
       		document.getElementById('child1').style.display='block';
       		document.getElementById('child2').style.display='block';
       		document.getElementById('child3').style.display='block';
       		document.getElementById('child4').style.display='none';
       		document.getElementById('child5').style.display='none';
       		document.getElementById('child6').style.display='none';
       		break;
       		case '4':
       		document.getElementById('child').style.display='block';
       		document.getElementById('child1').style.display='block';
       		document.getElementById('child2').style.display='block';
       		document.getElementById('child3').style.display='block';
       		document.getElementById('child4').style.display='block';
       		document.getElementById('child5').style.display='none';
       		document.getElementById('child6').style.display='none';
       		break;
       		case '5':
       		document.getElementById('child').style.display='block';
       		document.getElementById('child1').style.display='block';
       		document.getElementById('child2').style.display='block';
       		document.getElementById('child3').style.display='block';
       		document.getElementById('child4').style.display='block';
       		document.getElementById('child5').style.display='block';
       		document.getElementById('child6').style.display='none';
       		break;
       		case '6':
       		document.getElementById('child').style.display='block';
       		document.getElementById('child1').style.display='block';
       		document.getElementById('child2').style.display='block';
       		document.getElementById('child3').style.display='block';
       		document.getElementById('child4').style.display='block';
       		document.getElementById('child5').style.display='block';
       		document.getElementById('child6').style.display='block';
       		break;
       	}
       }

function rateType()
{
  var noAdults = document.packagesearchform.strNoAdults.value;

  if(noAdults == 1)
  {
    document.getElementById('single').style.display='block';
    document.getElementById('twin').style.display='none';
    document.getElementById('triple').style.display='none';
    document.getElementById('mul4').style.display='none';
    document.getElementById('mul5').style.display='none';
    document.getElementById('mul6').style.display='none';
    document.getElementById('mul7').style.display='none';
  }
  else if(noAdults == 2)
  {
    document.getElementById('twin').style.display='block';
    document.getElementById('single').style.display='none';
    document.getElementById('triple').style.display='none';
    document.getElementById('mul4').style.display='none';
    document.getElementById('mul5').style.display='none';
    document.getElementById('mul6').style.display='none';
    document.getElementById('mul7').style.display='none';
  }
  else if(noAdults == 3)
  {
    document.getElementById('triple').style.display='block';
    document.getElementById('twin').style.display='none';
    document.getElementById('single').style.display='none';
    document.getElementById('mul4').style.display='none';
    document.getElementById('mul5').style.display='none';
    document.getElementById('mul6').style.display='none';
    document.getElementById('mul7').style.display='none';
  }
  else if(noAdults == 4)
  {
    document.getElementById('mul4').style.display='block';
    document.getElementById('triple').style.display='none';
    document.getElementById('twin').style.display='none';
    document.getElementById('single').style.display='none';
    document.getElementById('mul5').style.display='none';
    document.getElementById('mul6').style.display='none';
    document.getElementById('mul7').style.display='none';
  }
  else if(noAdults == 5)
  {
    document.getElementById('mul4').style.display='none';
    document.getElementById('triple').style.display='none';
    document.getElementById('twin').style.display='none';
    document.getElementById('single').style.display='none';
    document.getElementById('mul4').style.display='none';
    document.getElementById('mul5').style.display='block';
    document.getElementById('mul6').style.display='none';
    document.getElementById('mul7').style.display='none';
  }
  else if(noAdults == 6)
  {
    document.getElementById('mul4').style.display='none';
    document.getElementById('triple').style.display='none';
    document.getElementById('twin').style.display='none';
    document.getElementById('single').style.display='none';
    document.getElementById('mul4').style.display='none';
    document.getElementById('mul5').style.display='none';
    document.getElementById('mul6').style.display='block';
    document.getElementById('mul7').style.display='none';
  }
  else if(noAdults == 7)
  {
    document.getElementById('mul4').style.display='none';
    document.getElementById('triple').style.display='none';
    document.getElementById('twin').style.display='none';
    document.getElementById('single').style.display='none';
    document.getElementById('mul4').style.display='none';
    document.getElementById('mul5').style.display='none';
    document.getElementById('mul6').style.display='none';
    document.getElementById('mul7').style.display='block';
  }
}

function NewWindow(mypage,myname)
 {
  var w = screen.width/2;
  var h = screen.height/2;
  LeftPosition = (screen.width) ? ((screen.width-w)/2+200) : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable=0';
  MM_openBrWindow(mypage,myname,settings)
 }
http://www.google.com/coop/cse/brand?form=cse-search-box<=en

(function() {
var f = document.getElementById('cse-search-box');
if (!f) {
f = document.getElementById('searchbox_demo');
}
if (f && f.q) {
var q = f.q;
var n = navigator;
var l = location;
var su = function () {
var u = document.createElement('input');
var v = document.location.toString();
var existingSiteurl = /(?:[?&]siteurl=)([^&#]*)/.exec(v);
if (existingSiteurl) {
v = decodeURI(existingSiteurl[1]);
}
var delimIndex = v.indexOf('://');
if (delimIndex >= 0) {
v = v.substring(delimIndex + '://'.length, v.length);
}
u.name = 'siteurl';
u.value = v;
u.type = 'hidden';
f.appendChild(u);
};
if (n.appName == 'Microsoft Internet Explorer') {
var s = f.parentNode.childNodes;
for (var i = 0; i < s.length; i++) {
        if (s[i].nodeName == 'SCRIPT'
            && s[i].attributes['src'].nodeValue == unescape('http:\x2F\x2Fwww.google.com\x2Fcoop\x2Fcse\x2Fbrand?form=cse-search-box\x26lang=en')) {
          su();
          break;
        }
      }
    } else {
      su();
    }

    
    if (n.platform == 'Win32') {
      q.style.cssText = 'border: 1px solid #7e9db9; padding: 2px;';
    }

    
    if (window.history.navigationMode) {
      window.history.navigationMode = 'compatible';
    }

    var b = function() {
      if (q.value == '') {
        q.style.background = '#FFFFFF url(http:\x2F\x2Fwww.google.com\x2Fcse\x2Fintl\x2Fen\x2Fimages\x2Fgoogle_custom_search_watermark.gif) left no-repeat';
      }
    };

    var f = function() {
      q.style.background = '#ffffff';
    };

    q.onfocus = f;
    q.onblur = b;

    
    if (!/[&?]q=[^&]/.test(l.search)) {
      b();
    }
  }
})();



var bookmarkurl="http://www.time4trip.in"
var bookmarktitle="Time4Trip."

function addbookmark()
{
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


/*
addDays(document.searchform.strCheckindate, tomonth);
addDays(document.searchform.strCheckoutdate, tomonth);
    var now = new Date();
    var day = now.getDate();
    var month = now.getMonth()+1; // numbered from 0
    var year = now.getFullYear();

    var startdate=new Date(year,month-1,day+1);
    var enddate=new Date(year,month-1,day+2);
    var cardate=new Date(year,month-1,day+2);
    var flightdepdate=new Date(year,month-1,day+15);
    var flightretdate=new Date(year,month-1,day+17);

    //document.AvailRequester.departureMonth.value=flightdepdate.getMonth();
    //document.AvailRequester.departureDay.value=flightdepdate.getDate();
    //document.AvailRequester.returnMonth.value=flightretdate.getMonth();
    //document.AvailRequester.returnDay.value=flightretdate.getDate();

    document.searchform.strCheckindate.value = startdate.getDate();
    document.searchform.strCheckinmonth.value = startdate.getMonth()+1;
    document.searchform.strCheckinyear.value = startdate.getFullYear();

    document.searchform.strCheckoutdate.value = enddate.getDate();
    document.searchform.strCheckoutmonth.value = enddate.getMonth()+1;
    document.searchform.strCheckoutyear.value = enddate.getFullYear();


    var indicator=0;
*/

      

