function getNewXMLHttpRequest() {
  var obj;
    try {
      obj = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch(e) {
      try {
        obj = new XMLHttpRequest();
      }
      catch (e) {
        obj = false;
      }
    }
    return obj;
}


function Shortlist (type,oid,action) {
var el='';
		var request = getNewXMLHttpRequest();
		geturl='/config/shortlist.php?oid='+oid+'&action='+action;
		request.open('GET', geturl);
		request.onreadystatechange=function() {
		  if (request.readyState==4) {
		           var response = request.responseText;

				var params = response.split('::');
				if (params[0]=="0") {
				// shortlist empty, display standard panel bottom img
					document.getElementById("shortlistbottom").innerHTML="<img src='"+params[1]+"images/shortlist_bottom.gif' width='227' height='20' alt='' border='0'>";	
				}
				else if (params[0]=="1"){
				// shortlist not empty, display enquiry button img
					document.getElementById("shortlistbottom").innerHTML="<a href='"+params[1]+"Enquiry/'><img src='"+params[1]+"images/shortlist_enquiry_btn.gif' width='227' height='45' alt='' border='0'></a>";	
				}
				else if (params[0]=="2"){
				// thats enough - 5 items on the list!
					alert('You can only have 5 items on your shortlist!');
					document.getElementById("shortlistbottom").innerHTML="<a href='"+params[1]+"Enquiry/'><img src='"+params[1]+"images/shortlist_enquiry_btn.gif' width='227' height='45' alt='' border='0'></a>";	
				}
			if (params[2]!="") {
				el=params[2];
				if (el) document.getElementById("shortlist_content").innerHTML=el;
			}

		 }
           }
    		request.send(null);	
}

function getdestresort () {
var selectBox = document.forms["countries"].elements[1];
sel_id = selectBox.options[selectBox.selectedIndex].value;
	location.href=sel_id;
		
}
function getdest (val) {
if (val!="") {
val1="con"+val;

var selectBox = document.forms[val1].elements[0];
sel_id = selectBox.options[selectBox.selectedIndex].value;

	location.href=sel_id;
	}	
}



function number_format( number, decimals, dec_point, thousands_sep ) {
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

function swapboxes(dest) {
	if (dest=="description") {
		document.getElementById("description_box").style.display="block";
		document.getElementById("roomtypes_box").style.display="none";
		document.getElementById("gallery_box").style.display="none";


		document.getElementById("description_button").style.backgroundColor="#f8f8f8";
		document.getElementById("gallery_button").style.backgroundColor="#eeeeee";
		document.getElementById("roomtypes_button").style.backgroundColor="#eeeeee";

	}

	else if (dest=="gallery") {
		document.getElementById("description_box").style.display="none";
		document.getElementById("roomtypes_box").style.display="none";
		document.getElementById("gallery_box").style.display="block";

		document.getElementById("description_button").style.backgroundColor="#eeeeee";
		document.getElementById("roomtypes_button").style.backgroundColor="#eeeeee";
		document.getElementById("gallery_button").style.backgroundColor="#f8f8f8";
	}

	else if (dest=="roomtypes") {
		document.getElementById("description_box").style.display="none";
		document.getElementById("roomtypes_box").style.display="block";
		document.getElementById("gallery_box").style.display="none";

		document.getElementById("description_button").style.backgroundColor="#eeeeee";
		document.getElementById("roomtypes_button").style.backgroundColor="#f8f8f8";
		document.getElementById("gallery_button").style.backgroundColor="#eeeeee";
	}
}
function check_findhotel_form(defurl) {
	if (document.fhform.fhquery.value.length>=3) {
		fh=defurl + 'FindHotel/'+document.fhform.fhquery.value+'/';
			window.location=fh;
	}
	else {
	alert('Your keyword should be at least 3 characters long!');
	 return false;
	}
}
function check_search_form(type,defurl) {
	errcount=0;
	msgval="";

	if (type=="pack") {
	if (document.P_searchform.P_country.options[document.P_searchform.P_country.options.selectedIndex].value=="") {
		msgval="Please select destination country!\n"; errcount++;
	}
	if (document.P_searchform.P_resort.options[document.P_searchform.P_resort.options.selectedIndex].value=="") {
		msgval+="Please select destination resort!\n";errcount++;
	}
	if (document.P_searchform.P_airport.options[document.P_searchform.P_airport.options.selectedIndex].value=="") {
		msgval+="Please select departure airport!\n"; errcount++;
	}
	if (document.P_searchform.P_depdate.options[document.P_searchform.P_depdate.options.selectedIndex].value=="") {
		msgval+="Please select departure date!\n"; errcount++;
	}
	if (document.P_searchform.P_duration.options[document.P_searchform.P_duration.options.selectedIndex].value=="") {
		msgval+="Please select duration!\n";errcount++;
	}
	if (document.P_searchform.P_partysize.options[document.P_searchform.P_partysize.options.selectedIndex].value=="") {
		msgval+="Please specify your party size!\n"; errcount++; 
	}
	if (errcount>0) {
		alert (msgval); return false;
	}
		else  {
			wlh=defurl + 'Search/Packages/'+
			document.P_searchform.P_country.options[document.P_searchform.P_country.options.selectedIndex].value +'/'+
			document.P_searchform.P_resort.options[document.P_searchform.P_resort.options.selectedIndex].value +'/'+
			document.P_searchform.P_airport.options[document.P_searchform.P_airport.options.selectedIndex].value +'/'+
			document.P_searchform.P_duration.options[document.P_searchform.P_duration.options.selectedIndex].value +'/'+
			document.P_searchform.P_depdate.options[document.P_searchform.P_depdate.options.selectedIndex].value +'/'+
			document.P_searchform.P_flex.value +'/'+			
			document.P_searchform.P_partysize.options[document.P_searchform.P_partysize.options.selectedIndex].value +'/';
			if (document.P_searchform.P_ATypes[0].checked==true) wlh= wlh + "hotel|";
			if (document.P_searchform.P_ATypes[1].checked==true) wlh= wlh + "chalet|";
			if (document.P_searchform.P_ATypes[2].checked==true) wlh= wlh + "apart";
			wlh = wlh + "/0/ns";

			window.location=wlh;
		}
	}


	else if (type=="accom"){
	if (document.A_searchform.A_country.options[document.A_searchform.A_country.options.selectedIndex].value=="") {
		msgval="Please select destination country!\n"; errcount++;
	}
	if (document.A_searchform.A_resort.options[document.A_searchform.A_resort.options.selectedIndex].value=="") {
		msgval+="Please select destination resort!\n";errcount++;
	}
	if (document.A_searchform.A_depdate_day.options[document.A_searchform.A_depdate_day.options.selectedIndex].value=="" ||
	    document.A_searchform.A_depdate_month.options[document.A_searchform.A_depdate_month.options.selectedIndex].value=="" ||
	    document.A_searchform.A_depdate_year.options[document.A_searchform.A_depdate_year.options.selectedIndex].value=="") {
		msgval+="Please select departure date!\n"; errcount++;
	}

	if (document.A_searchform.A_partysize.options[document.A_searchform.A_partysize.options.selectedIndex].value=="") {
		msgval+="Please specify your party size!\n"; errcount++; 
	}
	if (errcount>0) {
		alert (msgval); return false;
	}
		else document.A_searchform.submit();
	}
}

function check_email() {
	emcheck=document.newsletter_form.sub_email.value;
	
	if (!(emcheck.indexOf(".") > 2) || !(emcheck.indexOf("@") > 0)) {
		alert ('Please type proper e-mail address!');
		return false;
	}
	else {
		document.newsletter_form.submit(); 
	}
	
}


function switchsearch(obj) {
	if (obj=="P_search") {
		document.getElementById("A_search").style.display="none";
		document.getElementById("P_search").style.display="block";

		document.getElementById("aclass").className="white2";
		document.getElementById("pclass").className="white3";

	}
	else {
		document.getElementById("P_search").style.display="none";
		document.getElementById("A_search").style.display="block";

		document.getElementById("pclass").className="white2";
		document.getElementById("aclass").className="white3";


	}
}


function ChangeP_Country(targ) {
	var request = getNewXMLHttpRequest();
		var pos=0;
		var cid = document.getElementById("P_country").options[document.getElementById("P_country").selectedIndex].value;	
	if (cid!='') {
		document.getElementById("P_resort").options.length = 0;
		document.getElementById("P_resort").options[0] = new Option('Loading...','');
		disableIt(document.getElementById("P_resort"));
		 geturl='/config/getresorts.php?cid='+cid;
		request.open('GET', geturl);
		request.onreadystatechange=function() {
		  if (request.readyState==4) {
		           var response = request.responseText;
			     var resorts = response.split('|');
				for(i=0;i<resorts.length;i++){
					resort= resorts[i];
					resortbits = resort.split(":");
					if(resortbits[1]!=''){
						if (targ != 'none' && targ==resortbits[1])	{ 
				var pos=document.getElementById("P_resort").options.length;
				document.getElementById("P_resort").options[document.getElementById("P_resort").options.length] = new Option(resortbits[0],resortbits[1], "selected");

				}
						else	document.getElementById("P_resort").options[document.getElementById("P_resort").options.length] = new Option(resortbits[0],resortbits[1]);		
					}
				}
				document.getElementById("P_resort").options[0] = null;
			if (targ!='none' && pos>0) {
				document.getElementById("P_resort").selectFirstOption = false;
				document.getElementById("P_resort").options[pos-1].selected = true;
			}
				disableIt(document.getElementById("P_resort"));
			}
	 }
    		request.send(null);	
}

}



function ChangeA_Country(targ) {
	var request = getNewXMLHttpRequest();
		var pos=0;
		var cid = document.getElementById("A_country").options[document.getElementById("A_country").selectedIndex].value;	
	if (cid!='') {
		document.getElementById("A_resort").options.length = 0;
		document.getElementById("A_resort").options[0] = new Option('Loading...','');
		disableIt(document.getElementById("A_resort"));
		geturl='/config/getresorts.php?cid='+cid;
		request.open('GET', geturl);
		request.onreadystatechange=function() {
		  if (request.readyState==4) {
		           var response = request.responseText;
			     var resorts = response.split('|');
				for(i=0;i<resorts.length;i++){
					resort= resorts[i];
					resortbits = resort.split(":");
					if(resortbits[1]!=''){
						if (targ != 'none' && targ==resortbits[1]) 	{ 
							var pos=document.getElementById("A_resort").options.length;
							document.getElementById("A_resort").options[document.getElementById("A_resort").options.length] = new Option(resortbits[0],resortbits[1],"selected");
					}
						else document.getElementById("A_resort").options[document.getElementById("A_resort").options.length] = new Option(resortbits[0],resortbits[1]);
		
					}
				}
				document.getElementById("A_resort").options[0] = null;
			if (targ!='none' && pos>0) {
				document.getElementById("A_resort").selectFirstOption = false;
				document.getElementById("A_resort").options[pos-1].selected = true;
			}
				disableIt(document.getElementById("A_resort"));
			}
	 }
    		request.send(null);	

}
}
function disableIt(obj)
{
	obj.disabled = !(obj.disabled);
}

function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}

function changeImages() {
    preloadFlag = true;
  if (document.images && (preloadFlag == true)) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}


function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}
var preloadFlag = false;




function preloadImages() {
  if (document.images) {
    home_on = newImage("./images/home_.jpg");
    about_on = newImage("./images/about_.jpg");
    resorts_on = newImage("./images/resorts_.jpg");
    special_offers_on = newImage("./images/special_offers_.jpg");
    extras_on = newImage("./images/extras_.jpg");
    news_on = newImage("./images/news_.jpg");
    enquire_on = newImage("./images/enquire_.jpg");
    sb_on = newImage("./images/search_button_.jpg");
    gb_on = newImage("./images/go_btn.gif");

	    preloadFlag = true;
  }
}

function check_contact() {
	if (document.contact_form.contact_name.value=="" || document.contact_form.contact_email.value=="" ||	document.contact_form.contact_phone.value=="") {
		alert ('All fields marked with * are required!');
		return false;
	}
	else {
		return true; 
	}
}

 function showpicture(url,width, height)
	{
        LeftPosition=(screen.width)?(screen.width-width)/2:100;
     TopPosition=(screen.height)?(screen.height-height)/2:100;
        var Win = window.open(url,'showpic','width=' + width + ',height=' + height + ',top='+TopPosition+',left='+LeftPosition+',resizable=0,scrollbars=no,menubar=no,toolbar=no,status=no')
	}


function showagefields() {
		document.getElementById("age1").style.display="none";
		document.getElementById("age2").style.display="none";
		document.getElementById("age3").style.display="none";		
		document.getElementById("age4").style.display="none";		
		document.getElementById("age5").style.display="none";		
		document.getElementById("age6").style.display="none";
	amount=document.enquiry_form.e_children.options[document.enquiry_form.e_children.options.selectedIndex].value;
	if (amount==0) {
		document.getElementById("age1").style.display="none";
		document.getElementById("age2").style.display="none";
		document.getElementById("age3").style.display="none";		
		document.getElementById("age4").style.display="none";		
		document.getElementById("age5").style.display="none";		
		document.getElementById("age6").style.display="none";
	}	
	if (amount==1) {
		document.getElementById("age1").style.display="block";
	}
	if (amount==2) {
		document.getElementById("age1").style.display="block";
		document.getElementById("age2").style.display="block";		
	}
	if (amount==3) {
		document.getElementById("age1").style.display="block";
		document.getElementById("age2").style.display="block";		
		document.getElementById("age3").style.display="block";
	}
	if (amount==4) {
		document.getElementById("age1").style.display="block";
		document.getElementById("age2").style.display="block";		
		document.getElementById("age3").style.display="block";
		document.getElementById("age4").style.display="block";
	}
	if (amount==5) {
		document.getElementById("age1").style.display="block";
		document.getElementById("age2").style.display="block";		
		document.getElementById("age3").style.display="block";
		document.getElementById("age4").style.display="block";	
		document.getElementById("age5").style.display="block";
	}
	if (amount==6) {
		document.getElementById("age1").style.display="block";
		document.getElementById("age2").style.display="block";		
		document.getElementById("age3").style.display="block";
		document.getElementById("age4").style.display="block";	
		document.getElementById("age5").style.display="block";		
		document.getElementById("age6").style.display="block";
	}					
}	

function check_enquiry_form() {
	if (document.enquiry_form.e_firstname.value=="" || 
		document.enquiry_form.e_surname.value=="" ||	
		document.enquiry_form.e_email.value=="" ||	
		document.enquiry_form.e_phone.value=="" ||	
		document.enquiry_form.e_mobile.value=="") {
		alert ('All fields marked with * are required!');
		return false;
	}
	else {
		return true; 
	}
}

function check_enquiry_form_simple() {
	if (document.enquiry_form.e_firstname.value=="" || 
		document.enquiry_form.e_surname.value=="" ||	
		document.enquiry_form.e_email.value=="" ||	
		document.enquiry_form.e_phone.value=="" ) {
		alert ('All fields marked with * are required!');
		return false;
	}
	else {
		return true; 
	}
}