var gClientIsGecko = (window.controllers) ? true : false;
var gClientIsOpera = (window.opera) ? true : false;
var gClientIsIE    = (document.all && !gClientIsOpera) ? true : false;
var gClientIsIE5   = (gClientIsIE && /MSIE 5\.0/.test(navigator.appVersion)) ? true : false;
var gClientIsMac   = (/Mac/.test(navigator.appVersion)) ? true : false;


function showDiv (el, div, alignX, alignY) {
	// (i) popups etc
	if (document.getElementById){
    	var i = document.getElementById(el);
		var c = document.getElementById(div);
        if (c.style.display != "block"){
			

			var box = getDimensions(i);
			var left = box.x, top = box.y;

			c.style.visibility = 'hidden'; // Needed to measure
			c.style.display = "block";     // Needed to measure
			if(alignX == 'left')
				left -= c.offsetWidth;
			else
				left += i.offsetWidth;
			if(alignY == 'top')
				top -= c.offsetHeight;
			else
				top += i.offsetHeight;
			if(top<10)
				top = 10;
			// XXX: Don't know why IE5 needs this here and not for calendar
			if(gClientIsIE5) {
				left += document.body.scrollLeft;
				top += document.body.scrollTop;
			}
        	c.style.left = left+'px';
	        c.style.top = top+'px';
			c.style.visibility = 'visible';
		} else {
			c.style.display="none";
		}
	}
}

function hideDiv (div) {
	if (document.getElementById){
		var c=document.getElementById(div);
		c.style.display="none";
	}
}

var hide  = true;


function getDimensions( elm ) {
	var box = { x:0, y:0, w:0, h:0 };
	if(document.getBoxObjectFor) {
		var boxRef = document.getBoxObjectFor(elm);
		box.x = boxRef.x;
		box.y = boxRef.y;
		box.w = boxRef.width;
		box.h = boxRef.height;
	}
	else if(elm.getBoundingClientRect) {
		var rxIE50 = /MSIE 5\.0/g;
		var boxRef = elm.getBoundingClientRect();
		box.x = boxRef.left;
		box.y = boxRef.top;
		box.w = (boxRef.right - boxRef.left);
		box.h = (boxRef.bottom - boxRef.top);
		if(document.compatMode && document.compatMode != 'BackCompat') {
			box.x += document.documentElement.scrollLeft - 2;
			box.y += document.documentElement.scrollTop - 2;
		}
		else if(!gClientIsIE5) {
			box.x += document.body.scrollLeft - 2;
			box.y += document.body.scrollTop - 2;
		}
	}
	else {
		box.w = elm.offsetWidth;
		box.h = elm.offsetHeight;
		while(elm) {
			box.x += elm.offsetLeft;
			box.y += elm.offsetTop;
			if(elm.offsetParent)
				elm = elm.offsetParent;
			else
				break;
		}
	}

	return box;
}

function fldFocus(fld)
{
	if (fld.value == "0" || fld.value == "any")
		fld.value = "";
}

function fldBlur(fld, FrTo)
{
	if (fld.value == "")
	{
		if (FrTo == "fr")
			fld.value = "0";
		if (FrTo == "to")
			fld.value = "any";
	}
}

function GetCountryCode(Control)
{
	return document.getElementById(Control).options[document.getElementById(Control).selectedIndex].value;
}
function SetControlValue(ControlName, Value)
{
	document.getElementById(ControlName).value = Value;
}
function OpenWindow(page,pagename,w,h)
{
	if(document.all)
	{
		h=h+29;
		w=w+10;
	}
	win=window.open(page,pagename,'menubar=no,status=yes,resizable=no,scrollbars=yes,directories=no,location=no,toolbar=no,width='+w+',height='+h);
	win.resizeTo(w,h);
	win.moveTo((screen.width-w)/2,(screen.height-h)/2);
}
function CityListUpdate()
{
    if(TimerForCity != null) clearTimeout(TimerForCity);
    TimerForCity = setTimeout('GetCity()', 100);
}

var __CountryCode       = "";
var __City              = "";
var __RoomType          = "";
var __AmountOfRooms     = "";
var __ArrivalDate       = "";
var __DepartureDate     = "";
var __FromPrice         = "";
var __ToPrice           = "";
var __HotelName         = "";
var __HotelsClass5      = "";
var __HotelsClass4      = "";
var __HotelsClass3      = "";
var __HotelsClass2      = "";
var __HotelsClass1      = "";
var __HotelsClass0      = "";

function SaveFirstParameters()
{
    __CountryCode   = document.getElementById("CountryCode").options[document.getElementById("CountryCode").selectedIndex].value;
    __City          = document.getElementById("City").value;
    __RoomType      = document.getElementById("RoomType").value;
    __AmountOfRooms = document.getElementById("AmountOfRooms").value;
    __ArrivalDate   = document.getElementById("ArrivalDate").value;
    __DepartureDate = document.getElementById("DepartureDate").value;
    __FromPrice     = document.getElementById("FromPrice").value;
    __ToPrice       = document.getElementById("ToPrice").value;
    __HotelName     = document.getElementById("LikeHotelName").value;
    __HotelsClass5  = document.getElementById("HotelClass5").checked;
    __HotelsClass4  = document.getElementById("HotelClass4").checked;
    __HotelsClass3  = document.getElementById("HotelClass3").checked;
    __HotelsClass2  = document.getElementById("HotelClass2").checked;
    __HotelsClass1  = document.getElementById("HotelClass1").checked;
    __HotelsClass0  = document.getElementById("HotelClass0").checked;
}

function ResetForm()
{
    Clr();
}
