

function include(file)   
{   
  var script  = document.createElement('script');   
  script.src  = file;   
  script.type = 'text/javascript';   
  script.defer = true;   
  
  document.getElementsByTagName('head').item(0).appendChild(script);   
}

function includeinbody(file)   
{   
  var script  = document.createElement('script');   
  script.src  = file;   
  script.type = 'text/javascript';   
  script.defer = true;   
  document.getElementsByTagName('body').item(0).appendChild(script);   
} 

function includeStyle(file)   
{   
  var style  = document.createElement('link');   
  style.href  = file;   
  style.type = 'text/css';   
  style.defer = true;
  style.rel = 'stylesheet';  
  document.getElementsByTagName('head').item(0).appendChild(style);   
}  

/* include any js files here */
includeStyle('http://www.quickbooker.com/qbsearch/Style/calendar1.css');
include('http://www.quickbooker.com/qbsearch/Scripts/calendar_Single.js');
include('http://www.quickbooker.com/qbsearch/Scripts/actb.js'); 
include('http://www.quickbooker.com/qbsearch/Scripts/common.js');
//include('CountryCityArray.asp');
  

function ExtraBedDropDown(elem)
   {
   
      var SelectElem =  document.frmQBSearch.extraBed; 
      SelectElem.options.length = 0;
      opt1	=	document.createElement('option')
	  opt1.innerHTML	=	"0";
	  opt1.value		=	"0";
	  SelectElem.appendChild(opt1,null);
	  
      for(i=1;i<=parseInt(elem);i++)
      {
          var option = document.createElement("option");
          option.value = i;
          option.innerHTML = i;
          SelectElem.appendChild(option,null);
      }
   }

function validatePage()
{
	var checkin;
    var checkout;
    var result;
    checkin=document.frmQBSearch.checkin.value;
    checkout=document.frmQBSearch.checkout.value;        
    var date1=new Date(checkin.substring(6, 10), parseInt(checkin.substring(3, 5),10)-1, checkin.substring(0, 2));
    var date2=new Date(checkout.substring(6, 10), parseInt(checkout.substring(3, 5),10)-1, checkout.substring(0, 2));
    var new_Date = new Date();
    var currentdate= new Date();
    new_Date = addDays(currentdate,2);
    //alert("Please enter your destination!");
    if((document.frmQBSearch.txtDestination.value)=="" ||(document.frmQBSearch.txtDestination.value)==" " )
    {
        alert("Please enter the destination/city which you are looking for!");
        return false;
    }
            
        
        if(date1 <= new_Date)
        {
        alert("Check In date starts with Current Date + 3!");
        return false;
        }
      
        var year1 =    parseInt(checkin.substring(6, 10));
        var year2 =    parseInt(checkout.substring(6, 10));
        var c_date = new Date();
        var currentYear1 = parseInt(c_date.getFullYear());
        var currentYear = currentYear1 + 2
        var currentDay= c_date.getDate();
        var currentDay1= currentDay + 1;
        var currentDay2 = currentDay + 2;
        var Datevar= date1.getDate();
        
      
      if((date1 == "Invalid Date") || (date1 == "NaN"))
      {
        alert("Please select Check In Date");
        document.frmQBSearch.checkin.select();
        return false;
      }
       if((date2 == "Invalid Date") || (date2 == "NaN"))
       {
        alert("Please select Check Out Date");
        document.frmQBSearch.checkout.select();
        return false;
       }
        if(date1 >= date2)
        {
            alert("Check out date should be greater than check in date !");
            return false;
        }
      /*  if((date1 < c_date) || (date2 < c_date))
        {
            alert("Check in / Check out date can not be less than current date !");
            return false;
        }   */
        
       /* if((Datevar <= currentDay2))
        {
        alert("Check In date starts with Current Date + 3!");
            return false;
        } */ 
        
         if((year1 > currentYear) || (year2 > currentYear))
        {
            alert("Check In or Check Out Year can not be greater than "+currentYear);
            return false;
        }
        var result = days_between(date1,date2);
        if(result>365)
        {
            alert("Difference between checkout and checkin date should be less than 365 !");
            return false;
        }
        
        
        
      return true;
    }
    
   function CalendarDisappear()
   {
        var div = document.getElementById("CalendarControl1");
   
   }
   function AppearCalendar()
   {
        var div = document.getElementById("CalendarControl1");
        div.style.display = "block";
   }
    
   function days_between(date1, date2)
    {

        // The number of milliseconds in one day
        var ONE_DAY = 1000 * 60 * 60 * 24

        // Convert both dates to milliseconds
        var date1_ms = date1.getTime()
        var date2_ms = date2.getTime()

        // Calculate the difference in milliseconds
        var difference_ms = Math.abs(date1_ms - date2_ms)
        
        // Convert back to days and return
        return Math.round(difference_ms/ONE_DAY)

    }
    
    function ChangeCheckOutDate()
    {
      var checkin;
        var checkout;
        var result;
        checkin=document.frmQBSearch.checkin.value;
        checkout=document.frmQBSearch.checkout.value;
        var date1=new Date(checkin.substring(6, 10), parseInt(checkin.substring(3, 5),10)-1, checkin.substring(0, 2));
       // var date2=new Date(checkout.substring(6, 10), parseInt(checkout.substring(3, 5),10)-1, checkout.substring(0, 2));
        var newDate = addDays(date1,2);
        
        //var date = new Date();
        var newmonth = 0;
        var newday = 0;
        newmonth = parseInt(newDate.getMonth())+1
        if(newmonth <= 9)
        {
         newmonth = "0"+newmonth;
        }
        else
        {
            newmonth = newmonth;
        }
        if(parseInt(newDate.getDate()) <= 9)
        {
          newday = "0"+newDate.getDate(); 
        }
        else
        {
            newday = newDate.getDate(); 
        }
        var finalDate = (newday+"/"+newmonth+"/"+newDate.getFullYear());
        alert(finalDate)
        checkout.value = finalDate;
        
    }
    
    function addDays(myDate,days) {
    return new Date(myDate.getTime() + days*24*60*60*1000);
    }
document.write('</script>');
document.write('<div id="CalendarControl1"></div>');

document.write('<div id="VerAffMainCntainer">');
document.write('<div id="VerAffBdyCntainer">');
document.write('<div id="VerAffHeadCntner"><div id="VerAffHead">Book Your Hotel</div></div>');
document.write('<div id="VerAffBdyPrt1"><table width="100%" border="0" cellspacing="0" cellpadding="0">');
  document.write('<tr>');
    document.write('<td colspan="2"><strong>Destination:</strong></td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2" style="padding-top:3px;"><input name="txtDestination" type="text" style="width:99%;" /></td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2" style="padding-top:3px;">(Enter: City/Country, eg Paris/France)</td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2" align="center"><div class="Verpart"></div></td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td width="50%" height="20"><strong>Check In </strong>:<br />');
      document.write('<input type="text" runat="server" id="checkin" onfocus="$(\'checkin\').select();showCalendarControl($(\'checkin\'),\'1\',\'1\');" tabindex="3" size="9" value="dd/mm/yyyy" name="checkin" maxlength="10" />');
        document.write('<a onclick="$(\'checkin\').select();showCalendarControl($(\'checkin\'),\'1\');return false" href="#">');
		   document.write(' <img src="http://www.quickbooker.com/QBSearch/images_ver/cal.gif" alt="Calendar" name="calendar_icon1" width="14" height="14" id="calendar_icon1" title="Click to open calendar" align="absmiddle" border="0">');
		document.write('</a>');
		document.write('</td>');
    document.write('<td width="50%"><strong>Check Out </strong>:<br />'); 
      document.write(' <input type="text" id="checkout" runat="server" onfocus="$(\'checkout\').select();showCalendarControl($(\'checkout\'),\'1\',\'1\');" tabindex="3" size="9" value="dd/mm/yyyy" name="checkout" maxlength="10" />');
            document.write('<a onclick="$(\'checkout\').select();showCalendarControl($(\'checkout\'),\'1\');return false" href="#">');
                document.write(' <img src="http://www.quickbooker.com/QBSearch/images_ver/cal.gif" alt="Calendar" name="calendar_icon2" width="14" height="14" id="calendar_icon2" title="Click to open calendar" align="absmiddle" border="0">');
            document.write('</a>');
            document.write('</td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2" align="center"><div class="Verpart"></div></td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2"><div id="VerAffBdyPrt2Box">');
      document.write('<table width="100%" border="0" cellpadding="2" cellspacing="0" >');
        document.write('<tr>');
          document.write('<td><strong>Single</strong> (1 sleep)</td>');
          document.write('<td width="9">:</td>');
          document.write('<td width="40"><select name="cboSingle" id="cboSingle" runat="server" >');
                    document.write('<option value="0">0</option>');
                    document.write('<option value="1">1</option>');
                    document.write('<option value="2">2</option>');
                    document.write('<option value="3">3</option>');
                    document.write('<option value="4">4</option>');
                    document.write('<option value="5">5</option>');
          document.write('</select></td>');
        document.write('</tr>');
        document.write('<tr>');
          document.write('<td><strong>Double</strong> (2 sleep)</td>');
          document.write('<td>:</td>');
          document.write('<td><select name="cboDouble" id="cboDouble" runat="server" onchange="ExtraBedDropDown(this.value);">');
             document.write('<option value="0">0</option>');
                    document.write('<option value="1">1</option>');
                    document.write('<option value="2">2</option>');
                    document.write('<option value="3">3</option>');
                    document.write('<option value="4">4</option>');
                    document.write('<option value="5">5</option>');
          document.write('</select></td>');
        document.write('</tr>');
        document.write('<tr>');
          document.write('<td><strong>Triple</strong> (3 sleep)</td>');
          document.write('<td>:</td>');
          document.write('<td><select name="cboTriple" id="cboTriple" runat="server">');
               document.write('<option value="0">0</option>');
                    document.write('<option value="1">1</option>');
                    document.write('<option value="2">2</option>');
                    document.write('<option value="3">3</option>');
                    document.write('<option value="4">4</option>');
                    document.write('<option value="5">5</option>');
          document.write('</select></td>');
        document.write('</tr>');
        document.write('<tr>');
          document.write('<td><strong>Extra Bed</strong></td>');
          document.write('<td>:</td>');
          document.write('<td><select name="extraBed" id="extraBed" runat="server">');
            document.write('<option value="0">0</option>');
          document.write('</select></td>');
        document.write('</tr>');
        document.write('<tr>');
          document.write('<td><strong>Child</strong></td>');
          document.write('<td>:</td>');
          document.write('<td><select name="cboDoubleChild" id="cboDoubleChild" runat="server">');
            document.write('<option value="0">0</option>');
                    document.write('<option value="1">1</option>');
                    document.write('<option value="2">2</option>');
                    document.write('<option value="3">3</option>');
                    document.write('<option value="4">4</option>');
                    document.write('<option value="5">5</option>');
          document.write('</select></td>');
        document.write('</tr>');
      document.write('</table>');
    document.write('</div></td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2">&nbsp;</td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2" align="center"><input name="btnsubmit" type="image" src="http://www.quickbooker.com/QBSearch/images_ver/button.gif" height="28" width="80" value="" onclick="javascript:return validatePage();" /></td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2">&nbsp;</td>');
  document.write('</tr>');
  document.write('<tr>');
    document.write('<td colspan="2"><div id="Powered"></div></td>');
  document.write('</tr>');
document.write('</table>');
document.write('</div>');
document.write('</div>');
document.write('</div>');


