function users_address_code(usr_cntry)
{
	document.write("<option value=\"\">Please select");
	// users address country of residence
	for (var i=0; i < cnt.length; i++)
	{
		if (cnt[i][0] == usr_cntry)
			document.write("<option selected value=\""+cnt[i][0]+"\">"+cnt[i][1]);
		else
			document.write("<option value=\""+cnt[i][0]+"\">"+cnt[i][1]);
	}

}

function country_selectbox()
{
	document.write("<select id=\"country_selectbox\" name=\"country\" class=\"countryselect\" onChange=\"change_city(this.options[this.selectedIndex].value)\">");
	document.write("<option value=\"\">Choose a country...");
	for (var i=0; i < cnt.length; i++)
	{
		if (cnt[i][0] == document.forms['frmquery'].cnt.value)
			document.write("<option selected value=\""+cnt[i][0]+"\">"+cnt[i][1]);
		else
			document.write("<option value=\""+cnt[i][0]+"\">"+cnt[i][1]);
	}

	document.write("</select>");
}
function country_selectbox_aff()
{
	document.write("<select id=\"country_selectbox\" name=\"country\" style=\"width:135px;\" onChange=\"change_city(this.options[this.selectedIndex].value)\">");
	document.write("<option value=\"\">then choose a city...");
	for (var i=0; i < cnt.length; i++)
	{
		if (cnt[i][0] == document.forms['frmquery'].cnt.value)
			document.write("<option selected value=\""+cnt[i][0]+"\">"+cnt[i][1]);
		else
			document.write("<option value=\""+cnt[i][0]+"\">"+cnt[i][1]);
	}

	document.write("</select>");
}

function change_city(country_code)
{
	if (document.forms['frmquery'].destination)
	{
		i = document.forms['frmquery'].destination.options.length;
		for (var j=i;j>-1;j--)
		{
			document.forms['frmquery'].destination.options[j] = null;
		}
	}

	var counter=1;
	var selected_index = 0;
	document.forms['frmquery'].destination.options[0] = new Option("Now choose a city...                 ",0,1,1);
 	for (i=0;i<cit.length;i++)
	{
		if (cit[i][0] == country_code)
		{
			document.forms['frmquery'].destination.options[counter] = new Option(cit[i][1], cit[i][2]);
			if (cit[i][2] == document.forms['frmquery'].cit.value && selected_index == 0)
				selected_index = counter;
			counter++;
		}
	}
	document.forms['frmquery'].destination.selectedIndex = selected_index;
}
// used by homepage "prices-from" links to set drop down box defaults
function setSelected(country_str, city_str)
{
	for (i=0; i<cnt.length; i++)
	{

		if (cnt[i][1] == country_str)
		{

			document.forms['frmquery'].country.selectedIndex = i+1;
			document.forms['frmquery'].cit.value = city_str;
			change_city(cnt[i][0]);

			break;
		}
	}
}

function subWindow(uri)
{
	window.open(uri,'win','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=400');
}
function mapWindow(uri)
{
	window.open(uri,'win','toolbar=yes,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=550,height=350');
}
function revWindow(uri)
{
	window.open(uri,'win','toolbar=yes,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=650,height=600');
}

function copyname(pax_type,field_type,room_no, pax_no, pax_max, copy_from)
{
	if (room_no == copy_from)
	{
		for (i=2; i <= pax_max; i++)
		{
			if (document.checkout["ROOM"+i+"_"+pax_type+pax_no+"_"+field_type] && document.checkout["ROOM"+i+"_"+pax_type+pax_no+"_"+field_type].value == "")
			{
				document.checkout["ROOM"+i+"_"+pax_type+pax_no+"_"+field_type].value = document.checkout["ROOM"+copy_from+"_"+pax_type+pax_no+"_"+field_type].value;
			}
		}
	}
}

function copytitle(room_no,pax_no,pax_max,copy_from)
{
	if (room_no == copy_from)
	{
		for (i=2; i<= pax_max; i++)
		{
			if (document.checkout["ROOM"+i+"_ADT"+pax_no+"_TITLE"] && document.checkout["ROOM"+i+"_ADT"+pax_no+"_TITLE"].value == "")
			{
				document.checkout["ROOM"+i+"_ADT"+pax_no+"_TITLE"].selectedIndex = document.checkout["ROOM"+copy_from+"_ADT"+pax_no+"_TITLE"].selectedIndex;
			}
		}
	}
}
function copyage(room_no,pax_no,pax_max,copy_from)
{
	if (room_no == copy_from)
	{
		for (i=2; i<= pax_max; i++)
		{
			if (document.checkout["AGE_"+i+"_"+pax_no] && document.checkout["AGE_"+i+"_"+pax_no].value == "")
			{
				document.checkout["AGE_"+i+"_"+pax_no].selectedIndex = document.checkout["AGE_"+copy_from+"_"+pax_no].selectedIndex;
			}
		}
	}
}

function validate_paxes(myform, hotelid)
{
	show_kidages(myform, hotelid);


	if (Math.abs(myform['ADT1'].value) + Math.abs(myform['CHD1'].value) > 4)
	{
		alert("Maximum of 4 guests per room. For more than this please split the party into smaller groups and search for rooms separately.");
		return(false);
	}
	if (document.frmquery['destination'].value == '0' || document.frmquery['destination'].value == '' || document.frmquery['destination'].value == '99999')
	{
		alert("Please select a city/town/area");
		return(false);
	}
	return true;
}
function validate_kidages(myform)
{
	if ((Math.abs(myform['CHD1'].value) >= 1 && Math.abs(myform['KID_AGE1'].value < 1))
	  ||(Math.abs(myform['CHD1'].value) == 2 && Math.abs(myform['KID_AGE2'].value < 1)))
	{
		alert("Please enter child ages.");
		return(false);
	}

	return true;
}
function wait_page(uri)
{
	var popw = 400, poph = 220;
	var w = 480, h=340;
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var leftpos = (w-popw)/2, toppos=(h-poph)/2;
//	window.open('?OPCODE=waitpage&msg='+msg,'waitpage','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width='+popw+',height='+poph+',top='+toppos+',left='+leftpos);
	window.open(uri,'waitpage','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width='+popw+',height='+poph+',top='+toppos+',left='+leftpos);
}
function show_kidages2(num_kids)
{
	if (num_kids == 0)
	{
//		document.getElementById(kidage1).style.display = '
	}
}


function show_kidages(myform, hotelid)
{
	if ( myform['CHD1'].value ==  1)
	{
		//document.getElementById('kidage_' + hotelid).style.display = 'inline';
		document.getElementById('kidage_' + hotelid + '_0').style.display = 'inline';
		document.getElementById('kidage_' + hotelid + '_1').style.display = 'none';
	}
	else if ( myform['CHD1'].value ==  2)
	{
		//document.getElementById('kidage_' + hotelid).style.display = 'inline';
		document.getElementById('kidage_' + hotelid + '_0').style.display = 'inline';
		document.getElementById('kidage_' + hotelid + '_1').style.display = 'inline';
	}
	else
	{
		//document.getElementById('kidage_' + hotelid).style.display = 'none';
		document.getElementById('kidage_' + hotelid + '_0').style.display = 'none';
		document.getElementById('kidage_' + hotelid + '_1').style.display = 'none';
	}
}

function get_co_date(myform, hotelid)
{
	var dtMonthYr, dtDay, dtCheckout, dtNoOfNights,  dtYr, dtDisplayDate, dtDisplayDay, dtDisplayMonth, dtDisplayYear, dtReturnMonthYr
	var dtDisplayCheckout, dtMonth

	dtNoOfNights = myform['nights'].value
	dtMonthYr = myform['CI_YYYYMM'].value
	dtDay = myform['CI_DD'].value
	dtDisplayMonth = dtMonthYr.substring(5,7)
	dtYr = dtMonthYr.substring(0,4)
	dtDay = parseInt(dtDay) + parseInt(dtNoOfNights)
	dtCheckout = new Date(dtYr, dtDisplayMonth, dtDay)
	dtDisplayDay = dtCheckout.getDate().toString()
	dtDisplayMonth = dtCheckout.getMonth().toString()
	dtDisplayYear = dtCheckout.getFullYear().toString()

	if (dtDisplayDay.valueOf() < 10)
	{
		dtDisplayDay = "0" +  dtDisplayDay
	}

	document.getElementById("co_date" + hotelid).innerHTML = dtDisplayDay + "/" + dtDisplayMonth;

}

function IsNumeric(sText)
{
	var ValidChars = "0123456789";
	var IsNumeric=true;
	var Char;

	for (i=0; i<sText.length && IsNumeric == true; ++i)
	{
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1)
		{
			IsNumeric = false;
		}
	}

	return IsNumeric;
}

function loadArr (vlu)
{
	if (vlu == "false"|| vlu == "none" || vlu == "sel")
	{
		return;
	}

	$("country").src = "/qsoffbuild.cgi?area=" + vlu;
	loadDropOff(vlu);
}

function loadDropOff (vlu2)
{
	if (vlu2 == "false"|| vlu2 == "none" || vlu2 == "sel")
	{
		return;
	}

	$("dropoff").src = "/qsdropoffbuild.cgi?pickup=" + vlu2;
}



function validate_ha_query_box()
{
	// TO DO - check the start and end dates

	if (document.forms['details'].area.options[document.forms['details'].area.selectedIndex].text == "none" || 
	    document.forms['details'].area.options[document.forms['details'].area.selectedIndex].text == "sel" || 
		document.forms['details'].tlocation.options[document.forms['details'].tlocation.selectedIndex].text == "" || 
		document.forms['details'].tdropoff.options[document.forms['details'].tdropoff.selectedIndex].text == "" || 
		document.forms['details'].tlocation.options[document.forms['details'].tlocation.selectedIndex].text == "sel" || 
		document.forms['details'].tdropoff.options[document.forms['details'].tdropoff.selectedIndex].text == "sel")
	{
		window.alert("Please select location, pickup and dropoff");
		return 0;
	}

	if (document.details.fiDriverAge.value == "")
	{
		window.alert("Please enter the driver's age");
		return 0;
	}

	if (document.details.fiDriverAge.value < 21)
	{
		window.alert("We cannot hire cars to drivers younger than 21 years");
		return 0;
	}

	return 1;
}

function populate (frm, arr, arrval, len, typ)
{
	rootLength = len;
	if (typ != "tdropoff")
	{
		document.details.loclistpickdisp.value = arr;
		document.details.loclistpickengl.value = arrval;
	}
        else
	{
		document.details.loclistdropdisp.value = arr;
		document.details.loclistdropengl.value = arrval;
	}

	var slct = -1;
	var searchtext = "";

	if (typ == "tdropoff")
	{
		if (IsNumeric(frm.slct2.value))
		{
			slct = parseFloat (frm.slct2.value);
			if (slct == 0)
			{
				slct = 1;
			}
		}
		else
		{
			// slct2 probably holds the actual text
			searchtext = frm.slct2.value;
		}
        }
	else
	{
		if (IsNumeric(frm.slct.value))
		{
			slct = parseFloat (frm.slct.value);
		}
		else
		{
			// slct probably holds the actual text
			searchtext = frm.slct.value;
		}

		arr.sort ();
        }

        if (frm[typ])
	{
		frm[typ].length = 1;
		frm[typ][0] = new Option("select a location", "sel");

                for (var i = 0; i < arr.length; i++)
		{
                    frm[typ][frm[typ].length] = new Option (arr[i], arr[i]);

		    if (slct < 0 && arr[i] == searchtext)
			{
				slct = i + 1;
			}
                }

		if (typ != "tdropoff")
		{
			frm[typ][slct].selected = true;
		}
		else if (len > 0)
		{
			frm[typ][slct].selected = true;
		}
	}
}

function ckDstn(ckArea)
{
	if (ckArea != "none" && ckArea != "")
	{
		// Put up a message while waiting
		document.details.tlocation.length = 1;
		document.details.tlocation[0] = new Option("Please wait, loading", "none");

		new Ajax.Updater('carpickup','/qsoffbuild.cgi?area='+document.details.area[document.details.area.selectedIndex].value + '&slct=' + document.details.slct.value, {evalScripts:true,method:'get'})
		$('cardropoff').innerHTML = '<select accessKey="o" name="tdropoff" class="cardestinationselect"></select>'
	}
	else if (ckArea == "none")
	{
		window.alert("Please select a specific destination from the dropdown list.");
		document.details.tlocation.length = 1;
   		if (document.details.tdropoff)
		{
			if (document.details.tdropoff.length)
			{
				document.details.tdropoff.length = 1;
			}
		}
	}
}

function ckPickUp(ckArea)
{
	if (ckArea != "none" && ckArea != "")
	{
		new Ajax.Updater('cardropoff','/qsdropoffbuild.cgi?pickup='+ckArea, {evalScripts:true,method:'get'})
	}
	else if (ckArea == "none")
	{
		window.alert("Please select a pickup from the dropdown list");
		if (document.details.tdropoff)
		{
			if (document.details.tdropoff.length)
			{
				document.details.tdropoff.length = 1;
			}
		}
	}
}

function openMapWindow(parms)
{
    mapWindow = open('/?OPCODE=map&'+parms, 'map', 'height=600, width=800, location=no, resizable=yes');

    if (mapWindow.opener == null)
    {
            mapWindow.opener = self;
    }

    mapWindow.focus();
}

function resizemap_leavingspace(space)
{
	var height = f_clientHeight();
	
	if (height > 0)
	{
		var newheight = (height - space)+"px";
		document.getElementById("map").style.height=newheight;
	}
}

function resizemap()
{
	var height = f_clientHeight();
	
	if (height > 0)
	{
		var newheight = (height-97)+"px";
		document.getElementById("map").style.height=newheight;
	}
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function openFrontdeskMapWindow(parms, lat, lng, title)
{
    //alert("openFrontdeskMapWindow( long = " + lng + ", lat=" + lat + ")");
    mapWindow = open('/frontdesk.cgi?OPCODE=frontdesk_map&LATITUDE='+lat+'&LONGITUDE='+lng+"&"+parms, title, 'height=570, width=830, location=no');

    if (mapWindow.opener == null)
    {
            mapWindow.opener = self;
    }

    mapWindow.focus();
}


function bumpToTop(our_product_id)
{
    if (self.map != null)
    {
        self.map.closeInfoWindow();
    }

    if (self.opener != null)
    {
        self.opener.focus();
        self.opener.location="/?OPCODE=bumptotop&our_product_id=" + our_product_id;
    }
}

var smallMap = null;
var flag = 1;
var mapPopupEnabled = false;


// add control to search the map area
function MapSearchControl() {}
if (mapit) {MapSearchControl.prototype = new GControl()};
MapSearchControl.prototype.initialize = function(map)
{
	var container = document.createElement("div");
  	var mapSearchDiv = document.createElement("div");
  	this.setButtonStyle_(mapSearchDiv);
 	container.appendChild(mapSearchDiv);
	mapSearchDiv.appendChild(document.createTextNode("Search Map Area>>"));
 	GEvent.addDomListener(mapSearchDiv, "click", function() { geo_search(); });
 	map.getContainer().appendChild(container);
 	return container;
}
MapSearchControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(5, 10)); }
MapSearchControl.prototype.setButtonStyle_ = function(button)
{
	button.style.color = "#0000cc";
	button.style.backgroundColor = "#ffff66";
	button.style.fontFamily = "Verdana,sans-serif";
	button.style.fontWeight = "bold";
	button.style.border = "1px solid black";
	button.style.padding = "2px";
	button.style.marginBottom = "3px";
	button.style.textAlign = "center";
	button.style.cursor = "pointer";
	button.style.fontSize="13px";
}
function MapCentreOnControl() {}
if (mapit) {MapCentreOnControl.prototype = new GControl()};
MapCentreOnControl.prototype.initialize = function(map)
{
	var container = document.createElement("div");
	var centre_on = document.getElementById('centre_on');
	if (centre_on)
	{ 
		$('centre_on').style.display = "inline";
		container.appendChild(centre_on); 
	}
	map.getContainer().appendChild(container);
	return container;
}
MapCentreOnControl.prototype.getDefaultPosition = function (){return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0)); }

function loadSmallMap()
{
    if (GBrowserIsCompatible() && smallMap == null)
    {
        var mapContainer = document.getElementById("small_map_div");
        if (mapContainer == null) return;
		mapContainer.innerHTML="";
		smallMap = new GMap2(mapContainer);
		smallMap.setCenter(new GLatLng(0,0), 1);
        // moved to its own function to call after window has loaded to stop ie op aborted bug
		// smallMap.addControl(new MapSearchControl());
		//smallMap.addControl(new GScaleControl());
        //smallMap.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5,30)));
        //smallMap.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0,0)));
    }
}
function addmapcontrols()
{
        //smallMap.addControl(new MapSearchControl());
	smallMap.addControl(new GScaleControl());
        smallMap.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5,30)));
        smallMap.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0,0)));
}

function m(lat,lng,price_band,name,popup_html,hotidx,title_html)
{

        var gmarker = new GMarker(new GLatLng(lat, lng), {icon: ouricons[price_band] });
        GEvent.addListener(gmarker, "click", function() {ajaxwin=dhtmlmodal.open('hoteldetail', 'ajax', '/?OPCODE=hoteldetail_ajax&HOTIDX='+hotidx, name, 'width=800px,height=500px,center=1,resize=0,scrolling=1','recal') } ); 


		//GEvent.addListener(gmarker, "mouseover", function(){smallMap.openInfoWindowHtml(point,popup_html)});
		GEvent.addListener(gmarker, "mouseover", function(){Tip(title_html + popup_html)});
	   

		smallMap.addOverlay(gmarker); 
}
function markerV2(idx)
{
        var point = new GLatLng(latitudes[idx], longitudes[idx]);
        var ouricon = new GIcon();
        ouricon.image = "/images/markers/priceband" + price_bands[idx] + ".gif";
        ouricon.shadow = null;
        ouricon.iconSize = new GSize(20, 34);
        ouricon.shadowSize = null;
		ouricon.transparent = null;
		ouricon.infoShadowAnchor = null;
        ouricon.iconAnchor = new GPoint(10, 34);
        ouricon.infoWindowAnchor = new GPoint(10, 34);
        var gmarker = new GMarker(point, {icon: ouricon });
        //GEvent.addListener(gmarker, "click", function() {ajaxwin=dhtmlwindow.open('hoteldetail', 'ajax', '/?OPCODE=hoteldetail_ajax&HOTIDX='+idx, names[idx], 'width=800px,height=500px,center=1,resize=0,scrolling=1','recal') } ); 
		//GEvent.addListener(gmarker, "mouseover", function(){Tip(popup_htmls[idx])});
		smallMap.addOverlay(gmarker); 
}

function attraction_markerV2(lat,lng,name,img,txt)
{
	var point = new GLatLng(lat, lng);
	var ouricon = new GIcon();
	ouricon.image = "/images/markers/attraction.png";
	ouricon.shadow = null;
	ouricon.iconSize = new GSize(20, 34);
       ouricon.shadowSize = null;
	ouricon.transparent = null;
	ouricon.infoShadowAnchor = null;

    ouricon.iconAnchor = new GPoint(10, 34);
    ouricon.infoWindowAnchor = new GPoint(10, 34);
	var gmarker = new GMarker(point, {title: name, icon: ouricon });
	GEvent.addListener(gmarker, "mouseover", function(){Tip("<div class='mapinfo'><div class='mapinfohead'>" + name + "</div><div class='mapinfoimage'><img src='" + img + "'/></div><div class='mapinfoblurb'>" + txt + "</div></div>")});
	smallMap.addOverlay(gmarker); 
}

function filter(filtername,filtervalue,filtervalue2)
{
	$('hotelresults').innerHTML = "";
	new Effect.Appear("listhotelwait");
	smallMap.clearOverlays();
	new Ajax.Updater('hotelresults','/',{evalScripts:true,onComplete:function(){$("listhotelwait").style.display="none"; },parameters:{OPCODE:'filter_ajax',FILTERTYPE:filtername,FILTER:filtervalue,FILTER2:filtervalue2}});
}

function show1marker(idx)
{
	smallMap.clearOverlays();
	smallMap.panTo(new GLatLng(latitudes[idx],longitudes[idx]));
	m(latitudes[idx],longitudes[idx],price_bands[idx],names[idx],popup_htmls[idx],idx,"");
}

function panto(latlng,title)
{
	var dn = latlng.split(",",2);
	//smallMap.setZoom(15);
	//smallMap.setCenter(new GLatLng(dn[0],dn[1]),15);
	//smallMap.clearOverlays();
	//smallMap.addOverlay(new GMarker(new GLatLng(dn[0],dn[1])),{title:title});
	smallMap.panTo(new GLatLng(dn[0],dn[1]));
	smallMap.setCenter(new GLatLng(dn[0],dn[1]),15);
	//smallMap.setZoom(15);
}

//YAHOO.namespace("example.calendar");
//YAHOO.util.Event.addListener(window, "load", cal_init);

var selectHandler = function(type,args,obj)
{
    var selectedDates = args[0];
    var date = selectedDates[0];
    var year = date[0], month = date[1], day = date[2];
    var ci_dd = document.getElementById("CI_DD");
    ci_dd.value = day;
    var ci_yyyymm = document.getElementById("CI_YYYYMM");
    if(month<10)month="0"+month;
    ci_yyyymm.value = year + "-" + month;
    var oElement = document.getElementById("calcontainer");
    oElement.style.display="none";
};
function cal_init() 
{
    maxdate = new Date();
    maxdate.setFullYear(maxdate.getFullYear() + 1);
    YAHOO.example.calendar.cal1 = new YAHOO.widget.CalendarGroup("cal1","calcontainer",
                                                    {
													pages:3,
                                                    title: "Check-in date:",
                                                    close: true,
                                                    mindate: new Date(),
                                                    maxdate: maxdate,
                                                    START_WEEKDAY: 1
                                                    }
                                                );


    YAHOO.example.calendar.cal1.selectEvent.subscribe(selectHandler, YAHOO.example.calendar.cal1, true);

    var oElement = document.getElementById("calendar_icon");
    YAHOO.util.Event.addListener(oElement, "click", updateCal, YAHOO.example.calendar.cal1, true);

    YAHOO.example.calendar.cal1.cfg.setProperty("MDY_DAY_POSITION", 1);
    YAHOO.example.calendar.cal1.cfg.setProperty("MDY_MONTH_POSITION", 2);
    YAHOO.example.calendar.cal1.cfg.setProperty("MDY_YEAR_POSITION", 3);
}
function updateCal()
{
    var ci_dd = document.getElementById("CI_DD");
    var ci_yyyymm = document.getElementById("CI_YYYYMM");

    var newDate = ci_dd.value + "/" + ci_yyyymm.value.substr(5,2) + "/" + ci_yyyymm.value.substr(0,4) ;
    YAHOO.example.calendar.cal1.select(newDate);
    var firstDate = YAHOO.example.calendar.cal1.getSelectedDates()[0];

    if (firstDate)
        YAHOO.example.calendar.cal1.cfg.setProperty("pagedate", (firstDate.getMonth()+1) + "/" + firstDate.getFullYear());

    YAHOO.example.calendar.cal1.render();
    YAHOO.example.calendar.cal1.show();
}
// DOCKING
//
var offsetfromedge=0      //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array() //array to cache dockit instances
var dkclear=new Array()   //array to cache corresponding clearinterval pointers

function dockit(el, duration){
this.source=document.all? document.all[el] : document.getElementById(el);
this.source.height=this.source.offsetHeight;
this.docheight=truebody().clientHeight;
this.duration=duration;
this.pagetop=0;
this.elementoffset=this.getOffsetY();
dockarray[dockarray.length]=this;
var pointer=eval(dockarray.length-1);
var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;
eval(dynexpress);
}

dockit.prototype.getOffsetY=function(){
var totaloffset=parseInt(this.source.offsetTop);
var parentEl=this.source.offsetParent;
while (parentEl!=null){
totaloffset+=parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function dockornot(obj){
obj.pagetop=truebody().scrollTop;
if (obj.pagetop>obj.elementoffset) //detect upper offset
obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge+"px";
else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset
obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge+"px";
else
obj.source.style.top=0;
}


function truebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body }
function roomtip()
{
	Tip('<strong>Included boards are as follows</strong><br><br><table class="roomtip"><tr><td><strong>RO</strong></td><td width="300">Room only - no meals provided</td></tr><tr><td><strong>CB</strong></td><td>Continental breakfast - usually tea/coffee with croissant/pastries</td></tr><tr><td><strong>BB</strong></td><td>Bed and Breakfast - full cooked or buffet breakfast</td></tr><tr><td><strong>AB</strong></td><td>American breafast - full cooked, possibly pancakes</td></tr><tr><td><strong>HB</strong></td><td>Half board - breakfast and evening meal</td></tr><tr><td><strong>FB</strong></td><td>Full board - breakfast, lunch and evening meal</td></tr><tr><td><strong>AI</strong></td><td>All inclusive - all meals and drinks, including local alchohol</td></tr><tr><td><strong>SC</strong></td><td>Self catering - accommodation has kitchen facilities</td></tr></table><br><strong>Common Room Types</strong><br><br><table width="430" class="roomtip"><tr><th valign="top">standard</th><td >Standard "run of house" room - best available allocated on arrival</tr><tr><th>double</th><td>Room has only one large bed for two people</td></tr><tr><th>twin</th><td>Two separate beds</td></tr><tr><th valign="top">double/twin</th><td>Room is available as either a double or a twin bedded configuration, selected when confirming the room.</td></tr></table>Other room types are as described.');

}

function showpic(pic,total)
{
	pic_on = document.all ? document.all['hotelbigimage'+pic] : document.getElementById('hotelbigimage'+pic);
	for (var i = 1;i <= total; i++)
	{
		pic_off = document.all ? document.all['hotelbigimage'+i] : document.getElementById('hotelbigimage'+i);
		pic_off.style.display = "none";
	}
	pic_on.style.display = "block";
	
}

 var ie=document.all
 var dom=document.getElementById
 var ns4=document.layers
 var calunits=document.layers? "" : "px"
 var bouncelimit=32 //(must be divisible by 8)

 function initbox(e){
 if (!dom&&!ie&&!ns4) 
 return
 crossobj=(dom)?document.getElementById("cartdropin").style : ie? document.all.dropin : document.dropin
 scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
 crossobj.top=scroll_top-250+calunits
 crossobj.visibility=(dom||ie)? "visible" : "show"
 dropstart=setInterval("dropin()",50)
 }

 function dropin(){
 scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
 if (parseInt(crossobj.top)<100+scroll_top)
 crossobj.top=parseInt(crossobj.top)+40+calunits
 else{
 clearInterval(dropstart)
 //bouncestart=setInterval("bouncein()",50)
 }
 }

 function bouncein(){
 crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
 if (bouncelimit<0)
 bouncelimit+=8
 bouncelimit=bouncelimit*-1
 if (bouncelimit==0){
 clearInterval(bouncestart)
 }
 }

 function dismissbox(){
 if (window.bouncestart) clearInterval(bouncestart)
 crossobj.visibility="hidden"
 }

 function truebody(){
 return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
 }


