﻿
var ddlDate;
function the_date(defaultDate){
    var arrivalDate = "-- ArrivalDate --";    
    var shortDayName = new Array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
    var shortMonthName = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

	var date = new Date();
	var select = ddlDate;

	var firstDay = date.getDate();
	if(parseInt(firstDay) < 10) firstDay = "0" + firstDay;
	var firstMonth = date.getMonth() + 1;
	if(parseInt(firstMonth) < 10) firstMonth = "0" + firstMonth;

	var firstOption = new Option(arrivalDate);
	firstOption.value = date.getFullYear() + firstMonth + firstDay;

    document.writeln("<SELECT name=\"d\" class=\"lr-input\" id=\"d\">");

    for(var d=0;d<366;d++)
	{
		var day = date.getDate();
	    if(parseInt(day) < 10) day = "0" + day;
		var month = date.getMonth() + 1;
		if(parseInt(month) < 10) month = "0" + month;
		var option = new Option(shortDayName[date.getDay()] + " " + date.getDate() + " " + shortMonthName[date.getMonth()] + " " + date.getFullYear());
		option.value = date.getFullYear() + "" + month +  "" +  day;
		if (defaultDate == option.value)
		{
		        document.writeln("<OPTION value=" + option.value + " selected=\"selected\">" + shortDayName[date.getDay()] + " " + date.getDate() + " " + shortMonthName[date.getMonth()] + " " + date.getFullYear() + "</option>");
		}
		else
		{
		    document.writeln("<OPTION value=" + option.value + ">" + shortDayName[date.getDay()] + " " + date.getDate() + " " + shortMonthName[date.getMonth()] + " " + date.getFullYear() + "</option>");
		}
		date.setDate(date.getDate() + 1);
	}

	document.writeln("</SELECT>");
}

function buildLRSearchBanner(partnerid, defaultKeyword, defaultNights, defaultDate)
{
    document.writeln("<style type=\"text/css\">")
    document.writeln("<!--")
    
    document.writeln(".lr-cl { clear:both; }")
    document.writeln(".lr-cen { text-align:center; margin:15px 0 0; padding:0; }")
    document.writeln(".lr-bold { font-weight:bold; font-size:14px; }")
    document.writeln("#lr-specialoff { background:#514F4F url(/images/so4.gif) no-repeat; width:270px; height:660px; padding:0; font:12px Arial, Helvetica, sans-serif; }")
    document.writeln("#lr-specialoff .lr-input { font:12px Arial, Helvetica, sans-serif; }")
    document.writeln("#lr-specialoff select.lr-input { width:210px; }")
    document.writeln("#lr-specialoff input.lr-input { width:210px; }")
    document.writeln(".lr-pad { padding:90px 30px 0; }")
    document.writeln(".lr-srchtxt { font:12px Arial, Helvetica, sans-serif; padding:10px 0 5px; color:#fff; font-weight:bold; text-align:left; }")
    document.writeln(".lrbutton { margin:4px 0 0; }")
	document.writeln("#lr-offsrchbox {  }")
 	document.writeln("#lr-tickboxes { color:#fff; }")
 	document.writeln("#lr-tickboxes .lr-pad { padding:95px 0 0; }")
	document.writeln("table.lr-ticks, table.lr-ticks tr { margin:0; padding:0; }")
	document.writeln("table.lr-ticks td { font:12px Arial, Helvetica, sans-serif; color:#fff; padding:3px; margin:0; vertical-align:top;  }")
    
    document.writeln("-->")
    document.writeln("</style>")
    document.writeln("<div id=\"lr-specialoff\">")
    document.writeln("<form method=\"post\" action=\"http://www.laterooms.com/en/p" + partnerid + "/Hotels.aspx?q=10_special-offers\">")
    document.writeln("<div class=\"lr-pad\">")
    document.writeln("<div id=\"lr-offsrchbox\">")
    document.writeln("<div class=\"lr-srchtxt\">Enter your destination</div>")
    document.writeln("<input name=\"k\" type=\"text\" size=\"17\" value=\"" + defaultKeyword + "\" class=\"lr-input\" onFocus=\"if (this.value==this.defaultValue) this.value='';\" onBlur=\"if ((1) && (this.value=='')) this.value=this.defaultValue;\">")
    document.writeln("<div class=\"lr-srchtxt\">Arrival date</div>")
    the_date(defaultDate);
    document.writeln("<div class=\"lr-srchtxt\">Number of nights</div>")
    document.writeln("<select size=\"1\" name=\"n\" class=\"lr-input\">")
    if (defaultNights == null)
    {
        document.writeln("<option selected=\"selected\" value=\"1\">-- No of Nights --</option>")
    }
    else
    {
        document.writeln("<option value=\"1\">-- No of Nights --</option>")
    }
    var i = 1;
    while (i < 8)
    {
        if (i == 1)
        {
            if (defaultNights == i)
            {
                document.writeln("<option value=\"" + i + "\" selected=\"selected\">" + i + " Night</option>")    
            }
            else
            {
                document.writeln("<option value=\"" + i + "\">" + i + " Night</option>")    
            }
        }
        else
        {
            if (defaultNights == i)
            {
                document.writeln("<option value=\"" + i + "\" selected=\"selected\">" + i + " Nights</option>")    
            }
            else
            {
                document.writeln("<option value=\"" + i + "\">" + i + " Nights</option>")    
            }
        }
        
        i++;
    }
    document.writeln("</select>")
    document.writeln("<div class=\"lr-srchtxt\">Room sleeps</div>")
    document.writeln("<select size=\"1\" name=\"rt\" class=\"lr-input\">")
    document.writeln("<option value=\"0,0\">-- Room Sleeps --</option>")
    document.writeln("<option value=\"1,0\">1 person</option>")
    document.writeln("<option value=\"2,0\">2 people</option>")
    document.writeln("<option value=\"2,1\">2 + 1 child</option>")
    document.writeln("<option value=\"2,2\">2 + 2 children</option>")
    document.writeln("<option value=\"2,3\">2 + 3 children</option>")
    document.writeln("<option value=\"3,0\">3 people</option>")
    document.writeln("<option value=\"4,0\">4 people</option>")
    document.writeln("<option value=\"5,0\">5 people</option>")
    document.writeln("<option value=\"6,0\">6 people</option>")
    document.writeln("<option value=\"7,0\">7 people</option>")
    document.writeln("</select>")
    document.writeln("</div>")
    document.writeln("<div id=\"lr-tickboxes\">")
    document.writeln("<div class=\"lr-pad\">")
    document.writeln("<table class=\"lr-ticks\" cellpadding=\"0\" cellspacing=\"0\">")
    document.writeln("<tr>")
    document.writeln("<td><input type=\"checkbox\" checked=\"checked\" name=\"specialoffers\" value=\"discount\" /></td>")
    document.writeln("<td><span class=\"lr-bold\">Extra special discounts</span> - Deals offering even more value for money</td>")
    document.writeln("</tr>")
    document.writeln("<tr>")
    document.writeln("<td><input type=\"checkbox\" checked=\"checked\" name=\"specialoffers\" value=\"incentive\" /></td>")
    document.writeln("<td><span class=\"lr-bold\">Added value extras</span> - Get more for your money, with some wonderful little extras</td>")
    document.writeln("</tr>")
    document.writeln("<tr>")
    document.writeln("<td><input type=\"checkbox\" checked=\"checked\" name=\"specialoffers\" value=\"freestay\" /></td>")
    document.writeln("<td><span class=\"lr-bold\">Free hotel nights</span> - Get a night, free</td>")
    document.writeln("</tr>")
    document.writeln("<tr>")
    document.writeln("<td><input type=\"checkbox\" checked=\"checked\" name=\"specialoffers\" value=\"package\" /></td>")
    document.writeln("<td><span class=\"lr-bold\">Special occasions</span> - Package deals when you stay more than one night</td>")
    document.writeln("</tr>")
    document.writeln("</table>")
    document.writeln("<div class=\"lr-cen\">")
    document.writeln("<input type=\"image\" name=\"_:SearchPanel:search\" id=\"__SearchPanel_search\" class=\"lrbutton\" src=\"/images/so2_search.gif\" border=\"0\" />")
    document.writeln("</div>")
    document.writeln("</div>")
    document.writeln("</div>")    
    document.writeln("</div>")
    document.writeln("</form>")
    document.writeln("</div>")
}

