
// BUTTON PRELOAD AND ROLLOVER FUNCTIONALITY

// Home Button
home_on = new Image();  home_on.src = "/images/navigation/home_over.gif";
home_off = new Image(); home_off.src = "/images/navigation/home_out.gif";

// Flights Button
flights_on = new Image();  flights_on.src = "/images/navigation/flights_over.gif";
flights_off = new Image(); flights_off.src = "/images/navigation/flights_out.gif";

// Package Holidays Button
packageholidays_on = new Image();  packageholidays_on.src = "/images/navigation/packageholidays_over.gif";
packageholidays_off = new Image(); packageholidays_off.src = "/images/navigation/packageholidays_out.gif";

// Special Offers Button
specialoffers_on = new Image();  specialoffers_on.src = "/images/navigation/specialoffers_over.gif";
specialoffers_off = new Image(); specialoffers_off.src = "/images/navigation/specialoffers_out.gif";

// Car Hire Button
carhire_on = new Image();  carhire_on.src = "/images/navigation/carhire_over.gif";
carhire_off = new Image(); carhire_off.src = "/images/navigation/carhire_out.gif";

// Insurance Button
insurance_on = new Image();  insurance_on.src = "/images/navigation/insurance_over.gif";
insurance_off = new Image(); insurance_off.src = "/images/navigation/insurance_out.gif";

// Travel Extras Button
travelextras_on = new Image();  travelextras_on.src = "/images/navigation/travelextras_over.gif";
travelextras_off = new Image(); travelextras_off.src = "/images/navigation/travelextras_out.gif";

// Contact Us Button
contactus_on = new Image();  contactus_on.src = "/images/navigation/contactus_over.gif";
contactus_off = new Image(); contactus_off.src = "/images/navigation/contactus_out.gif";

// Resort Information Button
resortinformation_on = new Image();  resortinformation_on.src = "/images/general_buttons/67/resort_info_1.gif";
resortinformation_off = new Image(); resortinformation_off.src = "/images/general_buttons/67/resort_info_0.gif";

// Back Button
back_on = new Image();  back_on.src = "/images/general_buttons/67/back_1.gif";
back_off = new Image(); back_off.src = "/images/general_buttons/67/back_0.gif";

// Back2 Button
back2_on = new Image();  back2_on.src = "/images/general_buttons/67/back_1.gif";
back2_off = new Image(); back2_off.src = "/images/general_buttons/67/back_0.gif";

// More Details Button
moredetails_on = new Image();  moredetails_on.src = "/images/general_buttons/moredetails_1.gif";
moredetails_off = new Image(); moredetails_off.src = "/images/general_buttons/moredetails_0.gif";

// Advert Details Button
advertdetails_on = new Image();  advertdetails_on.src = "/images/general_graphics/details_1.gif";
advertdetails_off = new Image(); advertdetails_off.src = "/images/general_graphics/details_0.gif";

// Get Details Button
getdetails_on = new Image();  getdetails_on.src = "/images/general_graphics/details_1.gif";
getdetails_off = new Image(); getdetails_off.src = "/images/general_graphics/details_0.gif";








// IMAGE TRANSITION EFFECT BY MICROSOFT.COM
var slideShowSpeed = 7500;
  var crossFadeDuration = 4;
    
  //Iamge Set One	 - main photo
  var arrPic = new Array('/images/photo_imagery/01.jpg','/images/photo_imagery/02.jpg','/images/photo_imagery/03.jpg','/images/photo_imagery/04.jpg','/images/photo_imagery/05.jpg','/images/photo_imagery/06.jpg','/images/photo_imagery/07.jpg','/images/photo_imagery/08.jpg','/images/photo_imagery/09.jpg','/images/photo_imagery/010.jpg','/images/photo_imagery/011.jpg','/images/photo_imagery/012.jpg','/images/photo_imagery/013.jpg','/images/photo_imagery/014.jpg','/images/photo_imagery/015.jpg','/images/photo_imagery/016.jpg','/images/photo_imagery/017.jpg','/images/photo_imagery/018.jpg','/images/photo_imagery/019.jpg','/images/photo_imagery/020.jpg');
  //var arrPic = new Array('/images/photo_imagery/img001a.jpg','/images/photo_imagery/img001.jpg','/images/photo_imagery/img002.jpg','/images/photo_imagery/img003.jpg','/images/photo_imagery/img004.jpg','/images/photo_imagery/img005.jpg','/images/photo_imagery/img007.jpg','/images/photo_imagery/img008.jpg','/images/photo_imagery/img009.jpg','/images/photo_imagery/img010.jpg','/images/photo_imagery/img011.jpg','/images/photo_imagery/img012.jpg','/images/photo_imagery/img013.jpg','/images/photo_imagery/img014.jpg','/images/photo_imagery/img015.jpg','/images/photo_imagery/img016.jpg','/images/photo_imagery/img017.jpg','/images/photo_imagery/img018.jpg','/images/photo_imagery/img019.jpg','/images/photo_imagery/img020.jpg','/images/photo_imagery/img021.jpg','/images/photo_imagery/img022.jpg','/images/photo_imagery/img023.jpg','/images/photo_imagery/img006.jpg');
  var intPicArrLength = arrPic.length;
    
  var j = 0;
  var arrPreLoad = new Array();
  
  for(i=0; i < intPicArrLength; i++) {
     arrPreLoad[i] = new Image();
     arrPreLoad[i].src = arrPic[i];
}

  function runSlideShow() {
  
   if (document.all) {
    document.images.SlideShow.style.filter = "blendTrans(duration = crossFadeDuration)";
    document.images.SlideShow.filters.blendTrans.Apply();      
   }
   //alert(arrPreLoad[j].src);
   document.images.SlideShow.src = arrPreLoad[j].src;
   
   if(document.all)
    document.images.SlideShow.filters.blendTrans.Play(crossFadeDuration);
   
   j = j + 1;
   
   if(j >= intPicArrLength)
    j=0
   
   t = setTimeout('runSlideShow()', slideShowSpeed)
}





// CENTRAL POPUP WINDOW
var theWin=0;
function ramsayworldtravel(url,theWidth,theHeight)
{
  var theTop=(screen.height/2)-(theHeight/2);
  var theLeft=(screen.width/2)-(theWidth/2);
  var features='height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft+",scrollbars=yes";
  theWin = open(url,'ramsayworldtravel',features);
}





// EMAIL VALIDATION
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please input a valid email address in the form field provided.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please input a valid email address in the form field provided.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please input a valid email address in the form field provided.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please input a valid email address in the form field provided.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please input a valid email address in the form field provided.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please input a valid email address in the form field provided.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please input a valid email address in the form field provided.")
		    return false
		 }

 		 return true					
	}






// NEWSLETTER EMAIL INPUT VALIDATION
function ValidateForm(){
	var emailID=document.email_updates.email_address
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please input a valid email address in the form field provided.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 
 
 
 
 
// SEARCH FORM SELECTION VALIDATION
function ValidateSearchForm2(formname) {
	var theMessage = ""
	
	//get form name passed into function
	var form = document.getElementById(formname)
	
	//set lists to check using formname
	var listCheck = form.airport_from;
	var listCheck2 = form.airport_to;
	
	// Make sure a selection list is used
	if (listCheck2.options[listCheck2.selectedIndex].value == "-" && listCheck.options[listCheck.selectedIndex].value == "-"){
		theMessage = theMessage + "Please Select an Airport and a Destination\nfrom the drop down fields provided.";
	}

	else{
		if (listCheck.options[listCheck.selectedIndex].value == "-") {
			theMessage = theMessage + "Please Select an Airport from the drop down list provided.\n";
		}
					
		if (listCheck2.options[listCheck2.selectedIndex].value == "-") {
			theMessage = theMessage + "Please Select a Destination from the drop down list provided.";
		}
	}

// If no errors, submit the form
if (theMessage == "") {
return true;

} else {

// If errors were found, show alert message
alert(theMessage);
return false;
  }
}

function ValidateSearchForm(formname) {
	var theMessage = ""
	if(formname != 'OfferSearchForm'){
			currentdate = new Date();
			currentdate = new Date(currentdate.getFullYear(), currentdate.getMonth(), currentdate.getDate(), 0, 0, 0); 
			cindate = new Date(parseInt(document.forms[formname].startdate_y.value), parseInt(document.forms[formname].startdate_m.value - 1), parseInt(document.forms[formname].startdate_d.value), 0, 0, 0);
			  
			iMonth = new Number(cindate.getMonth())
			iMonth = iMonth + 1
			if(document.forms[formname].startdate_d.value != cindate.getDate()){
				theMessage = theMessage + '\nYou have entered an invalid date which has now been amended.\n';
			   
			   document.forms[formname].startdate_d[0].selected = true;
			   for (i=0;i<document.forms[formname].startdate_y.options.length;i++) {
					if (document.forms[formname].startdate_y.options[i].value ==iMonth) {
					 document.forms[formname].startdate_y[i].selected = true;
					}
			   }
			   for (i=0;i<document.forms[formname].startdate_m.options.length;i++) {
					if (document.forms[formname].startdate_m.options[i].value ==iMonth) {
					 document.forms[formname].startdate_m[i].selected = true;
					}
			   }
			}
			
			//get form name passed into function
			var form = document.getElementById(formname)
			
			//set lists to check using formname
			var listCheck = form.airport_from;
			var listCheck2 = form.airport_to;
			
			// Make sure a selection list is used
			if (listCheck2.options[listCheck2.selectedIndex].value == "-" && listCheck.options[listCheck.selectedIndex].value == "-"){
				theMessage = theMessage + "Please Select an Airport and a Destination\nfrom the drop down fields provided.";
			}
		
			else{
				if (listCheck.options[listCheck.selectedIndex].value == "-") {
					theMessage = theMessage + "Please Select an Airport from the drop down list provided.\n";
				}
							
				if (listCheck2.options[listCheck2.selectedIndex].value == "-") {
					theMessage = theMessage + "Please Select a Destination from the drop down list provided.";
				}
			}
			
			var month=new Array(12)
			month[0]="Jan"
			month[1]="Feb"
			month[2]="Mar"
			month[3]="Apr"
			month[4]="May"
			month[5]="Jun"
			month[6]="Jul"
			month[7]="Aug"
			month[8]="Sep"
			month[9]="Oct"
			month[10]="Nov"
			month[11]="Dec"
			
			var iMonth = new Number(document.getElementById("startdate_m").value);
			iMonth = iMonth
			
			var dDate = new Date(document.getElementById("startdate_y").value + '/' + iMonth + '/' + document.getElementById("startdate_d").value);
			//dDate = dDate.getFullYear() + ',' + dDate.getMonth() + ',' + dDate.getDate();
			
		//	iDay - 
			//dDate.setDate(dDate.getDate() - 1);
			
			var dCurrentDate = new Date();
			dCurrentDate.setHours(00, 0, 0)
			dCurrentDate.setDate(dCurrentDate.getDate() - 1);
			
			
			iMonth = dCurrentDate.getMonth() + 1
			//dCurrentDate = dCurrentDate.getFullYear() + ',' + iMonth + ',' + dCurrentDate.getDate();
			
			
			if(dDate < dCurrentDate){
				theMessage = theMessage + '\nThe date you have selected is not valid.';
			}else{
				//theMessage = theMessage + '\nDATE OK: ' + dDate + ',' + dCurrentDate;
			}
	
	}else{
			//theMessage = document.forms[formname].Available_Regionsid.value + '\n' + document.forms[formname].Closest_Resortid.value;
			//if (document.forms[formname].Available_Regions.options[document.forms[formname].Available_Regions.selectedIndex].value == "-" && document.forms[formname].Available_Regions.options[document.forms[formname].Available_Regions.selectedIndex].value == "-"){
			if (document.forms[formname].Available_Regionsid.value == "" || document.forms[formname].Available_Regionsid.value == "0"){
				theMessage = theMessage + "Please Select a Region from the drop down fields provided.";
			}
			if (document.forms[formname].Closest_Resortid.value == "" || document.forms[formname].Closest_Resortid.value == "0"){
				theMessage = theMessage + "\nPlease Select a Resort from the drop down fields provided.";
			}		
	}
	// If no errors, submit the form
	if (theMessage == "") {
		return true;
	} else {
		// If errors were found, show alert message
		alert(theMessage);
		return false;
	}
	
	
	
}





// USERS SCREEN BIT DEPTH DETECTION

/*
var bitDepth;
if (window.screen) {
	alert("global_high.css")
  document.write('<link rel="stylesheet" href="/css/global_high.css" media="screen" />');
} else {
	alert("global_low.css")
  document.write('<link rel="stylesheet" href="/css/global_low.css" media="screen" />');
}
  
*/





// FORM HIGHLIGHT ON FOCUS
function trColor(Colour, elementId) {
	if (document.getElementById) {
		document.getElementById(elementId).style.backgroundColor='#FFF';
	}
}
function trColorOff(elementId) {
	if (document.getElementById) {
		document.getElementById(elementId).style.backgroundColor="";
	}
}



// PRELOADING IMAGES
if (document.images)
{
  var img01= new Image(); 
  img01.src="/images/general_graphics/watermark.gif"; 
}




// Clears a text field only if the value matches what is passed in
function clearField(fId, sMatch, sChange)
{
	if(sChange == null) sChange = '';
	if(fId.value == sMatch)
	{ fId.value = sChange; }
}




// Browser sniffer
var ns4 = (document.layers); 
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

// Attaches objects dependent on browser
function object_attach(id)
{
	var obj;
	if(ns4) obj = document.layers[id];
	else if(ie4) obj = document.all[id];
	else if(ie5 || ns6) obj = document.getElementById(id);
	return obj;
}
function checkFormFieldSelectedIndex(sFieldName, sErrTxt)
{
	oTitleElements = document.getElementsByTagName("select")
	for (i = 0; i < oTitleElements.length; i++)
	{
		if(oTitleElements.item(i).id.indexOf(sFieldName) == 0)
		{
			temp_Obj = object_attach(oTitleElements.item(i).id);
			if(temp_Obj.selectedIndex == 0)
			{ alert(sErrTxt); temp_Obj.focus(); return false; break; }
		}
	}
	return true;
}
function checkFormFieldValue(sFieldName, sDefaultVal, sErrTxt)
{
	oFormElements = document.getElementsByTagName("input")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).id.indexOf(sFieldName) == 0)
		{
			temp_Obj = object_attach(oFormElements.item(i).id);
			if(temp_Obj.value == '' || temp_Obj.value == sDefaultVal)
			{ alert(sErrTxt); temp_Obj.focus(); return false; break; }
		}
	}
	oFormElements = document.getElementsByTagName("textarea")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).id.indexOf(sFieldName) == 0)
		{
			temp_Obj = object_attach(oFormElements.item(i).id);
			if(temp_Obj.value == '' || temp_Obj.value == sDefaultVal)
			{ alert(sErrTxt); temp_Obj.focus(); return false; break; }
		}
	}
	return true;
}
function checkFormFieldAges(sErrTxt)
{
	oFormElements = document.getElementsByTagName("select")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).id.indexOf("dob") == 0 && oFormElements.item(i).id.lastIndexOf("d") == 3)
		{
			temp_Obj1 = object_attach(oFormElements.item(i).id);
			temp_Obj1a = Math.abs(temp_Obj1.idmin);
			temp_Obj1b = Math.abs(temp_Obj1.idmax);
			temp_Obj2 = object_attach('dobm' + temp_Obj1.id.substr(4,temp_Obj1.id.length-4));
			temp_Obj3 = object_attach('doby' + temp_Obj1.id.substr(4,temp_Obj1.id.length-4));
			if(checkAge(temp_Obj1a, temp_Obj1b, temp_Obj1, temp_Obj2, temp_Obj3) == false)
			{ alert(sErrTxt + '\nPassenger ' + temp_Obj1.id.substr(4,temp_Obj1.id.length-4) + ' is out of the acceptable age range.'); temp_Obj1.focus(); return false; break; }
		}
	}
	return true;
}
function openPopupWin(popUrl, popWid, popHgt, popScroll, popResize)
{
	popupWin=window.open(popUrl,"popupWin","width=" + popWid + ",height=" + popHgt + ",left=" + ((screen.width-popWid)/2) + ",top=" + ((screen.height-popHgt)/2) + ",status=no,toolbar=no,menubar=no,scrollbars=" + popScroll + ",resizable=" + popResize);
	if(!popupWin.opener) popupWin.opener=self;
}




var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

function changeNav(id, Type, HoverColour, StandardColour){
	
		if(StandardColour != HoverColour && Type == 'Off'){
			document.getElementById(id).style.background = StandardColour;
		}else{
			document.getElementById(id).style.background = HoverColour;
		}

}


