// JScript File

var LoadXml;
var LoadTrustXml;
var ci="ci"
var co="co";
var Hidd="TBLRIT";
var Id="HL"+Hidd;
var totalguest=5;
//ReadXml(Id)
Read(Id)
//ManipulateXML(Id);
 var ArrDate=document.f1.month.value;
   var DepDate=document.f1.monthOut.value;
   var ArArr=new Array();
   var DpArr=new Array();
   ArArr=ArrDate.split(":");
   DpArr=DepDate.split(":");
   
  
  // alert(ArArr[0]);
  // alert(ArArr[1]);
   
  // get_date(document.f1.dateOut);
  // alert("1");
   //odddate_load(ArArr[1],ArArr[0],document.f1.date)

  var mm=myscriptTime.getMonth();
  var yy=myscriptTime.getFullYear();
  var dd=myscriptTime.getDate();
   
  
  //loadDate();
  function disp_div()
  {

 if(document.getElementById("Opt").style.display=='none')
{
var w=document.getElementById("Opt").style.display='block';
var q=document.getElementById("Exp");
q.src='images/minus1.jpg';
}
else
{
var w=document.getElementById("Opt").style.display='none'//visibility='hidden';
var q=document.getElementById("Exp");
q.src='images/plus1.jpg';
}
  CSBfleXcroll('mycustomscroll1');
  }
  
  
  
 
 function getMonthName(s)
            {
            if(s==0)
            return "JAN";
             if(s==1)
            return "FEB";
             if(s==2)
            return "MAR";
             if(s==3)
            return "APR";
             if(s==4)
            return "MAY";
            if(s==5)
            return "JUN";
             if(s==6)
            return "JUL";
              if(s==7)
            return "AUG";
            
             if(s==8)
            return "SEP";
             if(s==9)
            return "OCT";
            
             if(s==10)
            return "NOV";
            
             if(s==11)
            return "DEC";
            
             
            }
     
           
          
       
            
   
            
            	function Char_Check(Char_To_Be_Checked,Valid_Char)
				{
					checkStr = Char_To_Be_Checked;
					checkOK1=Valid_Char;
					var flag=0;  
					var allValid = true;
					for (i = 0;  i < checkStr.length;  i++)
					{
						ch = checkStr.charAt(i);
						for (j = 0;  j < checkOK1.length;  j++)
						{
						//alert(ch+" "+checkOK1.charAt(j));
						if (ch == checkOK1.charAt(j))
						{
						    flag=1;
							break;
						}
						}
						
						
						
					}
					if (flag==1)
						{
						allValid = false;
						//break;
						}
						
					return allValid;

				}
				
				 function get_Month_Number(monthnumber)
     {
      var MonName;
      switch(monthnumber)
       {
        case 1:
              MonName="01";
              break;
        case 2:
              MonName="02";
              break;
        case 3:
              MonName="03";
              break;
        case 4:
              MonName="04";
              break;
        case 5:
              MonName="05";
              break;
        case 6:
              MonName="06";
              break;
        case 7:
              MonName="07";
              break;
        case 8:
              MonName="08";
              break;
        case 9:
              MonName="09";
              break;
        case 10:
              MonName="10";
              break;
        case 11:
              MonName="11";
              break;
        case 12:
              MonName="12";
              break;
       }
      return MonName;
     }
     
     function get_date_number(dateid)
     {
     var get_value;
           var get_number;
           get_number=dateid.length;
          if(get_number==1)
          {
           get_value="0"+dateid;
          }
          else
          {
          get_value=dateid;
          }
        return get_value;
     }
				
            function opentrust()
            {
             var totoccupancy;
            var url;
            var ArrDate=document.f1.month;
            var DepDate=document.f1.monthOut;
            var one_day=1000*60*60*24;
            var ArArr=new Array();
            var DpArr=new Array()
            var ymIn=ArrDate.options[ArrDate.selectedIndex].value;
            var ymOut=DepDate.options[DepDate.selectedIndex].value;
            var Valid_Char="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_,+|}{<>?/.:;[]=''-~`\\ "+'"';
            //alert(ymOut);
            ArArr=ymIn.split(":");
            DpArr=ymOut.split(":");
           
            var In=new Date(ArArr[1],ArArr[0],document.f1.date.value);
            //alert(parseInt(ArArr[1])+1);
            //alert(In.getMonth());
            //alert(In.getFullYear());
            var Out=new Date(DpArr[1],DpArr[0],document.f1.dateOut.value);
            var Diff=Math.ceil((Out.getTime()-In.getTime())/(one_day)); 
            //var DIn=new Date(2007,11,21);
            var cIn=new Date(myscriptTime.getFullYear(),myscriptTime.getMonth(),myscriptTime.getDate()+1);
            var cOut=new Date(myscriptTime.getFullYear()+1,myscriptTime.getMonth(),myscriptTime.getDate()-1);
                   
            if(document.f1.date.value=="")
             {
             alert("Please Enter Arrival Date");
             document.f1.date.focus();
             return false;
             }
            // else if(Char_Check(document.f1.date.value,Valid_Char)==false || isLastDate1(document.f1.date.value,ArArr[0],ArArr[1])=="false" || document.f1.date.value==0)
            // {
            // alert("Invalid Arrival Date");
            //document.f1.date.focus();
            // }
//            else if(In<cIn)
//            {
//            alert("Arrival Date should be greater than Current Date");
//            document.f1.date.focus();
//            }
            else if(document.f1.dateOut.value=="")
              {
               alert("Please Enter Departure Date");
               document.f1.dateOut.focus();
               return false
              }
            else if(Out>cOut)
            {
            var s=new Date(cOut.setDate(cOut.getDate()+1));
            alert("Departure Date should be less than "+ (parseInt(s.getDate()))+"-"+getMonthName(s.getMonth())+"-"+s.getFullYear());
            document.f1.dateOut.focus();
            return false
            }
            else if(In>=Out)
            {
            alert("Departure Date should be greater than Arrival Date");
            document.f1.dateOut.focus();
            return false
            return false
            }
            else if(Diff>30)
             {
             alert("No of nights should be less than or equal to 30 days");
             document.f1.dateOut.focus();
             return false
             }
            
            else
            {   
           document.getElementById("calArrivalDateField").value=ArArr[1]+"-"+get_Month_Number((parseInt(ArArr[0])+1))+"-"+get_date_number(document.f1.date.value);
           document.getElementById("calDepartureDateField").value=DpArr[1]+"-"+get_Month_Number((parseInt(DpArr[0])+1))+"-"+get_date_number(document.f1.dateOut.value);
           document.getElementById("ccpSelectHotel").value="TJ-HL"+Hidd
           document.getElementById("occupancy").value=document.f1.Guests.value;
           document.getElementById("prsRoomCount").value=1;//document.f1.cmbRoomcount.value;
          url="https://www.yourreservation.net/ibe/02_taj/main.html?ccpSelectCity="+document.getElementById('ccpSelectCity').value+"&calArrivalDateField="+document.getElementById("calArrivalDateField").value+"&calDepartureDateField="+document.getElementById("calDepartureDateField").value+"&ccpSelectCountry="+document.getElementById('ccpSelectCountry').value+"&ccpSelectHotel="+document.getElementById("ccpSelectHotel").value+"&language=EN&prsRoomCount="+document.getElementById("prsRoomCount").value;
          var room;
          var j;
      
        if(document.f1.cmbaccountType.value!="-1")
           url+="&accountType="+document.getElementById("cmbaccountType").value
           if(document.f1.accountId.value!="")
           url+="&accountId="+document.f1.accountId.value;
           if(document.getElementById('rateAccesscode').value!="")
           url+="&rateAccesscode="+document.getElementById('rateAccesscode').value
          //url="https://www.yourreservation.net/ibe/02_taj/main.html?ccpSelectCity="+document.getElementById('ccpSelectCity').value+"&calArrivalDateField="+document.getElementById("calArrivalDateField").value+"&calDepartureDateField="+document.getElementById("calDepartureDateField").value+"&ccpSelectCountry="+document.getElementById('ccpSelectCountry').value+"&ccpSelectHotel="+document.getElementById("ccpSelectHotel").value+"&iata="+document.f1.iata.value+"&language=EN&occupancy="+document.getElementById("occupancy").value+"&prsRoomCount="+document.getElementById("prsRoomCount").value+"&quick=quick";
          var room;
          var j;
            if(document.f1.accountId.value!="" || document.getElementById("cmbaccountType").value!="-1")
           { 
            if(document.f1.accountId.value==0)
              {
                alert("Please enter the Account Id");
                document.f1.accountId.focus();
                return false;
              }
              if(document.getElementById("cmbaccountType").value=="-1")
              {
               alert("Please select account type");
               document.getElementById("cmbaccountType").focus();
               return false;
              }
           }
        
         if(document.f1.Guests.options[document.f1.Guests.selectedIndex].value<totalguest)
          {
          
              for(i=1;i<=1;i++)
              {
                var chid="cmbchildcnt"+i;
                 if(i==1)
                totoccupancy=parseInt(document.getElementById(chid).value)+parseInt(document.f1.Guests.value)
                //alert(document.getElementById(chid));
                if(document.getElementById(chid).value>=0)
                {
                 
                if(url==null)
                   url="&prsNumChildren="+document.getElementById(chid).value;
                else
                url+="&prsNumChildren="+document.getElementById(chid).value;
                    //alert(room);
                    for(j=1;j<=document.getElementById(chid).value;j++)
                     {
                   
                           if(i==1)
                              {
                                  var ageId="childagecmbchildcnt"+(parseInt(j)-1);
                                   //alert(ageId);
                               }
                            else
                            {
                                    var ageId="childagecmbchildcnt"+i+(j-1);
                                   // alert(document.getElementById(ageId).value);
                            }
                  if(document.getElementById(ageId).value=="<1")
                  {
                  url+="&prsRoomAge=0";
                  }
                  else
                  {          
                 url+="&prsRoomAge="+document.getElementById(ageId).value;
                  }
                       }
                 }
               }
               //
          }
          else
          {
          totoccupancy=parseInt(document.f1.Guests.value);
          }
         } 
         //debugger;
          //alert(url+"&occupancy="+totoccupancy+"&quick=quick");
          // totoccupancy=parseInt(document.f1.Guests.value);
        //   alert(url+"&occupancy="+totoccupancy+"&quick=quick");
       
        window.open(url+"&occupancy="+totoccupancy+"&quick=quick");
       
         
                   
            }
         
		 
		 
		
	

function getMonthValue(mon,yr)
{       
       return mon+":"+yr;
 }

 
 function setcType()
{
document.getElementById("Exp").style.cursor='hand';
document.getElementById("indate").style.cursor='hand';
document.getElementById("outdate").style.cursor='hand';
}
function invokeCal(vtype)
{
//alert("1");
var ArrDate=document.f1.month.value;
   var DepDate=document.f1.monthOut.value;
   var ArArr=new Array();
   var DpArr=new Array();
   ArArr=ArrDate.split(":");
   DpArr=DepDate.split(":");
    var dtArrival;
	frmname =document.f1.name;
	//alert(frmname);
	if (vtype=='ci')
	{
	 var dd=document.f1.date.value
	 var mm=parseInt(ArArr[0])+1;
	 var yy=ArArr[1];
	// alert(mm);
	 GoToCalendar('Cal','CHECK-IN',frmname,dd,mm,yy,dtArrival)
	}
	else if (vtype=='co')
	{
	 /*var dd=currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value
	 var mm=currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value
	 var yy=currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value*/
	
	 var mm=parseInt(ArArr[0])+1;
	 var yy=ArArr[1];
	  var dd=parseInt(document.f1.date.value);
	
	/* if((mm=="1" || mm=="3" || mm=="5" || mm=="7" || mm=="8" || mm=="10") && dd=="31")
	 { 
		  dd=1;
	      mm=mm+1;
	 }
	else if((mm=="4" || mm=="6" || mm=="9" || mm=="11") && dd=="30")
	{
		dd=1;
		mm=mm+1;
	}
	else if(mm=="2")
	{
	
	 if(yy%4==0 && dd=="29")
	 {
	  dd=1;
	   mm=mm+1;
	 }
	else
	 {
	 if(dd=="28")
	 {
	 dd=1;
	 m=mm+1;
	 }
	
	}
  }	
	else if(mm=="12" && dd=="31")
	{
	
	mm=1;
	yy=parseInt(ArArr[1])+1;
	dd=1;
	}
	else
	{
	
	dd=parseInt(document.f1.date.value)+1;
	
	}
	 //alert(dd);*/
	
	 dtArrival = mm+"-"+yy+"-"+dd
	 GoToCalendar('Cal','CHECK-OUT',frmname,dd,mm,yy,dtArrival)
	}
}

function GoToCalendar(CalName,LinkName,frm,day,month,year,dtArrival) {
		var myFrm;
		var selDate;
		var thisWinFrm;
		
		thisWinFrm=document.forms[frm];
		
		myFrm=thisWinFrm;
				
		//if(LinkName=='CHECK-IN') {
			selDate=month + " " + year + " " + day
		//}		
		myselDate=selDate.split(' ')
		//alert(selDate);
		selDate=''
		
		for(i=0;i<myselDate.length;i++) {
			if(selDate=='') {
				selDate=myselDate[i]
			}
			else {
				selDate=selDate+ '-' +myselDate[i]
			}
		}		
		//alert(selDate);
		//return;
		//alert(CalName);
		//alert(LinkName)
		//alert(frm);
		//alert(selDate);
		//alert(dtArrival);
		calendar_url="../../TajHotelFinder/Res_Calendar.aspx?formName="+frm+"&formCtrl="+LinkName+"&selDate="+selDate + "&selDate1=" + dtArrival
		
		if(navigator.userAgent.indexOf("Firefox")!=-1)
		MM_openwin(calendar_url,"150px","224px","100px","200px");
		else if(navigator.userAgent.indexOf("MSIE")!=-1)
		MM_openwin(calendar_url,"188px","240px","100px","200px");
		else
		MM_openwin(calendar_url,"165px","232px","100px","200px");
	}
	function MM_openwin(MM_file,MM_height,MM_width,left,top)
{
   MM_config=""
   MM_config+="toolbar=no,";
   MM_config+="location=no,"
   MM_config+="directories=no,";
   MM_config+="status=no,"
   MM_config+="menubar=no," //Not on Apple Mac for obvious reasons
   MM_config+="scrollbars=no,"
   MM_config+="resizable=no," //Mac windows are always resizable
   MM_config+="copyhistory=no,"
   MM_config+="width="+MM_width+","
   MM_config+="left="+left+","
   MM_config+="top="+top+","
   MM_config+="height="+MM_height
   var MM_win=open(MM_file,"",MM_config);
   MM_win.focus();
}

function calendarCall(formCtrl,myMonthYear,dtD) 
              {	
            
	 var str=eval(myMonthYear.split(' '));
	 var str1=str[0].slice(0,3);
	 //alert(dtD);
/*alert(str)
alert(str1)

alert(formCtrl);
  alert("Cal Calll");*/
	 putdate(dtD,str1,str[1],formCtrl);
	}
	
	
	function putdate(dd,mm,yy,ctrlname)
{
//alert(mm);
var cOut=new Date(myscriptTime.getFullYear()+1,myscriptTime.getMonth(),myscriptTime.getDate()-1);
//var cw=new Date(cOut.setMonth(cOut.getMonth()+1));
//alert(cw);
//alert(getMonthName(cOut.setMonth(2)));
//var cIn=new Date(myscriptTime.getFullYear()+1,myscriptTime.getMonth()-1,myscriptTime.getDate()-1);
//alert(cIn);
var mNum=getMonthNumber(mm.toUpperCase());
//alert(mNum);
var Out=new Date(yy,mNum,dd);
var my=mm.toUpperCase()+" "+yy;
var currform=document.f1;
//alert(myscriptTime.getMonth());
//alert(myscriptTime.getDate()-1);


	if (ctrlname == 'CHECK-IN')
	{
	//alert("2");
	/*if(yy>=2008 && mNum>=9 && dd>=myscriptTime.getDate()-1)
	{
alert("Arrival Date Should be less than "+parseInt(myscriptTime.getDate()-1)+"-"+mm.toUpperCase()+"-"+yy);
return false;

}*/
		//set year
		for(i=0;i<currform.month.options.length;i++)
		{
		
			if (currform.month.options[i].text ==my){
			
				currform.month.options[i].selected = true;
				break;}
		}
		//ArrivalYearChanged();

		//set month
		/*for(i=0;i<currform.cmbArrivalMonth.options.length;i++)
		{
			if (currform.cmbArrivalMonth.options[i].text.slice(0,3) ==mm){
				currform.cmbArrivalMonth.options[i].selected = true;
				break;}
		}
		ChangeOptionDays(ADaysObject,AMonthObject,AYearObject,'A');*/
		//set day
		//alert(dd+"put");
		onchangepopulateIndate();
		for(i=0;i<currform.date.options.length;i++)
		{
		//alert(currform.date.options[i].text);
			if (currform.date.options[i].text ==dd){
				currform.date.options[i].selected = true;
				break;}
		}
		//AddNights2Depart();
			changeDate("date","month");
		
	}
	
	if (ctrlname == 'CHECK-OUT')
	{
	if(Out>cOut)
            {
            alert("Departure Date should be less than  "+ (parseInt(cOut.getDate())+1)+"-"+getMonthName(cOut.getMonth())+"-"+cOut.getFullYear());
            return false;
            //document.f1.dateOut.focus();
            }
  
	//set day

	for(i=0;i<currform.monthOut.options.length;i++)
		{
	        	if (currform.monthOut.options[i].text ==my){
				currform.monthOut.options[i].selected = true;
				break;}
		}
  onchangepopulateOutdate();
	//set month
	/*for(i=0;i<currform.cmbDepartMonth.options.length;i++)
	{
		if (currform.cmbDepartMonth.options[i].text.slice(0,3) ==mm){
			currform.cmbDepartMonth.options[i].selected = true;
			break;}
	}*/

	//set year
	//disp_date(document.f1.dateOut,document.f1.monthOut);
	for(i=0;i<currform.dateOut.options.length;i++)
		{
			if (currform.dateOut.options[i].value ==dd){
				currform.dateOut.options[i].selected = true;
				break;}
		}
	}
	
}

function getMonthNumber(s)
            {
            if(s=="JAN")
            return 0;
             if(s=="FEB")
            return 1;
             if(s=="MAR")
            return 2 ;
             if(s=="APR")
            return 3;
             if(s=="MAY")
            return 4;
            if(s=="JUN")
            return 5;
             if(s=="JUL")
            return 6;
              if(s=="AUG")
            return 7;
            if(s=="SEP")
            return 8;
             if(s=="OCT")
            return 9;
            if(s=="NOV")
            return 10;
            if(s=="DEC")
            return 11;
            
             
            }
            
            
function changeDate()
 {
 //alert(document.f1.month.value);
 //alert(document.f1.month.options[0].value);
 //alert(document.f1.monthOut.options[0].value);
 var ArrDate=document.f1.month.value;
 var DepDate=document.f1.monthOut.selectedIndex;
 var ArArr=new Array();
 //var DpArr=new Array();
 ArArr=ArrDate.split(":");
 //DpArr=DepDate.split(":");
 var mm=parseInt(ArArr[0])+1;
//alert(mm);
 var yy=ArArr[1];
 var dd=parseInt(document.f1.date.value);
 
 if(parseInt(myscriptTime.getMonth())+1==mm && parseInt(myscriptTime.getFullYear())+1==yy && dd>parseInt(myscriptTime.getDate())-2)
	{
	//alert("O");
	var dt=new Date(myscriptTime.getFullYear()+1,myscriptTime.getMonth(),myscriptTime.getDate());
	var ndt=new Date(dt.setDate(dt.getDate()-1));
	var mName=getMonthName(ndt.getMonth());
	alert("Arrival Date should be less than "+parseInt(ndt.getDate())+"-"+mName.toUpperCase()+"-"+ndt.getFullYear());
	document.f1.date.value=1;
	return false;

	//disp_date(document.f1.dateOut,document.f1.month);
	}
 
 
 if((mm=="1" || mm=="3" || mm=="5" || mm=="7" || mm=="8" || mm=="10") && dd=="31")
	 { 
		if(document.f1.month.options[0].value==document.f1.monthOut.options[0].value)
		{
		  document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex+1;
		 // alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	    }
	    else
	    {
	    document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex;
		 // alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	    }
	      
	 }
	else if((mm=="4" || mm=="6" || mm=="9" || mm=="11") && dd=="30")
	{
	    if(document.f1.month.options[0].value==document.f1.monthOut.options[0].value)
		{
		 document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex+1;
		// alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	    }
	    else
	    {
	    document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex;
		// alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	    }  
	}
	else if(mm=="2")
	{
	//if(parseInt(myscriptTime.getMonth())+1==mm && parseInt(myscriptTime.getFullYear())+1==yy && dd>parseInt(myscriptTime.getDate())-2)
	//{
	//alert("O");
	
	//var mName=getMonthName(mm-1)
	//alert("Arrival Date Should be less than "+parseInt(myscriptTime.getDate()-1)+"-"+mName.toUpperCase()+"-"+yy);
	//document.f1.date.value=1;
	//return false;

	//disp_date(document.f1.dateOut,document.f1.month);
	//}
		
	 if(yy%4==0 && dd=="29")
	 {
	  if(document.f1.month.options[0].value==document.f1.monthOut.options[0].value)
		{
	 document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex+1;
		// alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	    }
	  else
	  {
	  document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex;
		// alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	 }  
	 }
	else if(yy%4!=0 && dd=="28")
	 {
	 
	 if(document.f1.month.options[0].value==document.f1.monthOut.options[0].value)
		{
		  document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex+1;
		  // alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	     }
	  else
	  {
	  document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex;
		  // alert(document.f1.monthOut.selectedIndex);
	      disp_date(document.f1.dateOut,document.f1.monthOut);
	      document.f1.dateOut.value=1;
	  }    
	 }
	 else
	 {
	
	disp_date(document.f1.dateOut,document.f1.month);
	 document.f1.dateOut.value=parseInt(document.f1.date.value)+1;
	 document.f1.monthOut.value=document.f1.month.value;
	
	  
	 }
	
	
  }	
	else if(mm=="12" && dd=="31")
	{
	 if(document.f1.month.options[0].value==document.f1.monthOut.options[0].value)
		{
		 document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex+1;
		 //alert(document.f1.monthOut.selectedIndex);
	     disp_date(document.f1.dateOut,document.f1.monthOut);
	     document.f1.dateOut.value=1;
	    }
	  else
	    {
	    document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex;
		 //alert(document.f1.monthOut.selectedIndex);
	     disp_date(document.f1.dateOut,document.f1.monthOut);
	     document.f1.dateOut.value=1;
	    
	    }    
	}
	
	else
	{
	//alert(parseInt(myscriptTime.getMonth())+1+" "+mm);
	//alert(parseInt(myscriptTime.getFullYear())+1+" "+yy);
	//alert(parseInt(myscriptTime.getDate())-2+" "+dd);
	if(parseInt(myscriptTime.getMonth())+1==mm && parseInt(myscriptTime.getFullYear())==yy)
	{
	//alert("Curr");
	document.f1.monthOut.selectedIndex=document.f1.month.selectedIndex;
	disp_date(document.f1.dateOut,document.f1.monthOut);
	document.f1.dateOut.value=parseInt(document.f1.date.value)+1;
		//disp_date(document.f1.dateOut,document.f1.monthOut);
	//dd=parseInt(document.f1.date.value)+1;
	}
	
	
	else if(parseInt(myscriptTime.getMonth())+1==mm && parseInt(myscriptTime.getFullYear())+1==yy && dd>parseInt(myscriptTime.getDate())-2)
	{
	//alert("O");
	var mName=getMonthName(mm-1)
	alert("Arrival Date should be less than "+parseInt(myscriptTime.getDate()-1)+"-"+mName.toUpperCase()+"-"+yy);
	document.f1.date.value=1;
	return false;

	//disp_date(document.f1.dateOut,document.f1.month);
	}
	else
	{
	document.f1.monthOut.value=document.f1.month.value;
	disp_date(document.f1.dateOut,document.f1.monthOut);
	document.f1.dateOut.value=parseInt(document.f1.date.value)+1;
	}
	}
 //alert(DepDate);
 
 } 
 
/* function End_Date(mm,dd,yy)
 {
   var w=
					   {
					  // alert(e);
					   var i=0;
					   ctr.options.length=w	
					   for(i=0;i<w;i++)
					    {
					    ctr.options[i]=new Option(odd[i],i+1);
					    }
					   } 
 
 
 }*/

 
 function Read(Id)
 {
   if(navigator.appName=="Microsoft Internet Explorer")
    {
      ReadXml1(Id);
    }
    else
    {
       ReadXml(Id)
    }
 }
function ReadXml(Id)
 {
     var XmlHTTP = null;
    var Possibles = {0: "XMLHttpRequest()", 1: "ActiveXObject('Microsoft.XMLHttp')", 2:"ActiveXObject('MSXML2.XMLHttp')", 3:"ActiveXObject('MSXML2.XMLHttp.3.0')", 4:"ActiveXObject('MSXML2.XMLHttp.4.0')", 5:"ActiveXObject('MSXML2.XMLHttp.5.0')", 6:"ActiveXObject('MSXML2.XMLHttp.6.0')",7:"ActiveXObject('Msxml.DOMDocument')", 8:""};
    var Option = 0;
    while(XmlHTTP === null){
        XmlHTTP = eval("new " + Possibles[Option]);
      
    }
if(XmlHTTP === null)
    return false;
XmlHTTP.open("get", "../../Common_Inc/link.xml", false);
XmlHTTP.send("");
LoadXml = XmlHTTP.responseXML;
ManipulateXML(Id);
}
  
function ReadXml1(Id) 
{ 

	if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
	{ 
		LoadXml = new ActiveXObject("Msxml.DOMDocument"); 
		LoadXml.async = false; 
		LoadXml.onreadystatechange = function () 
		{ 
		    if (LoadXml.readyState == 4) ManipulateXML(Id); 
		} 
		LoadXml.load("../../Common_Inc/link.xml"); 
	} 
	else if( document.implementation && document.implementation.createDocument ) 
	{ 
		LoadXml = document.implementation.createDocument("","",null); 
		LoadXml.async=false; 
		var loaded = LoadXml.load("../../Common_Inc/link.xml"); 
		moz=1;
		if (loaded) 
		{ 
			ManipulateXML(Id);
		} 
	} 
	else 
	{ 
		alert("Your browser can\'t handle this script"); 
		return; 
	} 
}



function showchild(ctg)
{

var pos;
if(navigator.userAgent.indexOf("Safari")!=-1)
pos=6;
else if(navigator.userAgent.indexOf("Firefox")!=-1)
pos=4;
else
pos=3;
var strroom;
var strnoofchildren;
 var child=null;
     if(document.getElementById("Guests").value<4)
     child=2;
     else
     child=totalguest-document.getElementById("Guests").value;
document.getElementById('cntchildren').innerHTML="";
var gusetroom=document.getElementById("Guests");
document.getElementById("agechild").innerHTML="";
var roomcount=1;//document.getElementById("cmbRoomcount");
 if(gusetroom.value!=5)
  {
     document.getElementById('child').style.display='block';
     for(j=0;j<=child;j++)
     {
     if(strnoofchildren==null)
     strnoofchildren="<option value='"+j+"'>"+j+"</option>";
     else
     strnoofchildren+="<option value='"+j+"'>"+j+"</option>";
     }
      for(i=1;i<=1;i++)
     {
     if(strroom==null)
     strroom="<table width='100%' cellpadding='1' cellspacing='0' border='0' class='darkb'><tr vAlign='top'><td style='padding-top:"+pos+"px' width='35%'>Children&nbsp;&nbsp;&nbsp;&nbsp;<select class='booker_txtblck' id='cmbchildcnt"+i+"' name='cmbchildcnt'"+i+" onchange=showAge('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' width='65%' align='left'></td></tr>";
     else
     strroom+="<tr vAlign='top'><td style='padding-top:"+pos+"px'>Children&nbsp;&nbsp;&nbsp;&nbsp;<select class='booker_txtblck' id='cmbchildcnt"+i+"' name='cmbchildcnt"+i+"' onchange=showAge('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' align='left'></td></tr>";
     break;
     }
     strroom+="</table>";
     if(document.getElementById('cntchildren')!=null)
      {
        document.getElementById('cntchildren').innerHTML=strroom;//"<select id='cmbchildcnt' name='cmbchildcnt'><option value='0'>0</option><option value='1'>1</option></select>";
      }  
      if(ctg!='load')
        CSBfleXcroll('mycustomscroll1');   
  }
 else
 {
 document.getElementById('child').style.display='none';
 document.getElementById('cntchildren').innerHTML="";
 }

}

function showAge(tdid1,childcnt)
{
//.
//alert(tdid);
//alert(tdid.innerHTML);
//alert(childcnt);
//document.getElementById(tdid).innerText="";

var tdid=document.getElementById(tdid1);
tdid.innerHTML="";

var strage='';
var strrooms;
//var =document.getElementById("cmbchildcnt");
//alert(childcnt.value);
if(childcnt.value!=0)
  {
  
    //alert(childcnt.value);
     document.getElementById("agechild").innerHTML="Age of Children";
     for(m=0;m<=16;m++)
     {
     if(strrooms==null)
     strrooms="<option value='<1'><1</option>";
     else
     strrooms+="<option value='"+m+"'>"+m+"</option>";
     }
    var t=0;
    strage+="<table cellpadding='0' cellspacing='0' border='0'>"
    strage+="<tr vAlign='top'>"
      for(k=0;k<childcnt.value;k++)
     {
     strage+="<td align='left' style='padding-bottom:1px;'>";
      if(t!=0)
      if(t%2==0)
      strage+="<tr vAlign='top'><td style='padding-top:1px;' align='left'>"
      if(strage==null)
      strage="<select id='childage"+childcnt.name+k+"' name='childage"+childcnt.name+k+"' class='booker_txtblck'>"+strrooms+"</select>";
      else
      strage+="&nbsp<select id='childage"+childcnt.name+k+"' name='childage"+childcnt.name+k+"' class='booker_txtblck'>"+strrooms+"</select>";
      strage+="</td>";
      
      t++;
     }
 
    strage+="</tr></table>"
    
     strage+="<div align='left'></div>"
    tdid.innerHTML=strage;
    strage=null;
   
    //alert("SD");
  }
else
 {

 if(document.getElementById("childagecmbchildcnt0")==null && document.getElementById("childagecmbchildcnt1")==null && document.getElementById("childagecmbchildcnt10")==null && document.getElementById("childagecmbchildcnt11")==null && document.getElementById("childagecmbchildcnt20")==null && document.getElementById("childagecmbchildcnt21")==null && document.getElementById("childagecmbchildcnt30")==null && document.getElementById("childagecmbchildcnt31")==null && document.getElementById("childagecmbchildcnt40")==null && document.getElementById("childagecmbchildcnt41")==null)
 {

    document.getElementById("agechild").innerHTML="";
 }
     //document.getElementById("tdid").innerHTML="";
     strage=null;
      tdid.innerHTML="";
 }
  CSBfleXcroll('mycustomscroll1');

}



function ManipulateXML(resortid)
{

var strTitle


//Rooms Combo
var rooms="<tr><td width='50%' vAlign='middle' style='padding-top:0px;'>Room(s):</td>"
rooms+="<td width='50%' style='padding-top:5px;padding-left:6px;'><select class='booker_txtblck' id='cmbRoomcount' name='cmbRoomcount' onchange=showchild('change');><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select></td></tr>"

//Guests Combo
Guests="<tr><td vAlign='middle' width='55%' style='padding-top:0px;'>Adults:</td>"
Guests+="<td width='40px' style='padding-top:5px;padding-left:6px;'><select class='booker_txtblck' id='Guests' name='guests' onchange=showchild('change');><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></td></tr>"
var design="<table class='booker_txt' border=0 cellpadding=0 cellspcing=0 width='320px'><tr height='10px;'><td style='padding-left:4px;padding-top:2px;'><div style='text-decoration: none; border-bottom: 1px solid #6f1b28; width:150px;'>Check Rates & Availability</div> </td></tr><tr><td>";
design+="<input type='hidden' name=language id=language value=en><input type='hidden' name='ccpSelectCountry' id='ccpSelectCountry'><input type='hidden' name='ccpSelectCity' id='ccpSelectCity'><input type='hidden' name='ccpSelectHotel' id='ccpSelectHotel'><input type='hidden' name='calArrivalDateField' id='calArrivalDateField'><input type='hidden' name='calDepartureDateField' id='calDepartureDateField'><input type='hidden' name=prsRoomCount id=prsRoomCount value=3><input type='hidden'name='occupancy' id='occupancy'><input type='hidden' name=prsRoomCount id=prsRoomCount>";
if(navigator.userAgent.indexOf("Safari")!=-1)
design+="<table border=0 cellspacing=0 cellpadding=1 width='320px'>";
else if(navigator.userAgent.indexOf("MSIE")!=-1)
design+="<table border=0 cellspacing=0 cellpadding=1 width='100%'>";
else
design+="<table border=0 cellspacing=0 cellpadding=1 width='100%'>";
design+="<tr vAlign='top'><td vAlign='top' colspan=4 width='50%' style='padding-left:4px;padding-bottom:2px;padding-top:4px;'>Arrive:</td>";
design+="<td vAlign='top' colspan=3 width='50%' style='padding-left:0px;padding-bottom:2px;padding-top:4px;'>Depart:</td></tr>";
design+="<tr vAlign='top' height='20px'><td vAlign='bottom' align='left' style='padding-left:4px;width:90px;'><select class='booker_txtblck' id='month' name='month' onchange='onchangepopulateIndate()' style='width:85px'><option value='0'>Select a Month</option></select></td>"
design+="<td vAlign='bottom' style='width:46px;' align='left'><select class='booker_txtblck' id='date' name='date' onchange=changeDate('date','month'); style='width:44px'><option value=''></option></select></td>"
design+="<td vAlign='bottom' style='width:21px;' align='left'><img id='indate' height='17px' name='indate' src='images/hcalc.jpg'  onclick='invokeCal(ci);' onmouseover='setcType();' onmouseout='setcType();' style='width:20px'></td><td width='6px'>&nbsp;</td>"
design+="<td vAlign='bottom' style='width:90px;' align='left'><select class='booker_txtblck' id='monthOut' name='monthOut' onchange='onchangepopulateOutdate()' style='width:85px'><option value='0'>Select a Month</option></select></td>"
design+="<td vAlign='bottom' style='width:46px;' align='left'><select class='booker_txtblck' id='dateOut' name='dateOut' style='width:44px'><option value=''></option></select></td>"
design+="<td vAlign='bottom' style='width:21px;' align='right'><img id='outdate' height='17px' src='images/hcalc.jpg' onclick='invokeCal(co);' name='outdate' onmouseover='setcType();' onmouseout='setcType();'></td></tr>"
//design+="<tr><td colspan=2 width='100%' vAlign='top' align='left' style='padding-left:2px;'><table cellpadding=0 cellspcing=0 border=0>"+rooms+"</table></td>"
design+="<tr><td colspan=5 width='100%' vAlign='top'><table cellpadding=0 cellspcing=0 border=0>"+Guests+"</table></td></tr>"
design+="<tr><td vAlign='top' width='100%' colspan='7'>";
design+="<div id='child' style='display:none'><table width='100%' border='0'><tr style='height:15px;'><td width='35%'></td><td id='agechild' width='65%' colspan='2' style='padding-left:6px;'></td></tr><tr>"
design+="<tr><td   vAlign='top' width='50%' colspan='3' id='cntchildren' name='cntchildren'></td></tr></table></div></td></tr><tr>"
design+="<tr height='10px' vAlign='middle'><td colspan='2' style='padding-bottom:3px;padding-left:4px;'>";
design+="Optional Information:</td><td colspan='5'><img id='Exp' name='Exp' src='images/plus1.jpg' onclick='disp_div();' onmouseover='setcType();' onmouseout='setcType();'/></td></tr><tr><td colspan='7'><div style='display:none' id='Opt'><table border='0' width='100%'><tr><td   vAlign='top' width='60%'>Account ID:</td><td colspan='2' align='left' width='40%'><input class='booker_txtblck' type='text' id='accountId' name='accountId' style='width:40px;height:15px' />"
design+="</td></tr><tr><td   vAlign='top'>Rate Access Code:</td><td colspan='2' align='left'><input class='booker_txtblck' type='text' id='rateAccesscode' name='rateAccesscode' style='width:40px;height:15px' /></td></tr><tr><td colspan='3' style='padding-bottom:3px;'>Account Type</td></tr><tr><td colspan='3' class='booker_txtblck' vAlign='top' style='padding-bottom:6px;'><select id='cmbaccountType' name='cmbaccountType' style='width:235px;'>"+fillAccounttype()+"</select></td></tr></table></div></td></tr><tr><td colspan='7' vAlign='middle' align='left' style='padding-left:4px'>"
design+="<input  type='image' src='images/submit.png' id='link' name='link' onclick='opentrust();return false;' /></table></td></tr></table>"


var j=0;
strTitle = LoadXml.getElementsByTagName("HotelLinks")[0]; 
var cap;
var lnk
var countId
var cityId
if(strTitle.getElementsByTagName('Hotel').length>0)
{
//var temp="<table width='344px' cellpadding='2' cellspacing='0' class='quick_table_b' vAlign='middle'><tr><td align='left'><ul>"
for(var i=0; i<strTitle.getElementsByTagName('Hotel').length; i++) 
{
if(strTitle.getElementsByTagName('Hotel')[i].getAttribute("HotelId")==resortid)
{
cap=strTitle.getElementsByTagName('Hotel')[i].getAttribute("caption");
lnk=strTitle.getElementsByTagName('Hotel')[i].getAttribute("link");
countId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("countryId");
cityId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("CityId");

}
} 
//temp+="</ul></td></tr></table>";
}


document.write(design);

//else
//document.write(design+temp+"<br>");
document.getElementById('ccpSelectCountry').value=countId;
document.getElementById('ccpSelectCity').value=cityId;



}

function fillAccounttype()
{
var actype="<option value='-1'>Please select</option>";
actype+="<option value='travelagency-agent-'>Travel Agency/Guest guarantees</option>";
actype+="<option value='travelagency-agent-A'>Travel Agency/Agency guarantees</option>";
actype+="<option value='travelagency-guest-'>Guest</option>";
actype+="<option value='travelagency-company-A'>Company</option>";
return actype;


} 
            
   
	 
 function openpopup(filename,wd,ht,top,lft)
{
//var filename="summer_experience.htm";
var Offerwin;
if(filename!="" ||filename!=null)
Offerwin=window.open(filename,"offer","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+wd+",height="+ht+",top="+top+",left="+lft);
Offerwin.focus();


}
function offerLink_fn2()
{
	window.open("offers.htm","Young","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=760,height=600,top=80,left=120");
}


function offerLink_fn1()
{
var countId;
 var cityId
 var strTitle;

strTitle = LoadXml.getElementsByTagName("HotelLinks")[0]; 
  if(strTitle.getElementsByTagName('Hotel').length>0) 
   { 
     for(var i=0; i<strTitle.getElementsByTagName('Hotel').length; i++) 
      {
        if(strTitle.getElementsByTagName('Hotel')[i].getAttribute("HotelId")==Id)
           {
                    countId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("countryId");
                    cityId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("CityId");
                    break;
            }        
                    
       }
//document.location.href = "https://www.trustinternational.com/mBooker/taj/2B?LANGUAGE=en&i=TajHolidays&property=TXL-TJ-"+Id;
   }
  document.location.href="https://www.yourreservation.net/ibe/TajHolidays/main.html?ccpSelectCity=" +cityId +"&ccpSelectCountry="+countId+"&ccpSelectHotel=TJ%2D"+Id+"&language=EN&quick=page1" 
 }  

function opennewwindow()
{
	window.location.href="offers.htm";
}

//---Date Operation


var yy=myscriptTime.getFullYear();
var mm=myscriptTime.getMonth();
//myscriptTime.setDate(myscriptTime.getDate()+1)
var dd=myscriptTime.getDate();

var startDate=new Date();
var strstartdate=(parseInt(mm)+1)+"/"+dd+"/"+yy; //"4/1/2009";  // mm/dd/yyyy
startDate.setDate(startDate.getDate()+1)

var yy=myscriptTime.getFullYear();
var mm=myscriptTime.getMonth();
var dd=myscriptTime.getDate();
var strenddate=parseInt(mm)+1+"/"+dd+"/"+(parseInt(yy)+1);//"1/1/2011";
//alert(strenddate);
var datediff=1;//Date Difference
var endDate=new Date(strenddate);


var arrMonth=new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
//alert(arrMonth[2]);
var todaydate=new Date();
var date=todaydate.getDate();
var month=todaydate.getMonth();
var year=todaydate.getFullYear();
var noofmonth=24;//no of month
var noofdays=30;





 function getMonthName(s)
            {
            if(s==0)
            return "JAN";
             if(s==1)
            return "FEB";
             if(s==2)
            return "MAR";
             if(s==3)
            return "APR";
             if(s==4)
            return "MAY";
            if(s==5)
            return "JUN";
             if(s==6)
            return "JUL";
              if(s==7)
            return "AUG";
             if(s==8)
            return "SEP";
             if(s==9)
            return "OCT";
             if(s==10)
            return "NOV";
             if(s==11)
            return "DEC";
           }
//populatemonth("date","month",strstartdate);
//populatemonth("dateOut","monthOut",strstartdate);
function populatemonth(ctrd,ctrm,stdate)
{

document.getElementById(ctrm).options.length=null;
 //document.getElementById(ctrm).options.length=null;
 sdate=new Date(stdate); 
 temenddate=new Date(strenddate);
 if(ctrd.indexOf('Out')!=-1)
 {
 temenddate.setDate(temenddate.getDate()+datediff);
 }
    for(i=0;i<=noofmonth;i++)
    {  

     document.getElementById(ctrm).options[i]=new Option(getMonthName(sdate.getMonth())+" "+sdate.getFullYear(),sdate.getMonth()+":"+sdate.getFullYear());
     if(temenddate.getMonth()==sdate.getMonth() && temenddate.getFullYear()==sdate.getFullYear())
     break;
     sdate.setMonth(sdate.getMonth()+1);
    // alert(startDate);
    }
}


prepopulatedates('date',strstartdate);
prepopulatedates('dateOut',strstartdate);

//var datandyear=document.getElementById(ctrm).options[document.getElementById(ctrm).selectedIndex].value;
//var datyear=datandyear.split(":");
//if(stdate.getMonth()==parseInt(datyear[0]) && parseInt(datyear[1])==stdate.getFullYear())
//{
//var newdate=curDate;
//newdate.setDate(newdate.getDate()+1)
//}
//else
//var newdate=new Date((parseInt(datyear[0])+1)+"/"+1+"/"+datyear[1]);
function prepopulatedates(ctrd,stdt)
{
 
    var stdate=new Date(stdt);
    if(ctrd.indexOf('Out')!=-1)
    {
        stdate.setDate(stdate.getDate()+parseInt(datediff))
       populatemonth("dateOut","monthOut",stdate);
        populatedate(stdate,ctrd);
        
    }
    else
    {
       populatemonth("date","month",stdate);
       populatedate(stdate,ctrd);
       
    }

}

function onchangepopulateIndate()
{

  var selIndate=getSelectedDate1("date","month");
  populatedate(selIndate,"date","onchange");
  changeDate("date","month"); 
   
    
}

function getSelectedDate1(ctrd,ctrm)
{

var curDate=new Date(strstartdate);
var datandyear=document.getElementById(ctrm).options[document.getElementById(ctrm).selectedIndex].value;
var datyear=datandyear.split(":");
if(curDate.getMonth()==parseInt(datyear[0]) && parseInt(datyear[1])==curDate.getFullYear())
var newdate=curDate;
else
var newdate=new Date((parseInt(datyear[0])+1)+"/"+document.getElementById(ctrd).options[document.getElementById(ctrd).selectedIndex].text+"/"+datyear[1]);
return newdate;
}

function getSelectedDateChange(ctrd,ctrm)
{
var datandyear=document.getElementById(ctrm).options[document.getElementById(ctrm).selectedIndex].value;
var datyear=datandyear.split(":");
var newdate=new Date((parseInt(datyear[0])+1)+"/"+1+"/"+datyear[1]);
return newdate;
}


function onchangepopulateOutdate()
{
var selOutdate=getSelectedDateChange("dateOut","monthOut");
var selIndate=getSelectedDate("date","month");

populatedateOut(selOutdate,selIndate,"dateOut","onchange");
//RevchangeDate("dateOut","monthOut");
}
function populatedateOut(selDate,selIndates,ctrd,type)
{


document.getElementById(ctrd).options.length=null;
var strtdate=new Date(strstartdate);
var tempenddate=new Date(strenddate);
//alert(selDate.getMonth()+"Select")
//alert(strtdate.getMonth()+"Start");

if(type=="onchange")
{
   
 
    if(selDate.getMonth()==selIndates.getMonth() && selDate.getFullYear()==selIndates.getFullYear())
    selDate.setDate(selIndates.getDate()+datediff);
    else
    selDate.setDate(1);
    
  
    
 }   
   var selIsndate=getSelectedDate1("date","month");
          if(ctrd.indexOf('Out')==-1)
             selIsndate=getSelectedDateChange("date","month");
          else
              selIsndate.setDate(selIsndate.getDate()+1)
      
            document.getElementById(ctrd).length=null;
  
       for(j=0;j<=31;j++)
        {
        document.getElementById(ctrd).options[j]=new Option(selDate.getDate(),selDate.getDate());
//        if(tempenddate.getMonth()==selDate.getMonth() && tempenddate.getDate()==selDate.getDate() && tempenddate.getFullYear()==selDate.getFullYear())
//        {
//         
//         
//          var cnt=1;
//           for(y=0;y<=tempenddate.getDate();y++)
//           {
//         
//                document.getElementById(ctrd).options[y]=new Option(selIsndate.getDate(),selIsndate.getDate());
//                var mon1=selIsndate.getMonth();
//                selIsndate.setDate(selIsndate.getDate()+1)
//                if(tempenddate.getMonth()!=selIsndate.getMonth())
//                break;
//           }
//        break
//        }
          var mon=selDate.getMonth();
        selDate.setDate(selDate.getDate()+1)
        if(mon!=selDate.getMonth())
        return;
        }
 }

function revpopulatedate(selDate,ctrd,type)
{
document.getElementById(ctrd).options.length=null;
var strtdate=new Date(strstartdate);
var tempenddate=new Date(strenddate);
//alert(selDate.getMonth()+"Select")
//alert(strtdate.getMonth()+"Start");
if(ctrd.indexOf('Out')!=-1)
 {
 tempenddate.setDate(tempenddate.getDate()+datediff);
 }
if(type=="onchange")
{
    if(ctrd.indexOf('Out')==-1)
    {
    if(selDate.getMonth()!=strtdate.getMonth())
    selDate.setDate(1);
    else
    selDate.setDate(1);
    }
    
    else
    {
    // if(selDate.getMonth()!=strtdate.getMonth())
    // selDate.setDate(strtdate.getDate()+datediff);
    //  else
    selDate.setDate(strtdate.getDate()+datediff);
    
    if(selDate.getMonth()==tempenddate.getMonth())
    selDate.setDate(tempenddate.getDate());
   // tempenddate.setDate(tempenddate.getDate()+datediff);
    }
    
 }   
       for(j=0;j<=31;j++)
        {
        document.getElementById(ctrd).options[j]=new Option(selDate.getDate(),selDate.getDate());
        if(tempenddate.getMonth()==selDate.getMonth() && tempenddate.getDate()==selDate.getDate())
        {
        break
        }
        var mon=selDate.getMonth();
        selDate.setDate(selDate.getDate()+1)
        if(mon!=selDate.getMonth())
        return;
        }
 }



function populatedate(selDate,ctrd,type)
{


document.getElementById(ctrd).options.length=null;
var strtdate=new Date(strstartdate);
var tempenddate=new Date(strenddate);
//alert(selDate.getMonth()+"Select")
//alert(strtdate.getMonth()+"Start");
if(ctrd.indexOf('Out')!=-1)
 {
 tempenddate.setDate(tempenddate.getDate()-3);

 }
if(type=="onchange")
{
    if(ctrd.indexOf('Out')==-1)
    {
    if(selDate.getMonth()==strtdate.getMonth())
  selDate.setDate(strtdate.getDate());
    else
     selDate.setDate(1);
    
     
   
    }
    else
    {
    if(selDate.getMonth()==strtdate.getMonth())
    selDate.setDate(1);
    else
    selDate.setDate(strtdate.getDate()+datediff);
    
    
    if(selDate.getMonth()==tempenddate.getMonth())
    selDate.setDate(tempenddate.getDate());
   // tempenddate.setDate(tempenddate.getDate()+datediff);
    }
    
 }   
  
       for(j=0;j<=31;j++)
        {
        document.getElementById(ctrd).options[j]=new Option(selDate.getDate(),selDate.getDate());
        if(tempenddate.getMonth()==selDate.getMonth() && tempenddate.getDate()==selDate.getDate() && tempenddate.getFullYear()==selDate.getFullYear())
        {
         
          var selIsndate=getSelectedDate1("date","month");
          if(ctrd.indexOf('Out')==-1)
             selIsndate=getSelectedDateChange("date","month");
          else
              selIsndate.setDate(selIsndate.getDate()+1)
      
            document.getElementById(ctrd).length=null;
          var cnt=1;
           for(y=0;y<=tempenddate.getDate();y++)
           {
         
                document.getElementById(ctrd).options[y]=new Option(selIsndate.getDate(),selIsndate.getDate());
                var mon1=selIsndate.getMonth();
                selIsndate.setDate(selIsndate.getDate()+1)
                if(tempenddate.getMonth()!=selIsndate.getMonth())
                break;
           }
        break
        }
          var mon=selDate.getMonth();
        selDate.setDate(selDate.getDate()+1)
        if(mon!=selDate.getMonth())
        return;
        }
 }

function getSelectedDate(ctrd,ctrm)
{

var curDate=new Date(strstartdate);
var datandyear=document.getElementById(ctrm).options[document.getElementById(ctrm).selectedIndex].value;
var datyear=datandyear.split(":");
if(curDate.getMonth()==parseInt(datyear[0]+1) && parseInt(datyear[1])==curDate.getFullYear())
var newdate=curDate;
else
var newdate=new Date((parseInt(datyear[0])+1)+"/"+document.getElementById(ctrd).options[document.getElementById(ctrd).selectedIndex].text+"/"+datyear[1]);
return newdate;
}


function changeDate(datelist,monthlist)
{

    var ArrDate=document.f1.month.value;
 var DepDate=document.f1.monthOut.selectedIndex;
 var ArArr=new Array();
 ArArr=ArrDate.split(":");
 var mm=parseInt(ArArr[0])+1;

 var yy=ArArr[1];
 var dd=parseInt(document.f1.date.value);
 
 if(parseInt(myscriptTime.getMonth())+1==mm && parseInt(myscriptTime.getFullYear())+1==yy && dd>parseInt(myscriptTime.getDate())-2)
	{
	//alert("O");
	var dt=new Date(myscriptTime.getFullYear()+1,myscriptTime.getMonth(),myscriptTime.getDate());
	var ndt=new Date(dt.setDate(dt.getDate()-1));
	var mName=getMonthName(ndt.getMonth());
	alert("Arrival Date Should be less than "+parseInt(ndt.getDate())+"-"+mName.toUpperCase()+"-"+ndt.getFullYear());
	document.f1.date.value=1;
	return false;


	}

    var datandyear=document.getElementById(monthlist).options[document.getElementById(monthlist).selectedIndex].value;
    var datyear=datandyear.split(":");
    var newdate=new Date((parseInt(datyear[0])+1)+"/"+(parseInt(document.getElementById(datelist).options[document.getElementById(datelist).selectedIndex].text))+"/"+datyear[1]);
    var stdati=new Date(strstartdate);
    prepopulatedates('dateOut',newdate);
    newdate.setDate(stdati.getDate());
    var selIndates=getSelectedDate("date","month");
    
}


function RevchangeDate(datelist,monthlist)
{

    var selOutdates=getSelectedDate("dateOut","monthOut");
    selOutdates.setDate(selOutdates.getDate()-datediff)
    var mn=getMonthName(selOutdates.getMonth());
    var yr=selOutdates.getFullYear();
    var mnyr=mn+" "+yr;
    //alert(mnyr);
    currform1=document.f1;
		for(i=0;i<currform1.month.options.length;i++)
		{
		
			if (currform1.month.options[i].text ==mnyr){
			
				currform1.month.options[i].selected = true;
				break;}
		}
  var sendate=getSelectedDate("date","month");
  //alert(sendate);
  populatedate(sendate,"date","onchange");
			for(i=0;i<currform1.date.options.length;i++)
		{
		
			if (currform1.date.options[i].text ==selOutdates.getDate()){
			
				currform1.date.options[i].selected = true;
				break;}
		}
	
}

function revprepopulatedates(ctrd,stdt)
{

    var stdate=new Date(stdt);
    if(ctrd.indexOf('Out')!=-1)
    {
           populatemonth("dateOut","monthOut",stdate);
        revpopulatedate(stdate,ctrd);
        
    }
    else
    {
     stdate.setDate(stdate.getDate()-parseInt(datediff))
       populatemonth("date","month",stdate);
        revpopulatedate(stdate,ctrd);
   
       
    }

}


function changemonth(ctrd,ctrm)
{
mnt=document.getElementById(ctrm).options[document.getElementById(ctrm).selectedIndex].value;
dt=document.getElementById(ctrd).options[document.getElementById(ctrd).selectedIndex].value;
var datyear=mnt.split(":");
//if(isLastDate(dt,datyear[0],datyear[1])=="true")
//document.getElementById("monthOut").value=(parseInt(mnt)+1)+":"+datyear[1];
//else
document.getElementById("monthOut").value=document.getElementById("month").value;
}


showchild('load');