// JavaScript Document

function readratings()
{
	dummy = window.open("http://flightcentreuk.hotelconnect.co.uk/common/EN/Exp_Cat.htm","explain","dependent=yes,toolbar=no,menubar=no,status=no,directories=no,width=600,height=450,resizable=yes,scrollbars=yes,screenx=100,left=100,screeny=100,top=100");
	dummy.focus()
}
function showapart()
{
	dummy = window.open("http://flightcentreuk.hotelconnect.co.uk/common/EN/Exp_room.htm","explain","dependent=yes,toolbar=no,menubar=no,status=no,directories=no,width=600,height=450,resizable=yes,scrollbars=yes,screenx=100,left=100,screeny=100,top=100");
	dummy.focus()
}


function next()
{
	if (Srch_onsubmit()) 
	{
	document.Srch.submit();
	}
}

function Srch_onsubmit() 
{
 // Validate fields 
 
  //if (CheckForm() && CheckRooms())
  	if (CheckForm() )
 		return true;
 	else
 		return false;	
	
}
     	
// this function pops open the hotel images
function showpic(theURL,winName,features) { 
		popup = window.open(theURL,winName,features)
    	popup.focus();
  } 		

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function CheckForm()
{

	// city validation
	if (document.Srch.cboCityString.options[document.Srch.cboCityString.selectedIndex].value == "")
	{
		window.alert("You have omitted to select a destination."); 
		document.Srch.cboCityString.focus();
		return false;
	}
	else
	{
		var str = document.Srch.cboCityString.options[document.Srch.cboCityString.selectedIndex].text;
		if (str.indexOf("--",0) != -1 || str.indexOf("[",0) != -1 || str == "" )
		{
			window.alert("You have omitted to select a destination."); 
			document.Srch.cboCityString.focus();
			return false;
		}
	}

	// Make options into Date variables
	//modified so that it will handle international dates
	// var dteDept  = new Date(Date.parse(document.Srch.DeptDay.options[document.Srch.DeptDay.selectedIndex].value + " " + document.Srch.DeptMonthYr.options[document.Srch.DeptMonthYr.selectedIndex].text.toString()));
	var dteDept  = new Date(document.Srch.DeptMonthYr.options[document.Srch.DeptMonthYr.selectedIndex].value.toString().substr(2,4),(document.Srch.DeptMonthYr.options[document.Srch.DeptMonthYr.selectedIndex].value.toString().substr(0,2) -1), document.Srch.DeptDay.options[document.Srch.DeptDay.selectedIndex].text);
	//alert (dteDept.toString());
	//var dteReturn  = new Date(Date.parse(document.Srch.ReturnDay.options[document.Srch.ReturnDay.selectedIndex].value + " " + document.Srch.ReturnMonthYr.options[document.Srch.ReturnMonthYr.selectedIndex].text.toString()));
	var dteReturn  = new Date(document.Srch.ReturnMonthYr.options[document.Srch.ReturnMonthYr.selectedIndex].value.toString().substr(2,4), (document.Srch.ReturnMonthYr.options[document.Srch.ReturnMonthYr.selectedIndex].value.toString().substr(0,2)-1), document.Srch.ReturnDay.options[document.Srch.ReturnDay.selectedIndex].text );
	//alert (dteReturn.toString());
	// today's date
	var	dteNow = new Date(); 

	// if they've entered an invalid date the date function will force it to a valid date
	// if the date is invalid the day value will not match.

	if (dteDept.getDate() != parseInt(document.Srch.DeptDay.options[document.Srch.DeptDay.selectedIndex].value))
	{
		window.alert("The check-in date is invalid");
		document.Srch.DeptDay.focus();
		return false;
	}

	if (dteReturn.getDate() != parseInt(document.Srch.DeptDay.options[document.Srch.ReturnDay.selectedIndex].value))
	{
		window.alert("The check-out date is invalid");
		document.Srch.ReturnDay.focus();
		return false;
	}

	if (dteDept.valueOf() < dteNow.valueOf())
	{
		window.alert("The check-in date you have supplied has already passed");
		document.Srch.DeptDay.focus();
		return false;
	}

	if (dteDept.valueOf() >= dteReturn.valueOf())
	{
		window.alert("The check-in date must be earlier than the check-out date");
		Srch.DeptDay.focus();
		return false;
	}

	if ((dteReturn.valueOf() - dteDept.valueOf())  > (31 * 86400000) )
	{
		window.alert("Please contact us for stays of more than one month");
		Srch.DeptDay.focus();
		return false;
	}

	//room validation
	
	if (document.Srch.txtRooms1.options[document.Srch.txtRooms1.selectedIndex].value == "0" && document.Srch.txtRooms2.options[document.Srch.txtRooms2.selectedIndex].value == "0" && document.Srch.txtRooms3.options[document.Srch.txtRooms3.selectedIndex].value == "0" && document.Srch.txtRooms4.options[document.Srch.txtRooms4.selectedIndex].value == "0")
	{
		window.alert("You have omitted to select your required number/type of rooms"); 
		document.Srch.txtRooms1.focus();
		return false;
	}


   if (parseInt(document.Srch.txtRooms1.options[document.Srch.txtRooms1.selectedIndex].value*2,10) + parseInt(document.Srch.txtRooms2.options[document.Srch.txtRooms2.selectedIndex].value*2,10) + parseInt(document.Srch.txtRooms3.options[document.Srch.txtRooms3.selectedIndex].value,10) + parseInt(document.Srch.txtRooms4.options[document.Srch.txtRooms4.selectedIndex].value*3,10) > 9)
    {
     window.alert("For groups of 10 persons or more please contact us");
       document.Srch.txtRooms1.focus();
       return false;
      }

	return true;
}

function changeimage(imgname,newimage) {
		if (document.images) {
			document.images[imgname].src= newimage ;
		}
	}
function loadimages() {
	myimg = new Array()
	a=loadimages.arguments
	for (i=0;i<a.length;i++) {
		myimg[i] = new Image
		myimg[i].src=a[i]
		}
	}


function changeCity(sCity)
{
var i,iNewIndex ;

//Loop through array to find the city
for (i=0;i < document.Srch.cboCityString.length;i++) 
	{
	if (document.Srch.cboCityString.options[i].value == sCity) 
		//Found the city remember index and break
		{
		iNewIndex = i ;
		break;
		}
	}

//If we found a city then go to it
if (iNewIndex >=0) {
	document.Srch.cboCityString.selectedIndex = iNewIndex ;
	document.Srch.cboCityString.focus();
	}
}

function OpenPage(newLoc) { 
var ss,lang,cur 
ss = newLoc.split("|"); 
newPage =ss[2] 
lang = ss[1] 
cur = ss[0] 
if (newPage != "") { 
	window.location.href = newPage 
 if (parent.topFrame) {
 parent.topFrame.document.location.href = "/common/"+ lang +"/top.htm"
	} 
	} 
	} 