function formJump(url)
{
	if (url != '')
		self.location = url;
}

function changeButtonClass(b)
{
	if ((b.style.color == '#000000') || (b.style.color == 'rgb(0, 0, 0)'))
	{
		b.style.color='#008000';
	}
	else
	{
		b.style.color='#000000';
		b.style.cursor='pointer';
	}
}

function changeButtonClassGrey(b)
{
	if ((b.style.color == '#000000') || (b.style.color == 'rgb(0, 0, 0)'))
	{
		b.style.color='#808080';
	}
	else
	{
		b.style.color='#000000';
		b.style.cursor='pointer';
	}
}

function openCalendar(url)
{
  var params="menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,dependent,top=0,left=0,width=680,height=210";
  popupWin = window.open(url, 'calendar',params);
  popupWin.focus();
}

function createDropdown(b,e,s)
{
	for (i=b; i<=e; i++)
	{
		if (i==s)
			document.write('<option value="'+i+'" selected="selected">'+i+'</option>');
		else
			document.write('<option value="'+i+'">'+i+'</option>');
	}
}

function showRooms(r, c)
{
	kids=document.form.kidsage.value;
	if (kids=='') kidspace=0;
	else kidspace=31;
	for (i=2; i<=5; i++)
	{
		document.getElementById('otherRooms'+i).style.display = 'none';
	}
	if (r>1)
	{
		for (i=2; i<=r; i++)
		{
			document.getElementById('otherRooms'+i).style.display = 'block';
		}
	}
}

function setGuests(br)
{
	f = document.form;
	adults = 0;
	children = 0;
	m = f.rooms.options[f.rooms.selectedIndex].value;
	lb = "";
	if (br==1)
		lb = "<br />";
	for (i=1; i<=m; i++)
	{
		if ((f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value=='doubleroom')||(f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value=='twin')||(f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value=='family3'))
			adults = adults + 2;
		if (f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value=='single')
			adults = adults + 1;
		if (f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value=='triple')
			adults = adults + 3;
		if (f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value=='family1')
		{
			adults = adults + 2;
			children = children + 1;
		}
		if (f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value=='family2')
		{
			adults = adults + 2;
			children = children + 2;
		}
	}

	f.adults.value = adults;
	f.children.value = children;
}

function setGuestsFree()
{
	f = document.form;
	adults = 0;
	children = 0;

	if (f.family1.selectedIndex>0)
	{
		adults = adults + (2 * f.family1.selectedIndex);
		children = children + (1 * f.family1.selectedIndex);
	}
	if (f.family2.selectedIndex>0)
	{
		adults = adults + (2 * f.family2.selectedIndex);
		children = children + (2 * f.family2.selectedIndex);
	}
	f.adults.value = adults;
	f.children.value = children;
}

function blankOtherCities()
{
	f = document.form;
	c = f.city.length;
	for (i=0; i<c; i++)
	{
		if (f.city[i].checked==true)
			f.other_city.selectedIndex = 0;
	}
}

function blankCities()
{
	f = document.form;
	c = f.city.length;
	if (f.other_city.selectedIndex!=0)
	{
		for (i=0; i<c; i++)
		{
			f.city[i].checked = false;
		}
	}
}

function showAdvanced(c)
{
	f = document.form;
	s = document.getElementById('advancedSearch');
	a = document.getElementById('advancedLink');
	l = document.getElementById('selectEither');
	r = document.form.rooms.options[document.form.rooms.selectedIndex].value;
	kids=document.form.kidsage.value;
	if (kids=='') kidspace=0;
	else kidspace=31;

	if ((s.style.display=='')||(s.style.display=='none'))
	{
		s.style.display = 'block';
		a.className = 'black8';
		l.style.visibility = 'visible';
		document.cookie = "advanced=1";
	}
	else
	{
		s.style.display = 'none';
		a.className = 'green8';
		l.style.visibility = 'hidden';
		f.price.selectedIndex = 0;
		f.category.selectedIndex = 0;
		f.location.selectedIndex = 0;
		f.hotelname.selectedIndex = 0;
		f.facilities.selectedIndex = 0;
		document.cookie = "advanced=0";
	}
}

function showAdvanced2(c)
{
	f = document.form;
	s = document.getElementById('advancedSearch');
	a = document.getElementById('advancedLink');
	l = document.getElementById('selectEither');
	r = document.form.rooms.options[document.form.rooms.selectedIndex].value;
	kids=document.form.kidsage.value;
	if (kids=='') kidspace=0;
	else kidspace=31;

	if ((s.style.display=='')||(s.style.display=='none'))
	{
		s.style.display = 'block';
		a.className = 'black8';
		l.style.visibility = 'visible';
		document.cookie = "advanced=1";
	}
	else
	{
		s.style.display = 'none';
		a.className = 'green8';
		l.style.visibility = 'hidden';
		document.cookie = "advanced=0";
	}
}

function clearAdvanced()
{
	f = document.form;

	f.attraction.selectedIndex = 0;
	if (f.tube)
		f.tube.selectedIndex = 0;
	if (f.rail)
		f.rail.selectedIndex = 0;
	f.price.selectedIndex = 0;
	f.category.selectedIndex = 0;
	f.location.selectedIndex = 0;
	f.hotelname.selectedIndex = 0;
	f.facilities.selectedIndex = 0;
}

function blankAdvanced(a)
{
	f = document.form;
	i = a.selectedIndex;
	n = a.name;

	clearAdvanced();

	f[n].selectedIndex = i;
}

function resetAdvancedSearch(x)
{
	f = document.form;
	cookie = document.cookie;
	broken_cookie = cookie.split(";");
	m = broken_cookie.length;

	for (i=0; i<m; i++)
	{
		broken_cookie[i] = trimCookie(broken_cookie[i]);
		if (broken_cookie[i] == 'advanced=0')
		{
			clearAdvanced();
		}
		else if (broken_cookie[i] == 'advanced=1')
		{
			showAdvanced(0);
		}
	}
	advancedLinkCookie(x);
}

function resetAdvancedSearch2(x)
{
	f = document.form;
	cookie = document.cookie;
	broken_cookie = cookie.split(";");
	m = broken_cookie.length;

	for (i=0; i<m; i++)
	{
		broken_cookie[i] = trimCookie(broken_cookie[i]);
		if (broken_cookie[i] == 'advanced=0')
		{
			clearAdvanced();
		}
		else if (broken_cookie[i] == 'advanced=1')
		{
			showAdvanced2(0);
		}
	}
	advancedLinkCookie(x);
}

function advancedLinkCookie(x)
{
	f = document.form;
	cookie = document.cookie;
	broken_cookie = cookie.split(";");
	m = broken_cookie.length;

	for (i=0; i<m; i++)
	{
		if ((broken_cookie[i] == 'advancedLink=1') && (x == 1))
		{
			showAdvancedLink();
		}
	}
}

function moveOffers(p)
{
	document.getElementById('offer2').style.paddingTop = p + 'px';
	document.getElementById('offer3').style.paddingTop = p + 'px';
	document.getElementById('offer4').style.paddingTop = p + 'px';
}

function numbersOnly(field)
{
	var valid = "0123456789"
	ok = 1;
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
			ok = 0;
	}
	if (ok==0)
	{
		alert("Please only enter numbers in this field!");
		field.focus();
		field.select();
	}
}

function setKids(t)
{
        showKidsAge();
}

function showKidsAge()
{

	f = document.form;
	s = document.getElementById('kidsagediv');
	r1 = document.form.roomtype1.options[document.form.roomtype1.selectedIndex].value;
	r2 = document.form.roomtype2.options[document.form.roomtype2.selectedIndex].value;
	r3 = document.form.roomtype3.options[document.form.roomtype3.selectedIndex].value;
	r4 = document.form.roomtype4.options[document.form.roomtype4.selectedIndex].value;
	r5 = document.form.roomtype5.options[document.form.roomtype5.selectedIndex].value;
	r = document.form.rooms.options[document.form.rooms.selectedIndex].value;

	if ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1))
	{
		s.style.display = 'block';
		kidspace=31;
	}
	else
	{
		s.style.display = 'none';
		kidspace=0;
	}
}

function showKidsAge2()
{

	f = document.form;
	s = document.getElementById('kidsagediv');
	r1 = document.form.roomtype1.options[document.form.roomtype1.selectedIndex].value;
	r2 = document.form.roomtype2.options[document.form.roomtype2.selectedIndex].value;
	r3 = document.form.roomtype3.options[document.form.roomtype3.selectedIndex].value;
	r4 = document.form.roomtype4.options[document.form.roomtype4.selectedIndex].value;
	r5 = document.form.roomtype5.options[document.form.roomtype5.selectedIndex].value;

	if ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1))
	{
		s.style.display = 'block';
	}
	else
	{
		s.style.display = 'none';
	}
}


function openWindow(url, w, h, s)
{
	var params="menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars="+s+",resizable=yes,dependent,top=0,left=0,width="+w+",height="+h;
	popupWin = window.open(url, 'popup',params);
	popupWin.focus();
}

function openMap(url, w, h)
{
	var params="menubar=yes,toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,dependent,top=0,left=0,width="+w+",height="+h;
	popupWin = window.open(url, 'popup',params);
	popupWin.focus();
}

function ageOnly(field)
{
	var valid = "0123456789,"
	ok = 1;
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
			ok = 0;
	}
	if (ok==0)
	{
		alert("Please only enter numbers in this field!");
		field.focus();
		field.select();
	}
}

function setAge()
{
	w=window.opener.document.form;
	f=document.form;

	if (f.kidsage.value=='')
	{
		alert('Please enter the age of the child/children');
	}
	errors="";
	errorcheck=0;
	stripNumber(f.kidsage.value,w.maxage.value);
	if (errorcheck==1)
		alert(errors);
	else
	{
		w.kidsage.value=f.kidsage.value;
		window.close();
	}
}

function stripNumber(number,maxage)
{
	age = 0;
	max = parseInt(maxage);
	var comma = number.indexOf(',');
	if (comma!=-1)
	{
		age = number.substring(0,comma);
		if (age>max)
		{
			errors = errors + 'The age '+age+' is too old for a child at this hotel. Maximum age: '+maxage+'\n\n';
			errorcheck = 1;
		}
		var newnumber = number.substring(comma+1);
		stripNumber(newnumber,max);
	}
	if (comma==-1)
	{
		age = number;
		if (age>max)
		{
			errors = errors + 'The age '+age+' is too old for a child at this hotel. Maximum age: '+maxage+'\n\n';
			errorcheck = 1;
		}
	}
}

function setCurrency(c)
{
	document.cookie = "currency=" + c;
	url = document.URL;
	if (url.indexOf('?')>-1)
	{
		pos=url.indexOf('currency=');
		if (pos>-1)
		{
			url=url.replace('currency=','currency2=');
			document.location = url + "&currency=" + c;
		}
		else document.location = url + "&currency=" + c;
	}
	else
	{
		if (url.indexOf('currency=')>-1)
			document.location = url.substring(0, url.indexOf('currency=')) + "currency=" + c;
		else
		{
		  lastchar=url.length;
		  if (url[lastchar-1]=='/')
			document.location = url + "index_" + c+".htm";
		  else
		  {
		    if (url.indexOf('index_'))
		    {
			if (c=='gbp')
			{
			   pos=url.indexOf('index_');
			   document.location = url.substring(0,pos);		  	   
			}
			else
		  	{
			   pos=url.indexOf('index_');
	  	  	   document.location = url.substring(0,pos)+ "index_" + c+".htm";  
			}
		    }
		    else
			document.location = url + "?currency=" + c;
		  }
		}
	}
}

function getCurrency()
{
	cookie = document.cookie;
	broken_cookie = cookie.split(";");
	m = broken_cookie.length;

	for (i=0; i<m; i++)
	{
		broken_cookie[i] = trimCookie(broken_cookie[i]);
		if (broken_cookie[i]=='currency=usd')
			document.getElementById('usd').className = document.getElementById('usd').className + " sel";
		else if (broken_cookie[i]=='currency=euro')
			document.getElementById('euro').className = document.getElementById('euro').className + " sel";
		else
			document.getElementById('gbp').className = document.getElementById('gbp').className + " sel";
	}
}

function checkHotelcookiecitypage(thiscity)
{
	cookie = document.cookie;
	broken_cookie = cookie.split(";");
	m = broken_cookie.length;
	hotelid=0;hname='';thumbnail='';hotelcurrency='';city='';

	for (i=0; i<m; i++)
	{
		broken_cookie[i] = trimCookie(broken_cookie[i]);
		if (broken_cookie[i].indexOf('hotelid=')>-1) hotelid=broken_cookie[i].substring(8);
		if (broken_cookie[i].indexOf('hname=')>-1) hname=broken_cookie[i].substring(6);
		if (broken_cookie[i].indexOf('city=')>-1) city=broken_cookie[i].substring(5);
		if (broken_cookie[i].indexOf('thumbnail=')>-1) thumbnail=broken_cookie[i].substring(10);
		if (broken_cookie[i].indexOf('hotelcurrency=')>-1) hotelcurrency=broken_cookie[i].substring(14);
		if (hotelid!=0 && hname!='' && city!='' && thumbnail!='' && hotelcurrency!='') 
		{
			if (city==thiscity) break;
			else 
			{
				hotelid=0;hname='';thumbnail='';hotelcurrency='';city='';
			}
		}
	}
	if (hotelid!=0 && hname!='' && city!='' && thumbnail!='' && hotelcurrency!='')
		document.getElementById('extraelems').style.display = 'none';
}


function trimCookie(str)
{
	return str.replace(/^\s+/,"").replace(/\s+$/,"").replace(/\s+/g," ");
}


function checkCompareForm()
{
 f=document.compareform;
 max=f.total.value;
 found=false;
 i=1;
 while (!found && i<=max)
 {
  if (f['hotel'+i].checked==true) found=true;
  else i++;
 }
 if (!found)
 {
   window.alert('Please select at least one hotel');
   return false;
 }
 else f.submit();
}

function showYear()
{
 now = new Date();
 document.write(now.getFullYear()); 
}

function changeRow(n)
{
	document.getElementById('row'+n).className = "resultsHover";
}

function changeRowmap(n)
{
	document.getElementById('row'+n).className = "resultsHover2";
}

function resetRow(n)
{
	document.getElementById('row'+n).className = "";
}

var lock = false;
var run;
	
//loading the slideshow based on the play/pause button
function auto() {
	//document.getElementById("SLIDESIMG").style.display = 'block';
	if (lock == true) {
		lock = false;
		SLIDES.pause();
	}
	else if (lock == false) {
		lock = true;
		SLIDES.next(); 
		SLIDES.play();
	}
}

function loadImage() {
	//the line below used to cause misaligns slideshow in firefox 
	document.getElementById("SLIDESIMG").style.display = 'block';
	SLIDES.pause();
	lock = false;
}