		//setRange("conf",daysAfter(0),"");
		
		function benefits(url) 
		{ 
			window.open(url,'Medi','width=810,height=620,left=100,top=50,screenX=0,screenY=80'); 
		}
		function showInsurance(pageName)
		{
				win = open(pageName, 'InsuranceScheme', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=550,left = 180,top = 80');
		}
		function enableSDOB()
		{
				var NOA = document.getElementById('cmbAdults').value;
				if(parseInt(NOA)<2)
				{
					document.frmATC.txtSDob.disabled= true;
					document.frmATC.txtSDob.value="N/A";      
			 	 }
				else
				{
					document.frmATC.txtSDob.disabled= false;
					if(document.frmATC.txtSDob.value=="N/A")
					{
						document.frmATC.txtSDob.value="dd/mm/yyyy";
					}
				}
		}		
		function Validates()
		{
			 var strDDate = document.getElementById('txtDepartDate').value;
			 var strRDate = document.getElementById('txtReturnDate').value;
			 var strFDate = document.getElementById('txtFDob').value;
			 var strSDate = document.getElementById('txtSDob').value;
			 var NOA = document.getElementById('cmbAdults').value;
			 
			 var country = document.getElementById('cmbCountry').value;
			 if(country=="")
			 {
				alert('Please select a country !');
				document.getElementById('cmbCountry').focus();
				return false;
			 }
			
			
			 if (strDDate=="")
			 {
				alert('Please enter departure date !');
				return false;
			 }
			 else
			 {
					if (!isDate(document.frmATC.txtDepartDate.value, 'DepatureDate'))
					{
						return false;
					}
					if (!isGraterThanToday('txtDepartDate'))
					{
						alert('Departure Date has to be greater than Current Date');
						return false;
					}
					
									
			 }
			 if (strRDate=="")
			 {
				alert('Please enter return date !');
				return false;
			 }
			 else
			 {
					if(!isDate(document.frmATC.txtReturnDate.value,'ReturnDate'))
					{
						return false;
					}
					if(!isGraterThanToday('txtReturnDate'))
					{
						alert('Arrival Date has to be greater than Current Date');
						return false;
					}
					
			 }
			//triming
				var str = document.frmATC.txtDepartDate.value;
				document.frmATC.txtDepartDate.value =trim(str);
				var str = document.frmATC.txtReturnDate.value;
				document.frmATC.txtReturnDate.value =trim(str);
				
				var sd1 = document.frmATC.txtDepartDate.value.split("/");
				var sd2 = document.frmATC.txtReturnDate.value.split("/");
					
				var x = new Date(sd1[2] ,sd1[1] -1 ,sd1[0] );
				var y = new Date(sd2[2] ,sd2[1] -1 ,sd2[0] );

				var difference = Date.UTC(y.getYear(),y.getMonth(),y.getDate(),0,0,0) - Date.UTC(x.getYear(),x.getMonth(),x.getDate(),0,0,0);
				
				var nights = difference/1000/60/60/24;
				
				if( nights < 0)
				{
					alert("Return date has to be greater than Departure date");
					return false;
				
				}
				
				
			 if (strFDate=="")
			 {
				alert('Please enter DOB for Traveller 1 !');
				return false;
			 }
			 else
			 {
					if(!isDate(document.frmATC.txtFDob.value,'Traveller1DOB'))
					{
						return false;
					}
					if(!ValiDate(strFDate,'1  ' ))
					{
						return false;
					}
					
			 }
			 
			 if(NOA>1)
			 {
				if (strSDate=="")
				{
					alert('Please enter DOB for Traveller 2 !');
					return false;
				}
				else
				{
						if(!isDate(document.frmATC.txtSDob.value,'Traveller2DOB'))
						{
							return false;
						}
						if(!ValiDate(strSDate,'2  ' ))
						{
							return false;
						}
						
				}
			 }
		}
						
		function DepRetDate(sd,ed) 
		{ 
			
			var s=sd.split('/') 
			var e=ed.split('/') 
			//create new date objects using constructed arrays 
			var startdate =new Date(s[2],s[0],s[1]); 
			var enddate=new Date(e[2],e[0],e[1]); 


			//run the comparison 
			if(startdate.getTime()> enddate.getTime()) 
			{ 
				alert("Return date has to be greater than departure date !"); 
				return false; 
			} 
			else 
				return true; 
		}
			
		function ValiDate(oTextBox,TravNum) 
		{ 
			
			var Tdate=new Date();
			var sd1=Tdate.getUTCDate  ()+ "/" + (Tdate.getUTCMonth ()+ 1 )+"/" + Tdate.getUTCFullYear  ()
			var i=oTextBox.split('/') 
			var ss=sd1.split('/') 

			
			var y = new Date(ss[2] ,ss[1] -1 ,ss[0]);
			var x = new Date(i[2] ,i[1] -1 ,i[0] );
			
			
				var difference = Date.UTC(y.getUTCFullYear(),y.getUTCMonth(),y.getUTCDate(),0,0,0) - Date.UTC(x.getUTCFullYear(),x.getUTCMonth(),x.getUTCDate(),0,0,0);
				
				var years = difference/1000/60/60/24/30/12;
				//if less than 2 years invalid
				
				if( years < 21)
				{
					alert("Traveller "+TravNum+ " age should be more than 21 Years !");
					return false;
				
				}
				else
				{
					return true;
				}
		}

		function callCalendar(conf_name,target_field,ref_field,default_date,hoder_id,dx,dy,mode)
		{
				//debugger;
				xcModPath="script";
				xcWindowTemplate="/script/xc2_template.html";
				xcDateFormat ='dd/mm/yyyy';
				setRange("conf",daysAfter(0),"");
				

				
				//setting the start date
				var strDate = document.getElementById('txtDepartDate').value;
				if(strDate != 0 && target_field.id != 'txtDepartDate')
				{
					setRange("conf",strDate,"");
				}
				
				showCalendar("conf",target_field,ref_field,default_date,hoder_id,dx,dy,mode);
				target_field.className="date";

 		}
	 		
	 		// for the hyperlink of second traveler DOB
 		function callCalendar_NorangeMod(conf_name,target_field,ref_field,default_date,hoder_id,dx,dy,mode)
		{

			var NOA = document.getElementById('cmbAdults').value;
	
			if(NOA<2)
			{
					alert('only for two travellers, you have selected only one');
					return;
			}
			callCalendar_Norange(conf_name,target_field,ref_field,default_date,hoder_id,dx,dy,mode);
			
		}
 		function callCalendar_Norange(conf_name,target_field,ref_field,default_date,hoder_id,dx,dy,mode)
		{
				//debugger;
				xcModPath="script";
				xcWindowTemplate="/script/xc2_template.html";
				
				
				xcDateFormat ='dd/mm/yyyy';
				//setRange("conf",daysAfter(15),"");
				setRange("conf", "", daysBefore(1));
				
				//setting the start date
				//var strDate = document.getElementById('txtDepartDate').value;
				//if(strDate != 0 && target_field.id != 'txtDepartDate')
				//{
				//	setRange("conf",strDate,"");
				//}
				var strDate="";
				//setRange("conf",strDate,"");
				showCalendar("conf",target_field,ref_field,default_date,hoder_id,dx,dy,mode);
				target_field.className="date";
 		}
			//xcDateFormat ='dd/mm/yyyy';
			//setRange("conf",daysAfter(0),"");
			
		function setDateFrom()
		{
				var datefrom1 = document.frmATC.setDate.value.split("/");
				document.frmATC.txtDepartDate.value = datefrom1[1] + "/" + datefrom1[0] + "/" + datefrom1[2];
		}

		function Today()
		{
				var dd = new Date();
				return((dd.getMonth()+1) + "/" + dd.getDate() + "/" + dd.getFullYear());
		}
		
		function showDateCal1()
		{
				var controlStr ="AppendOrReplace=Replace;AppendChar=';';CloseOnSelect=Yes;ReturnData=Date;Title=Calendar;InlineX=500;InlineY=270;CurrentDate=Today;SelectAfter=Today;SelectBefore=\"\";AllowWeekends=Yes;Resizable=No;CallFunction=setDateFrom();PopupX=200;PopupY=220;Nav=Yes;SmartNav=Yes;Fix=Yes;";show_calendar('frmATC.setDate',null,null, null,null, controlStr);
		}

		function setDateTo()
		{
				var dateto = document.frmATC.setDate.value.split("/");
				document.frmATC.txtReturnDate.value = dateto[1] + "/" + dateto[0] +  "/" + dateto[2];
		}

		function showDateCal2()
		{
				var controlStr ="AppendOrReplace=Replace;AppendChar=';';CloseOnSelect=Yes;ReturnData=Date;Title=Calendar;InlineX=500;InlineY=270;CurrentDate=Today;SelectAfter=Today;SelectBefore=\"\";AllowWeekends=Yes;Resizable=No;CallFunction=setDateTo();PopupX=200;PopupY=220;Nav=Yes;SmartNav=Yes;Fix=Yes;";show_calendar('frmATC.setDate',null,null, null,null, controlStr);
		}
			
		function trim(inputString)
		 {
				// Removes leading and trailing spaces from the passed string. Also removes
				// consecutive spaces and replaces it with one space. If something besides
				// a string is passed in (null, custom object, etc.) then return the input.
				if (typeof inputString != "string") { return inputString; }
				var retValue = inputString;
				var ch = retValue.substring(0, 1);
				while (ch == " ") 
				{
					 // Check for spaces at the beginning of the string
					retValue = retValue.substring(1, retValue.length);
					ch = retValue.substring(0, 1);
				}
				ch = retValue.substring(retValue.length-1, retValue.length);
				while (ch == " ") 
				{	// Check for spaces at the end of the string
					retValue = retValue.substring(0, retValue.length-1);
					ch = retValue.substring(retValue.length-1, retValue.length);
				}
				while (retValue.indexOf("  ") != -1) 
				{	// Note that there are two spaces in the string - look for multiple spaces within the string
					retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
				}
				return retValue; // Return the trimmed string back to the user
		}
			
		function checkDate(txtBoxName, fieldName)
		{
				//debugger;
				var dtStr =document.getElementById(txtBoxName).value;
				document.getElementById(txtBoxName).value =trim(dtStr);
				dtStr =trim(dtStr);
				if((fieldName =='ReturnDate') && (document.frmATC.ddlTicketType.selectedIndex != 1))
				{
					document.frmATC.txtReturnDate.value = "";
				}
				
				if(!isDate(dtStr.toString(), fieldName))
				{
					return false;
				}
				else
				{
					if(!isGraterThanToday(txtBoxName))
					{
						alert(fieldName+' is less than Today');
						return false;
					}
				}
				
		}
		function isGraterThanToday(txtBoxName)
		{
				
				var td = Today();
				var sd1 = td.split("/");
				var sd2 = document.getElementById(txtBoxName).value.split("/");
					
				var x = new Date(sd1[2] ,sd1[0] -1 ,sd1[1] );
				var y = new Date(sd2[2] ,sd2[1] -1 ,sd2[0] );

				var difference = Date.UTC(y.getYear(),y.getMonth(),y.getDate(),0,0,0) - Date.UTC(x.getYear(),x.getMonth(),x.getDate(),0,0,0);
				var nights = difference/1000/60/60/24;
				if( nights < 0)
				{
					//alert("End date has to be grater than Start date");
					return false;
				}
				return true;
		}
			
			//----------------------  Date Validation ----------------------------------------------------------------
			/**
			* DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
			*/
			// Declaring valid date character, minimum year and maximum year
			var dtCh= "/";
			var minYear=1900;
			var maxYear=2100;

			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 isDate(dtStr, fieldName){
				var temp =new String(dtStr);
				dtStr=temp.substring(0,10);
				temp=temp.substring(10);
				/*
				if (temp.lenght!=0)
				{
					if (temp!= " 00:00:00")
					{
						alert("Ilegal Charaters in "+fieldName);
					}
				}*/
				var daysInMonth = DaysArray(12)
				var pos1=dtStr.indexOf(dtCh)
				var pos2=dtStr.indexOf(dtCh,pos1+1)
				var strDay=dtStr.substring(0,pos1)
				var strMonth=dtStr.substring(pos1+1,pos2)
				var strYear=dtStr.substring(pos2+1)
				strYr=strYear
				if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
				if (strMonth.charAt(0)=="0" && strMonth.length>1) 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 (pos1==-1 || pos2==-1){
					alert("The date format should be : dd/mm/yyyy in "+fieldName )
					return false;
				}
				if (strMonth.length<1 || month<1 || month>12){
					alert("Please enter a valid month for "+fieldName)
					return false;
				}
				if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
					alert("Please enter a valid day for "+fieldName)
					return false;
				}
				if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
					alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear+" for "+fieldName)
					return false;
				}
				if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
				{
					alert("Please enter a valid date for "+fieldName)
					return false;
				}
			return true;
			}
			function ChkOnewayClicked()
			{
				if(document.frmATC.ddlTicketType.value == 1)
				{
					document.frmATC.txtReturnDate.value = "";
				}
			}
			var objWindow ;
			
			function termsLink()
			{ 
					
					window.open("../client/Brochure.pdf",'bro','width=810,height=620,left=100,top=50,screenX=0,screenY=80, resizable=1'); 
			//	var win = window.open("./downloads/brochure.pdf", "HotelInfo", "left=50, top=50, width=700, height=600, scrollbars=1, resizable=1"); 
			}
			function textChange(object)
			{
				document.getElementById(object).className="date";
			}
			
			function focusout(object)
			{
				if(document.getElementById(object).value=="")
				{
					document.getElementById(object).value="dd/mm/yyyy"
					document.getElementById(object).className="datetext";
				}
			}