function recalculate_summer(code,web_price,total_price) {

var rafting_pax = document.getElementById('rafting_pax').value;
var loyalty_pax = document.getElementById("loyalty_pax").value;
var roomcosts = document.getElementById("roomcosts").value;
var group_discount = document.getElementById("group_d_a").value;
var total_price = document.getElementById('total_f_p').value;

var rafting_amount = 25;

/*
loyalty_choice
rafting_choice
room_choice
*/

//alert(loyalty_pax+"\n"+roomcosts+"\n"+group_discount+"\n"+total_price);
//so now we need to sort it out so that 
// 1. Amount for loyalty pax is when group discount removed. so



var total_loyal_am = (roomcosts - group_discount) * 0.05;
total_loyal_am = total_loyal_am*loyalty_pax
total_loyal_am = Math.round(total_loyal_am*100)/100;
document.getElementById("loyal_discs").innerHTML = "&pound;"+total_loyal_am+" (total)" ;


rafting_amount = rafting_amount * rafting_pax;
rafting_amount = Math.round(rafting_amount*100)/100;

document.getElementById("raft_discs").innerHTML = "&pound;"+rafting_amount+" (total)" ;


total_price = (total_price - total_loyal_am)-rafting_amount;
total_price = Math.round(total_price*100)/100;
document.getElementById("total_price").innerHTML = "&pound;"+total_price;

var voucher_code = document.create_basket_form.voucher_code.value.toUpperCase();
	 if (voucher_code == "10P3C3NT" && code==10) {
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		alert("10% off  voucher accepted");
		web_price = web_price * 0.9
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.9
		total_price=Math.round(total_price*100)/100
		//total_price = total_price + (flight_costsy*1)
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>  &#163;" + total_price+"</strong>";
		//document.getElementById('total_f_p').value = total_price;
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

		 if (voucher_code == "SHOWDISCOUNT12" && code==10) {
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		alert("Boat Show 10% off  voucher accepted");
		web_price = web_price * 0.9
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.9
		total_price=Math.round(total_price*100)/100
		//total_price = total_price + (flight_costsy*1)
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>  &#163;" + total_price+"</strong>";
		//document.getElementById('total_f_p').value = total_price;
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

		if (voucher_code == "5PERCENT" && code==5) {
		alert("5% off  voucher accepted");
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		web_price = web_price * 0.95
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.95
		//total_price = total_price + (flight_costsy*1)
		total_price=Math.round(total_price*100)/100
	//	document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>&#163;" + total_price+"</strong>";
		//document.getElementById('total_f_p').value = total_price;
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

	if (voucher_code == "15PERCENT" && code==15) {
		alert("15% off  voucher accepted");
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		web_price = web_price * 0.85
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.85
		//total_price = total_price + (flight_costsy*1)
		total_price=Math.round(total_price*100)/100
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>&#163;" + total_price+"</strong>";
		//document.getElementById('total_f_p').value = total_price;
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

	if (voucher_code == "20P3C3NT" && code==20) {
		alert("20% off  voucher accepted");
	//	var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		web_price = web_price * 0.8
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.8
		//total_price = total_price + (flight_costsy*1)
		total_price=Math.round(total_price*100)/100
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>&#163;" + total_price+"</strong>";
		//document.getElementById('total_f_p').value = total_price;
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}
}




function loyalty_check_reprice() {

var txt = "";
var amount = 0;
var split_amount =""
if (document.create_basket_form.single_drop) {
var singles = document.create_basket_form.single_drop.length;
if(singles == undefined) {
	if (document.create_basket_form.single_drop.checked) {
				var display_name = document.create_basket_form.single_drop.value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>";
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
	}

} else {
		for (i = 0; i < singles; i++) {
				if (document.create_basket_form.single_drop[i].checked) {
				//txt = txt + document.create_basket_form.single_drop[i].value + "<br/>";
				var display_name = document.create_basket_form.single_drop[i].value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>";
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
				}
		}
	}
}




if (document.create_basket_form.twin_drop) {
var twins = document.create_basket_form.twin_drop.length;


if(twins == undefined) {
if (document.create_basket_form.twin_drop.checked) {
				var display_name = document.create_basket_form.twin_drop.value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>"; 
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
}
} else {

		for (i = 0; i < twins; i++) {
				if (document.create_basket_form.twin_drop[i].checked) {
				//txt = txt + document.create_basket_form.twin_drop[i].value + "<br/>";
				var display_name = document.create_basket_form.twin_drop[i].value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>"; 
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
				}
		}
}
}


if (document.create_basket_form.double_drop) {
var doubles= document.create_basket_form.double_drop.length;

if(doubles == undefined) {
if (document.create_basket_form.double_drop.checked) {
				var display_name = document.create_basket_form.double_drop.value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>"; 
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
}
} else {

		for (i = 0; i < doubles; i++) {
				if (document.create_basket_form.double_drop[i].checked) {
				//txt = txt + document.create_basket_form.double_drop[i].value + "<br/>";
				var display_name = document.create_basket_form.double_drop[i].value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>"; 
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
				}
		}
}
}

if (document.create_basket_form.triple_drop) {
var triples = document.create_basket_form.triple_drop.length;

if(triples == undefined) {
		if (document.create_basket_form.triple_drop.checked) {
				var display_name = document.create_basket_form.triple_drop.value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>";
					split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
		}
} else {

		for (i = 0; i < triples; i++) {
				if (document.create_basket_form.triple_drop[i].checked) {
				//txt = txt + document.create_basket_form.triple_drop[i].value + "<br/>";
				var display_name = document.create_basket_form.triple_drop[i].value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>"; 
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
				}
		}
}
}


if (document.create_basket_form.quad_drop) {
var quads = document.create_basket_form.quad_drop.length;

if(quads == undefined) {
	if (document.create_basket_form.quad_drop.checked) {
				var display_name = document.create_basket_form.quad_drop.value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>";
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
	}
} else {
	for (i = 0; i < quads; i++) {

				if (document.create_basket_form.quad_drop[i].checked) {
				//txt = txt + document.create_basket_form.quad_drop[i].value + "<br/>";
				var display_name = document.create_basket_form.quad_drop[i].value;
				var room_like = "roomis_" + display_name;
				txt = txt + document.getElementById(room_like).innerHTML+"<BR/>"; 
				split_amount = display_name.split("_");
				amount = Number(amount) + Number(split_amount[1]);
				}
		}
}
}
if (txt == "") { //means that there is something in it so show the rooms list.
document.getElementById("room_choice").style.display ="none";
} else {
document.getElementById("room_choice").style.display ="block";
}
document.getElementById("room_supps_totals").innerHTML = txt;


var rafting_pax = document.getElementById('rafting_pax').value;
var loyalty_pax = document.getElementById("loyalty_pax").value;
var roomcosts = document.getElementById("roomcosts").value;
var group_discount = document.getElementById("group_d_a").value;
var total_price = document.getElementById('total_f_p').value 

var rafting_amount = 25;


/*
loyalty_choice
rafting_choice
room_choice
*/


//alert(loyalty_pax+"\n"+roomcosts+"\n"+group_discount+"\n"+total_price);
//so now we need to sort it out so that 
// 1. Amount for loyalty pax is when group discount removed. so



var total_loyal_am = (roomcosts - group_discount) * 0.05;
total_loyal_am = total_loyal_am*loyalty_pax
total_loyal_am = Math.round(total_loyal_am*100)/100;

//need to check if the price is not zerp and that it is not hidden then show it
if (document.getElementById("loyalty_choice")) {
if (total_loyal_am == 0.00)
{
document.getElementById("loyalty_choice").style.display ="none";
} else {
document.getElementById("loyalty_choice").style.display ="block";
}

document.getElementById("loyal_discs").innerHTML = "&pound;"+total_loyal_am+" (total)" ;
}

rafting_amount = rafting_amount * rafting_pax;
rafting_amount = Math.round(rafting_amount*100)/100;

if (document.getElementById("rafting_choice")) {
if (rafting_amount == 0.00 || rafting_amount == 0)
{
document.getElementById("rafting_choice").style.display ="none";
} else {
document.getElementById("rafting_choice").style.display ="block";
}

document.getElementById("raft_discs").innerHTML = "&pound;"+rafting_amount+" (total)" ;
}

total_price = ((total_price - total_loyal_am)-rafting_amount)+amount;
total_price = Math.round(total_price*100)/100;
document.getElementById("total_price").innerHTML = "&pound;"+total_price;

//document.getElementById('total_f_p').value = total_price;

}
function loyalty_check_summer() {
//need to get the alue of the check box
var r=confirm("Terms: \nWe are glad that you have chosen to travel with us again. \nOur Loyalty discounts are for repeat guests only. \nIf you or any of your party have not been with us before and your booking comes into us with the discount applied, \nthen we will simply take off the discount and process the order as normal. \nClick ok if you agree to these terms");
return false;
}


function loyalty_check() {
//need to get the alue of the check box
var cbvalue = document.getElementById("loyalty_chkbox").checked;
	if (cbvalue == true){
	var r=confirm("Terms: \nWe are glad that you have chosen to travel with us again. \nOur Loyalty discounts are for repeat guests only. \nIf you or any of your party have not been with us before and your booking comes into us with the discount applied, \nthen we will simply take off the discount and process the order as normal. \nClick ok if you agree to these terms");
	} 
		if (r==false)  {
			document.getElementById("loyalty_chkbox").checked = false;
		 }


}

function enter_competition()
{

var strError = "";
  if (document.getElementById("email").value=='') {
		strError=strError + "Email is mandatory\n";
	  }
	  if (document.getElementById("first_name").value=='') {
		strError=strError + "First name is mandatory\n";
	  }
	  if (document.getElementById("last_name").value=='') {
		strError=strError + "Surname is mandatory\n";
	  }

	  if (document.getElementById("postcode").value=='') {
		strError=strError + "Post Code is Mandatory\n";
	  }
	 if (document.getElementById("housenumbercomp").value=='') {
		strError=strError + "House Number is Mandatory\n";
	  }

  if (strError=='') {


var	brochures = "Alpine Elements Winter";


xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

//var url="http://travelink.alpineelements.co.uk/dandylogic/postcode_check.asp?postcode="+pcode;

var url="http://www.alpineelements.co.uk/forms/post_brochure.php";
url=url+"?subject=Brochure Request";
url=url+"&first_name="+document.getElementById("first_name").value;
url=url+"&last_name="+document.getElementById("last_name").value;
url=url+"&email="+document.getElementById("email").value;
url=url+"&title=";
url=url+"&address1="+document.getElementById("housenumbercomp").value;
url=url+"&address2="+document.getElementById("add1").innerHTML;
url=url+"&address3="+document.getElementById("add2").innerHTML;
url=url+"&address4="+document.getElementById("towncity").innerHTML;
url=url+"&postcode="+document.getElementById("postcode").value;
url=url+"&brochure="+brochures;
url=url+"&email_from=sales@alpineelements.co.uk";


xmlHttp.onreadystatechange=stateChanged_entercomp;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);





var themail = document.getElementById("email").value;
var url_to_post = "http://www.alpineelements.co.uk/includes/capture_email_comp.php?email="+themail;
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	}	else  {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4 && xmlhttp.status==200)	 {
			}
		}
xmlhttp.open("GET",url_to_post,true);
xmlhttp.send();

  } else {
	alert(strError);
	return false;
  }

} 


function stateChanged_entercomp() 
{ 
if (xmlHttp.readyState==4)
{ 
//alert("All good")
	document.getElementById("response_brochure").innerHTML="<FONT Color='green'>Thankyou for entry</font>";
}
}

function getbrochures()
{

var strError = "";
  if (document.getElementById("email").value=='') {
		strError=strError + "Email is mandatory\n";
	  }
	  if (document.getElementById("first_name").value=='') {
		strError=strError + "First name is mandatory\n";
	  }
	  if (document.getElementById("last_name").value=='') {
		strError=strError + "Surname is mandatory\n";
	  }

	  if (document.getElementById("postcode").value=='') {
		strError=strError + "Post Code is Mandatory\n";
	  }
	 if (document.getElementById("housenumber").value=='') {
		strError=strError + "House Number is Mandatory\n";
	  }
if (document.getElementById("brochures").value =='NONE'){
 		strError=strError + "Please Choose a Brochure\n";
	  }
  if (strError=='') {





xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var brochures =document.getElementById("brochures").value;
if (brochures == "winter"){
	//Brochure Request : Ocean Elements
	brochures = "Alpine Elements Winter";
}
if (brochures == "summer")
{
	brochures = "Alpine Summer";
}

if (brochures == "beach")
{
	brochures = "Ocean Elements";
}

if (brochures == "weekend")
{
	brochures = "Ski Weekends";
}

//var url="http://travelink.alpineelements.co.uk/dandylogic/postcode_check.asp?postcode="+pcode;

var url="post_brochure.php";
url=url+"?subject=Brochure Request";
url=url+"&first_name="+document.getElementById("first_name").value;
url=url+"&last_name="+document.getElementById("last_name").value;
url=url+"&email="+document.getElementById("email").value;
url=url+"&title=";
url=url+"&address1="+document.getElementById("housenumber").value;
url=url+"&address2="+document.getElementById("add1").innerHTML;
url=url+"&address3="+document.getElementById("add2").innerHTML;
url=url+"&address4="+document.getElementById("towncity").innerHTML;
url=url+"&postcode="+document.getElementById("postcode").value;
url=url+"&brochure="+brochures;
url=url+"&email_from=sales@alpineelements.co.uk";


//alert(url);
//document.getElementById("response_brochure").innerHTML=url;
xmlHttp.onreadystatechange=stateChanged_brochure;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
  } else {
	alert(strError);
	return false;
  }

} 

function getbrochurescomp()
{

var strError = "";
  if (document.getElementById("email").value=='') {
		strError=strError + "Email is mandatory\n";
	  }
	  if (document.getElementById("first_name").value=='') {
		strError=strError + "First name is mandatory\n";
	  }
	  if (document.getElementById("last_name").value=='') {
		strError=strError + "Surname is mandatory\n";
	  }

	  if (document.getElementById("postcode").value=='') {
		strError=strError + "Post Code is Mandatory\n";
	  }
	 if (document.getElementById("housenumbercomp").value=='') {
		strError=strError + "House Number is Mandatory\n";
	  }
if (document.getElementById("brochures").value =='NONE'){
 		strError=strError + "Please Choose a Brochure\n";
	  }
  if (strError=='') {





xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var brochures =document.getElementById("brochures").value;
if (brochures == "winter"){
	//Brochure Request : Ocean Elements
	brochures = "Alpine Elements Winter";
}
if (brochures == "summer")
{
	brochures = "Alpine Summer";
}

if (brochures == "beach")
{
	brochures = "Ocean Elements";
}

if (brochures == "weekend")
{
	brochures = "Ski Weekends";
}

//var url="http://travelink.alpineelements.co.uk/dandylogic/postcode_check.asp?postcode="+pcode;

var url="http://www.alpineelements.co.uk/forms/post_brochure.php";
url=url+"?subject=Brochure Request";
url=url+"&first_name="+document.getElementById("first_name").value;
url=url+"&last_name="+document.getElementById("last_name").value;
url=url+"&email="+document.getElementById("email").value;
url=url+"&title=";
url=url+"&address1="+document.getElementById("housenumbercomp").value;
url=url+"&address2="+document.getElementById("add1").innerHTML;
url=url+"&address3="+document.getElementById("add2").innerHTML;
url=url+"&address4="+document.getElementById("towncity").innerHTML;
url=url+"&postcode="+document.getElementById("postcode").value;
url=url+"&brochure="+brochures;
url=url+"&email_from=sales@alpineelements.co.uk";


//alert(url);
//document.getElementById("response_brochure").innerHTML=url;
xmlHttp.onreadystatechange=stateChanged_brochure;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
  } else {
	alert(strError);
	return false;
  }

} 


function stateChanged_brochure() 
{ 
if (xmlHttp.readyState==4)
{ 
//alert("All good")
	document.getElementById("response_brochure").innerHTML=xmlHttp.responseText;
}
}

function get_postcode()
{

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  pcode = document.getElementById("postcode").value;
  housenumber = document.getElementById("housenumber").value;
if (pcode == "")
{
	alert("You must enter a Postcode");
	return false;
}

if (housenumber == "")
{
	alert("You must enter a House Number");
	return false;
}


pcode =pcode.replace(" ", "");
//var url="http://travelink.alpineelements.co.uk/dandylogic/postcode_check.asp?postcode="+pcode;
var url="http://www.alpineelements.co.uk/get_postcode.php?postcode="+pcode;
xmlHttp.onreadystatechange=stateChanged_postcode;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function get_postcode_comp()
{

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  pcode = document.getElementById("postcode").value;
  housenumber = document.getElementById("housenumbercomp").value;
if (pcode == "")
{
	alert("You must enter a Postcode to enter our competition");
	return false;
}

if (housenumber == "")
{
	alert("You must enter a House Number to enter our competition");
	return false;
}


pcode =pcode.replace(" ", "");
//var url="http://travelink.alpineelements.co.uk/dandylogic/postcode_check.asp?postcode="+pcode;
var url="http://www.alpineelements.co.uk/get_postcode.php?postcode="+pcode;
xmlHttp.onreadystatechange=stateChanged_postcodecomp;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged_postcodecomp() 
{ 
if (xmlHttp.readyState==4)
{ 

//alert(xmlHttp.responseText);
var mySplitResult = xmlHttp.responseText.split(",");
var add1 = mySplitResult[0];
add1 = add1.split("=");
add1 = add1[1];
var add2 = mySplitResult[1];
add2 = add2.split("=");
add2 = add2[1];
var towncity = mySplitResult[2];
towncity = towncity.split("=");
towncity = towncity[1];
var county = mySplitResult[3];
county = county.split("=");
county = county[1];
var postcode=mySplitResult[4];
postcode = postcode.split("=");
postcode = postcode[1];

	//need to chaneg all the boxes and values with the new stuff we have from the 
document.getElementById("HouseNum").innerHTML = document.getElementById("housenumbercomp").value;
document.getElementById("add1").innerHTML=add1;
document.getElementById("add2").innerHTML=add2;
document.getElementById("towncity").innerHTML=towncity;
document.getElementById("county").innerHTML=county;
document.getElementById("address_holder").style.display="block";



}
}


function stateChanged_postcode() 
{ 
if (xmlHttp.readyState==4)
{ 

//alert(xmlHttp.responseText);
var mySplitResult = xmlHttp.responseText.split(",");
var add1 = mySplitResult[0];
add1 = add1.split("=");
add1 = add1[1];
var add2 = mySplitResult[1];
add2 = add2.split("=");
add2 = add2[1];
var towncity = mySplitResult[2];
towncity = towncity.split("=");
towncity = towncity[1];
var county = mySplitResult[3];
county = county.split("=");
county = county[1];
var postcode=mySplitResult[4];
postcode = postcode.split("=");
postcode = postcode[1];

	//need to chaneg all the boxes and values with the new stuff we have from the 
document.getElementById("HouseNum").innerHTML = document.getElementById("housenumber").value;
document.getElementById("add1").innerHTML=add1;
document.getElementById("add2").innerHTML=add2;
document.getElementById("towncity").innerHTML=towncity;
document.getElementById("county").innerHTML=county;
document.getElementById("address_holder").style.display="block";



}
}


function show_image(dot, id, path) {
//	alert(dot);
/*
1. get the main image conatiner id
2. display the image in there that we need
3. Change the colour of the dots to black
*/

var main_image ="pictures"+id;
if (path == "")
{
	path = "/images/no_photo.gif";
}
var real_path = "http://www.alpineelements.co.uk"+path;
document.getElementById(main_image).src = 'http://www.alpineelements.co.uk'+path;

var i=1;

		for (i=1;i<=6;i++)
		{
var my_dotty = "shown_"+i+"_"+id;

				if (i == dot){
					document.getElementById(my_dotty).src = 'http://www.alpineelements.co.uk/images/shown.gif';				
				} else {
					document.getElementById(my_dotty).src = 'http://www.alpineelements.co.uk/images/not_shown.gif';
				}

		}


}




function dispHandlexx(obj) {
if (obj == "price_conatiner_2") {
var x = document.getElementById(obj);
var y = document.getElementById("price_conatiner_1");
/*document.getElementById("head_text").innerHTML = "Showing Winter 2011 / 2012";
document.getElementById("image1").style.opacity="1";
document.getElementById("image1").style.filter="alpha(opacity=100)" ;
document.getElementById("image2").style.opacity="0.4";
document.getElementById("image2").style.filter="alpha(opacity=40)" ;
*/

}
if (obj == "price_conatiner_1") {
var x = document.getElementById(obj);
var y = document.getElementById("price_conatiner_2");
/*document.getElementById("head_text").innerHTML = "Showing Winter 2010 / 2011";
document.getElementById("image1").style.opacity="0.4";
document.getElementById("image1").style.filter="alpha(opacity=40)" ;
document.getElementById("image2").style.opacity="1.0";
document.getElementById("image2").style.filter="alpha(opacity=100)" ;
*/
}
x.style.display = "block";
y.style.display = "none";
}
	
	function showDealsSignup() {
		document.getElementById("signup_news").style.display="block";

	}
	function deals_signup() {
	var email_address=	document.getElementById("email_newsletter").value;
	document.getElementById("signup_news").style.display="none";
	var url_to_post = "/includes/capture_email.php?email="+email_address;
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	}	else  {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4 && xmlhttp.status==200)	 {
			}
			}
xmlhttp.open("GET",url_to_post,true);
xmlhttp.send();
}



function dynamic_pricing(amount)  {
	//alert(amount);

}

function recalculate(code,web_price,total_price) {
var voucher_code = document.create_basket_form.voucher_code.value.toUpperCase();
	 if (voucher_code == "10P3C3NT" && code==10) {
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		alert("10% off  voucher accepted");
		web_price = web_price * 0.9
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.9
		total_price=Math.round(total_price*100)/100
		total_price = total_price + (flight_costsy*1)
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>  &#163;" + total_price+"</strong>";
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

		 if (voucher_code == "SHOWDISCOUNT12" && code==10) {
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		alert("Boat Show 10% off  voucher accepted");
		web_price = web_price * 0.9
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.9
		total_price=Math.round(total_price*100)/100
		total_price = total_price + (flight_costsy*1)
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>  &#163;" + total_price+"</strong>";
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

		if (voucher_code == "5PERCENT" && code==5) {
		alert("5% off  voucher accepted");
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		web_price = web_price * 0.95
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.95
		total_price = total_price + (flight_costsy*1)
		total_price=Math.round(total_price*100)/100
	//	document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>&#163;" + total_price+"</strong>";
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

	if (voucher_code == "15PERCENT" && code==15) {
		alert("15% off  voucher accepted");
		//var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		web_price = web_price * 0.85
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.85
		total_price = total_price + (flight_costsy*1)
		total_price=Math.round(total_price*100)/100
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>&#163;" + total_price+"</strong>";
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}

	if (voucher_code == "20P3C3NT" && code==20) {
		alert("20% off  voucher accepted");
	//	var flight_costsy = document.getElementById('new_total_flight_price').value;
		var flight_costsy = 0;
		web_price = web_price * 0.8
		web_price=Math.round(web_price*100)/100
		total_price = total_price * 0.8
		total_price = total_price + (flight_costsy*1)
		total_price=Math.round(total_price*100)/100
		//document.getElementById('web_price').innerHTML = "<strong>&#163;" + web_price+"</strong>";
		document.getElementById('total_price').innerHTML = "<strong>&#163;" + total_price+"</strong>";
		var vc_code = document.getElementById('vc_on');
		vc_code.value = "true"; 
	}
}





function show_vc(disc_perc) {
	var email_vc = document.getElementById("email_vc").value;
	var site_area = document.getElementById("site_area").value;

if (email_vc.length < 5) {
	alert("Please Enter a valid email address");
	return false
}else{
if (disc_perc == 20){
document.getElementById("vc_code").innerHTML = "20P3C3NT";
}else if (disc_perc == 5){
document.getElementById("vc_code").innerHTML = "5PERCENT";
}else if (disc_perc == 15){
document.getElementById("vc_code").innerHTML = "15PERCENT";
}else {
	if (site_area != "winter")	{
document.getElementById("vc_code").innerHTML = "10P3C3NT";
	} else {
	document.getElementById("vc_code").innerHTML = "10P3C3NT";
	}
}
getVC("goodonw");
}

}


var xmlHttp;
function getVC(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
 

var email_vc = document.getElementById("email_vc").value;
var url="https://secureuk.alpineelements.co.uk/dandylogic/vc_store_email.asp?email="+email_vc+"&vc=10";
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
//document.getElementById("vc_code").innerHTML=xmlHttp.responseText;

}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function reload_form() {
	var load_page = document.getElementById("Season").value; 
	if (load_page == "4")
	{
		window.location = "http://www.alpineelements.co.uk/ski-holidays.html"; 
	}
		if (load_page == "6")
	{
	SelectSubCat();
	}

	if (load_page == "5" )
	{
window.location = "http://www.alpineelements.co.uk/activity-holidays.html";  
	}
}
function goheredeals(where) {

	 hu = window.location.search.substring(1);
window.location = where; 
return false; 
}

function ChangeDaysDuration() {
var date_dur = document.getElementById("date_range").value; 
if (date_dur == "7-Jan-2012") {
	document.getElementById("days_duration").value = 8;
} else {
	document.getElementById("days_duration").value = 7;

}

}


var timerlen = 5;
var slideAniLen = 250;
var selected = "";
var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=200,left = 490,top = 312');");
}
function DisplayAlert(id,left,top) {
document.getElementById(id).style.left=left+'px';
document.getElementById(id).style.top=top+'px';
document.getElementById(id).style.display='block';
}
function DoSomething() {
var something = false;
if(something) {
   // do this section
   }
else {
   DisplayAlert('AlertBox',100,50);
   }
}

function gohere2(where) {
   if (where == "luxury")   {
	   window.location = "http://www.alpineelements.co.uk/luxury-ski-holidays.html"; 
   }
      if (where == "beach")   {
	   window.location = "http://www.alpineelements.co.uk/beach-holidays.html"; 
   }
      if (where == "winter")   {
	   window.location = "http://www.alpineelements.co.uk/ski-holidays.html"; 
   }
      if (where == "activity")   {
	   window.location = "http://www.alpineelements.co.uk/activity-holidays.html"; 
   }
    


}


function gohere(where) {

//alert("go_where");
//var flight_var = document.getElementById('flight_var').value;
 var radioResults = 'Radio buttons: ';
    for (var i = 0; i < document.create_basket_form.elements.length; i++ ) {
        if (document.create_basket_form.elements[i].type == 'checkbox') {
            if (document.create_basket_form.elements[i].checked == true) {
                cbResults += document.create_basket_form.elements[i].value + ' ';
            }
        }
        if (document.create_basket_form.elements[i].type == 'radio') {
            if (document.create_basket_form.elements[i].checked == true) {
                radioResults = document.create_basket_form.elements[i].value + ' ';
            }
        }
    }

radioResults = "&flights="+radioResults;
//alert(radioResults);
//for (var i=0; i < document.create_basket_form.flights.length; i++)
//   {
 //  if (document.create_basket_form.flights[i].checked)
  //    {
  //    var rad_val = document.create_basket_form.flights[i].value;
  //    }
  // }
//alert (rad_val);
//alert("the location" + where);
//return false;
//alert("the location" + where);
window.location = where+radioResults; 
return false; 
}

function anyCheck(form){
//alert("anycheck");
    var total = 0;
    var no_adults = getQuerystring('no_adults');
    var no_children = getQuerystring('no_children');

    no_adults = no_adults * 1;
    no_children = no_children * 1;
    var total_pax = (no_adults + no_children);
    if (hu == "") {
    }
    else {
        var destination = querySt("destination");
        if (destination.length > 15) {
            var mySplitDestination = destination.split("*");
            destination = mySplitDestination[0];
        }
        var shit_check = check_pax_allocation(destination, (total_pax));
		
	if (shit_check != true) {
        if (shit_check != undefined) {
            SelectPaxs2(shit_check[3], shit_check[2]);
            //alert(shit_check[3] +" --" + shit_check[2]);
			document.form.no_adults.focus();
		//	 return false;
        }

    }
		
     /*   if (shit_check != true) {
            if (shit_check != undefined) {
                SelectPaxs2(shit_check[3], shit_check[0]);
				//alert("this undefined");
            }
            else {
                return false;
            }
            
            document.getElementById("no_adults").focus();
            return false;
        }
    */
    }
    
    
    if (document.create_basket_form.single_drop) {
        var singles = document.create_basket_form.single_drop.length;
        if (singles === undefined) {
            if (eval("document.create_basket_form.single_drop.checked") == true) {
                total += 1;
            }
        }
        
        for (var idx = 0; idx < singles; idx++) {
            if (eval("document.create_basket_form.single_drop[" + idx + "].checked") == true) {
                total += 1;
            }
        }
    }
    if (document.create_basket_form.double_drop) {
        var doubles = document.create_basket_form.double_drop.length;
        if (doubles === undefined) {
            if (eval("document.create_basket_form.double_drop.checked") == true) {
                total += 2;
            }
        }
        for (var idx = 0; idx < doubles; idx++) {
            if (eval("document.create_basket_form.double_drop[" + idx + "].checked") == true) {
                total += 2;
            }
        }
    }
    
    if (document.create_basket_form.twin_drop) {
        var twins = document.create_basket_form.twin_drop.length;
        if (twins === undefined) {
            if (eval("document.create_basket_form.twin_drop.checked") == true) {
                total += 2;
            }
        }
        for (var idx = 0; idx < twins; idx++) {
            if (eval("document.create_basket_form.twin_drop[" + idx + "].checked") == true) {
                total += 2;
            }
        }
    }
    
    if (document.create_basket_form.triple_drop) {
        var triples = document.create_basket_form.triple_drop.length;
        if (triples === undefined) {
            if (eval("document.create_basket_form.triple_drop.checked") == true) {
                total += 3;
            }
        }
        for (var idx = 0; idx < triples; idx++) {
            if (eval("document.create_basket_form.triple_drop[" + idx + "].checked") == true) {
                total += 3;
            }
        }
    }
    
  if (document.create_basket_form.quad_drop) {
        var quads = document.create_basket_form.quad_drop.length;
        if (quads === undefined) {
            if (eval("document.create_basket_form.quad_drop.checked") == true) {
                total += 4;
            }
        }
        for (var idx = 0; idx < quads; idx++) {
            if (eval("document.create_basket_form.quad_drop[" + idx + "].checked") == true) {
                total += 4;
            }
        }
    }
    
//================STAR OF THE CHALET CHECK=======================
 if (document.create_basket_form.chalet_drop) {
        var chalet = document.create_basket_form.chalet_drop.length;
				if (chalet === undefined) {
							if (eval("document.create_basket_form.chalet_drop.checked") == true) {	
								var testmychalet = document.create_basket_form.chalet_drop.value; 
								var min_max_passenger = testmychalet.split("*");
								min_paxs = min_max_passenger[1];
								max_paxs = min_max_passenger[2];
								std_paxs = min_max_passenger[3];
									if (total_pax >= min_paxs && total_pax <= max_paxs){
										total += total_pax;
										document.getElementById('no_adults_span').innerHTML = "<INPUT TYPE=hidden NAME=no_adults id=no_adults value=" + no_adults + ">";
										document.getElementById('no_children_span').innerHTML = "<INPUT TYPE=hidden NAME=no_children id=no_children value="+no_children+">";
									} else{
										total += std_paxs;	
										document.getElementById('no_adults_span').innerHTML = "<INPUT TYPE=hidden NAME=no_adults id=no_adults value=" + std_paxs + ">";
										document.getElementById('no_children_span').innerHTML = "<INPUT TYPE=hidden NAME=no_children id=no_children value=0>";
									}			
						}
			}
						for (var idx = 0; idx < chalet; idx++) {
										if (eval("document.create_basket_form.chalet_drop[" + idx + "].checked") == true) {
											var testmychalet = document.create_basket_form.chalet_drop.value; 
											var min_max_passenger = testmychalet.split("*");
											min_paxs = min_max_passenger[1];
											max_paxs = min_max_passenger[2];
													if (no_adults >= min_paxs && no_adults <= max_paxs){
														document.getElementById('no_adults_span').innerHTML = "<INPUT TYPE=hidden NAME=no_adults id=no_adults value=" + no_adults + ">";
														document.getElementById('no_children_span').innerHTML = "<INPUT TYPE=hidden NAME=no_children id=no_children value="+no_children+">";
														total += total_pax;
													} else{
														total += min_paxs;	
														document.getElementById('no_adults_span').innerHTML = "<INPUT TYPE=hidden NAME=no_adults id=no_adults value=" + std_paxs + ">";
														document.getElementById('no_children_span').innerHTML = "<INPUT TYPE=hidden NAME=no_children id=no_children value=0>";
													}
									   }
			
						}
    }
//================END OF THE CHALET CHECK=======================
    
	
		if (total === 0) {      
			   if(document.create_basket_form.ignore_button){
					return true;
			   }else{
					 document.getElementById('room_selection').innerHTML = "Please Choose you rooms";
					return false;	
			   }   
		}
    
		if (total_pax > total) {
			alert("You have not selected enough accommodation  for " + total_pax + " x passengers \n If you are Having Difficulty \n please call 0844 770 4070");
			document.getElementById('room_selection').innerHTML = "<font color='red'>You have not selected enough accommodation</font>";
			return false;
		}


    if (total_pax < total) {
        alert("You have selected too much accommodation\nIf you are Having Difficulty \n please call \n 0844 770 4070");
        document.getElementById('room_selection').innerHTML = "<font color='red'>You have selected too much accommodation</font>";
		total = total - no_children;
		//need to enter the details thing in here
		document.getElementById('no_adults_span').innerHTML = "<INPUT TYPE=hidden NAME=no_adults id=no_adults value=" + total + ">";
        document.getElementById('no_children_span').innerHTML = "<INPUT TYPE=hidden NAME=no_children id=no_children value="+no_children+">";
		return true;
    }
    
    if (total_pax === total) {
        return true;
    }
}


function destinationxx(a){
    /*this is split into 4 vars i think
     1:Hcode - HOT0000519
     2:Price - 739*
     3:Chalet Name
     4:Resort
     5:Min Paxs
     */
   // alert("The destination is"+a);
    
    //alert("TWAT"+ document.getElementById('destinationy').innerHTML);
    


    var mySplitDestination = a.split("*");
    //alert(mySplitDestination[4]);
    min_passengers = mySplitDestination[4];
    min_children = mySplitDestination[5];
    //alert(min_passengers);
    //alert(min_children);
    if (min_passengers == 2) {
        //alert("2 pax");
    }
    else {
        min_passengers = min_passengers - min_children;
        //alert(min_passengers);
        document.getElementById('no_adults_span').innerHTML = "<INPUT TYPE=hidden NAME=no_adults id=no_adults value=" + min_passengers + ">";
        
        document.getElementById('no_children_span').innerHTML = "<INPUT TYPE=hidden NAME=no_children id=no_children value=" + min_children + ">";

    }

	//alert ("THis is where we change the Form Action");
	if (document.create_basket_form.individual_chalet_found) {
	
		var individual_chalet_found = document.create_basket_form.individual_chalet_found.value
		if (individual_chalet_found == "Yes") {
			//alert("individual_chalet_found");
			document.create_basket_form.action = "booking.php"
		}
	}

    
    document.getElementById('destinationy').innerHTML = "<INPUT TYPE=hidden NAME=destination id=destination value=" + a + ">";
    return false;
}

function slidedown(objname){
    if (moving[objname]) 
        return;
    
    if (document.getElementById(objname).style.display != "none") 
        return; // cannot slide down something that is already visible
    moving[objname] = true;
    dir[objname] = "down";
    startslide(objname);
}

function slideup(objname){
    if (moving[objname]) 
        return;
    
    if (document.getElementById(objname).style.display == "none") 
        return; // cannot slide up something that is already hidden
    moving[objname] = true;
    dir[objname] = "up";
    startslide(objname);
}

function startslide(objname){
    obj[objname] = document.getElementById(objname);
    
    endHeight[objname] = parseInt(obj[objname].style.height);
    startTime[objname] = (new Date()).getTime();
    
    if (dir[objname] == "down") {
        obj[objname].style.height = "1px";
    }
    
    obj[objname].style.display = "block";
    
    timerID[objname] = setInterval('slidetick(\'' + objname + '\');', timerlen);
}

function slidetick(objname){
    var elapsed = (new Date()).getTime() - startTime[objname];
    
    if (elapsed > slideAniLen) 
        endSlide(objname)
    else {
        var d = Math.round(elapsed / slideAniLen * endHeight[objname]);
        if (dir[objname] == "up") 
            d = endHeight[objname] - d;
        
        obj[objname].style.height = d + "px";
    }
    
    return;
}

function endSlide(objname){
    clearInterval(timerID[objname]);
    
    if (dir[objname] == "up") 
        obj[objname].style.display = "none";
    
    obj[objname].style.height = endHeight[objname] + "px";
    
    delete (moving[objname]);
    delete (timerID[objname]);
    delete (startTime[objname]);
    delete (endHeight[objname]);
    delete (obj[objname]);
    delete (dir[objname]);
    
    return;
}

function toggleSlide(objname){
    if (document.getElementById(objname).style.display == "none") {
        // div is hidden, so let's slide down
        slidedown(objname);
    }
    else {
        // div is not hidden, so slide up
        slideup(objname);
    }
}

function removeAllOptions(selectbox){
    var i;
    for (i = selectbox.options.length - 1; i >= 0; i--) {
        //selectbox.options.remove(i);
        selectbox.remove(i);
    }
}

function addOption(selectbox, value, text, selected){
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    //alert(selected);
    if (selected != "") {
        optn.selected = true;
    }
    
    selectbox.options.add(optn);
}

function querySt(ji){
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

function URLDecode(url) //function decode URL
{
    // Replace + with ' '
    // Replace %xx with equivalent character
    // Put [ERROR] in output if %xx is invalid.
    var HEXCHARS = "0123456789ABCDEFabcdef";
    var encoded = url;
    var plaintext = "";
    var i = 0;
    while (i < encoded.length) {
        var ch = encoded.charAt(i);
        if (ch == "+") {
            plaintext += " ";
            i++;
        }
        else 
            if (ch == "%") {
                if (i < (encoded.length - 2) &&
                HEXCHARS.indexOf(encoded.charAt(i + 1)) != -1 &&
                HEXCHARS.indexOf(encoded.charAt(i + 2)) != -1) {
                    plaintext += unescape(encoded.substr(i, 3));
                    i += 3;
                }
                else {
                    //alert( 'Bad escape combination near ...' + encoded.substr(i) );
                    plaintext += "%[ERROR]";
                    i++;
                }
            }
            else {
                plaintext += ch;
                i++;
            }
    } // while 
    return plaintext;
};

function URLEncode(url) //Function to encode URL.
{
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" + // Numeric
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
    "abcdefghijklmnopqrstuvwxyz" +
    "-_.!~*'()"; // RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";
    
    var plaintext = url;
    var encoded = "";
    for (var i = 0; i < plaintext.length; i++) {
        var ch = plaintext.charAt(i);
        if (ch == " ") {
            encoded += "+"; // x-www-urlencoded, rather than %20
        }
        else 
            if (SAFECHARS.indexOf(ch) != -1) {
                encoded += ch;
            }
            else {
                var charCode = ch.charCodeAt(0);
                if (charCode > 255) {
                    alert("Unicode Character '" +
                    ch +
                    "' cannot be encoded using standard URL encoding.\n" +
                    "(URL encoding only supports 8-bit characters.)\n" +
                    "A space (+) will be substituted.");
                    encoded += "+";
                }
                else {
                    encoded += "%";
                    encoded += HEX.charAt((charCode >> 4) & 0xF);
                    encoded += HEX.charAt(charCode & 0xF);
                }
            }
    }
    
    return encoded;
};

function loadImages(){
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById('hidepage').style.visibility = 'hidden';
    }
    else {
        if (document.layers) { // Netscape 4
            document.hidepage.visibility = 'hidden';
        }
        else { // IE 4
            document.all.hidepage.style.visibility = 'hidden';
        }
    }
}

function checkformPax(form){

    var email = document.finalForm.txtEmail.value;
    var emailconf = document.finalForm.txtEmailconf.value;
    var phone = document.finalForm.txtPhone.value;
    var mobile = document.finalForm.txtMobile.value;
    
    // ** THERE NEEDS TO BE AT LEAST 1 THing here so that we can contact themSTART **
    
    if (email != emailconf) {
        alert("emails do not match")
        return false;
    }
    if (phone == "" && mobile == "") {
        alert("Please Enter a contact Number")
        return false;
    }
    
    //alert email;
    return true;
    
    
}

function check_pax_allocation(hotel_code, paxs){

	var free_sell = 0;
	if (document.create_basket_form) {
	
		if (document.create_basket_form.free_sell) {
			free_sell = document.create_basket_form.free_sell.value;
		}
	}


	if (free_sell == 1) {
		return true;
	} else {
		//(ae_min, igo_min, hcode, max_occ)
	
		if (hotel_code != "") {
			for (x in chalet_array_final) {
				myString = new String(chalet_array_final[x])
				z = (myString.indexOf(hotel_code));
				
				if (z < 0) {
					// alert("not found it");
				}
				else {
					//alert("found it");
					
					var mySplitResult = chalet_array_final[x].split(",");
					
					
					/*
					 1. need to get the value of the initial search
					 2. then check if its the minimum number
					 3. if ok then continue
					 4. if not change the value to the correct number and then return false
					 5. show the maximum number
					 */
					if (parseInt(paxs) < parseInt(mySplitResult[3])) {
						
	//alert("Minimum occupancy " + mySplitResult[3] + " persons \n Please search again \n If you are experiencing difficulty \nplease call 0844 770 4070 and \speak to a sales representative  ");
	
	var search_date = document.form.date_range.value;

 var split_search_date = search_date.split("-");
	var search_date= new Date(split_search_date[0]+","+split_search_date[1]+","+split_search_date[2]);

	today=new Date()
	//Get 1 day in milliseconds
	var one_day=1000*60*60*24
	//Calculate difference btw the two dates, and convert to days
	var days_left =((search_date.getTime()-today.getTime())/(one_day));
	var the_seasons = document.form.Season.value;
	//alert(the_seasons);
	if (days_left > 42)	{
		if(the_seasons != "3"){
			if (mySplitResult[7] !="HOT0000516")
			{
				alert("Minimum occupancy is usually " + mySplitResult[3] + " persons\n\n You may be able to book if the chalet has been made available for smaller groups.\n\nClick OK to continue\n\n Please call 0844 770 4070 for any queries");
			}
			
		}
	}
			return mySplitResult;
					}
					else //(ae_min, igo_min, hcode, max_occ)
 						if (parseInt(paxs) > parseInt(mySplitResult[4])) {
							//alert("max occupancy " + mySplitResult[4] + " persons \n Please search again \n If you are experiencing difficulty \nplease call 0844 770 4070 and \speak to a sales representative   ");
							return mySplitResult;
							
						}
						else {
						// return true; 
						}
					
					
				}
			}
		}
		
	}
}
function checkform(form){

    //
    //alert("Checkform");
    var duration = document.form.duration.value;
    var val = document.form.date_range_start.value;
    var dates = form.date_range.options[form.date_range.options.selectedIndex].value;
    var destination = form.destination.options[form.destination.options.selectedIndex].value;
    var resort = form.resort.options[form.resort.options.selectedIndex].value;
    var group = form.no_adults.options[form.no_adults.options.selectedIndex].value;
    var dep_airport = form.dep_airport.options[form.dep_airport.options.selectedIndex].value;
    var group = (form.no_adults.options[form.no_adults.options.selectedIndex].value * 1);
    var group2 = (form.no_children.options[form.no_children.options.selectedIndex].value * 1);
    var tots = (group + group2)
        var shit_check = check_pax_allocation(destination, (group + group2));
    // ** START **
    if (resort == 0) {
        alert("No Resort selected");
        form.resort.focus();
        return false;
    }

    // see http://www.thesitewizard.com/archive/validation.shtml
    // for an explanation of this script and how to use it on your
    // own website
    if (shit_check != true) {
        if (shit_check != undefined) {
			form.no_adults.focus();
        }

    }
    if (duration == 0) {
        alert("Please Select Duration.");
        form.duration.focus();
        return false;
    }
    if (val == 0) {
        alert("Select a Departure Day.");
        form.date_range_start.focus();
        return false;
    }
    if (dates == "") {
        alert("No Dates selected");
        form.date_range.focus();
        return false;
    }
    
    if (destination == 0) {
        alert("No Destination");
        form.destination.focus();
        return false;
    }
    
    if (dep_airport == 0) {
        alert("No Airport");
        form.dep_airport.focus();
        return false;
    }


if (tots%2 || (tots >=3 && tots <=7)){

			var theurllocation = location.href;
			if ((theurllocation.indexOf("luxury") != -1) || (theurllocation.indexOf("LUXURY") != -1)){
			}
			else if((theurllocation.indexOf("beach-holidays") != -1) || (theurllocation.indexOf("activity-holidays-search-beach") != -1)){
			} else {
	//var r=confirm("REMEMBER!\n\nVoucher get a code for a 10% - 20% discount. Group discounts start at group size 8\n\nHaving an Odd numbered group size will limit the chalets available.");
	
//if (r==true) {
//  }else {
//return false;
 // }
  		}



   //alert("Having an Odd numbered group size will limit the chalets available.\n\nBy selecting an Even numbered group size you will have a greater choice.");
  // DoSomething()
//	   return false;
  }

    
    return true;
    
    
}

function checkform1(form){

    var roomcost = document.create_basket_form.roomcosts.value;
    //single BED
    if (document.create_basket_form.single_drop) {
        var single_value = document.create_basket_form.single_drop.options[document.create_basket_form.single_drop.options.selectedIndex].value;
        var single_num = parseInt(single_value);
        var single_rooms = (single_num * 1);
        var single_cost = (roomcost * single_rooms);
        document.getElementById('total_single').innerHTML = "&pound;" + single_cost;
        //	need to write the innerhtml here so that we can get the price per room
        //	alert (single_rooms + "single Beds");
    }
    else {
        var single_value = "";
        var single_rooms = 0;
        var single_cost = 0;
    }
    
    //Double Bed	
    if (document.create_basket_form.double_drop) {
        var double_value = document.create_basket_form.double_drop.options[document.create_basket_form.double_drop.options.selectedIndex].value;
        var double_num = parseInt(double_value);
        var double_rooms = (double_num * 2);
        var double_cost = (roomcost * double_rooms);
        document.getElementById('total_double').innerHTML = "&pound;" + double_cost;
        //alert (double_rooms + "Double Beds");
    }
    else {
        var double_cost = 0;
        var double_value = "";
        var double_rooms = 0;
    }
    
    //Twin Bed
    if (document.create_basket_form.twin_drop) {
        var twin_value = document.create_basket_form.twin_drop.options[document.create_basket_form.twin_drop.options.selectedIndex].value;
        var twin_num = parseInt(twin_value);
        var twin_rooms = (twin_num * 2);
        var twin_cost = (roomcost * twin_rooms);
        document.getElementById('total_twin').innerHTML = "&pound;" + twin_cost;
        
        //alert (twin_rooms + "Twin beds");
    }
    else {
        var twin_value = "";
        var twin_rooms = 0;
        var twin_cost = 0;
    }
    
    //Triple Bed
    if (document.create_basket_form.triple_drop) {
        var triple_value = document.create_basket_form.triple_drop.options[document.create_basket_form.triple_drop.options.selectedIndex].value;
        var trip_num = parseInt(triple_value);
        var triple_rooms = (trip_num * 3);
        var triple_cost = (roomcost * triple_rooms);
        document.getElementById('total_triple').innerHTML = "&pound;" + triple_cost;
        //alert (triple_rooms + "Triple beds");
    }
    else {
        var triple_value = "";
        var triple_rooms = 0;
        var triple_cost = 0;
    }
    
    //Quad Bed
    if (document.create_basket_form.quad_drop) {
        var quad_value = document.create_basket_form.quad_drop.options[document.create_basket_form.quad_drop.options.selectedIndex].value;
        var quad_num = parseInt(quad_value)
        var quad_rooms = (quad_num * 4);
        var quad_cost = (roomcost * quad_rooms);
        document.getElementById('total_quad').innerHTML = "&pound;" + quad_cost;
        //alert (quad_rooms + "Quad Beds");
    }
    else {
        var quad_value = "";
        var quad_rooms = 0;
        var quad_cost = 0;
    }
    // see http://www.thesitewizard.com/archive/validation.shtml
    // for an explanation of this script and how to use it on your
    // own website
    // ** START **
    //we first get the value of the number of adults and make sure that this is the same as the number of beds allocated 
    //if (duration == 0) {
    //alert( "Please Select Duration." );
    // form.duration.focus();
    //  return false ;
    // }
    //now need to add all the numbers together
    var total_beds = (single_rooms + twin_rooms + double_rooms + triple_rooms + quad_rooms);
    var no_adults = getQuerystring('no_adults');
    var total_cost = (single_cost + twin_cost + double_cost + triple_cost + quad_cost);
    //document.getElementById('holiday_total').innerHTML = "&pound;"+total_cost;
    if (total_beds === 0) {
        alert("Please choose your rooms");
        return false;
    }
    // alert(no_adults + "Adults");
    //alert(total_beds + "Beds");
    if (no_adults > total_beds) {
        alert("You have not selected enough accomodation");
        return false;
    }
    if (no_adults < total_beds) {
        alert("You have selected to much accomodation");
        return false;
    }
    
    if (no_adults === total_beds) {
    
        return true;
    }
    return true;
}

function getQuerystring(key, default_){
    if (default_ == null) 
        default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null) 
        return default_;
    else 
        return qs[1];
}

function reload(form){
    //alert( "No Airport" );
    var url = window.location.href;
    var nohttp = url.split('//')[1];
    //alert("ELPWsdfsdf");
    //var hostPort = nohttp.split('/')[0];
    //alert(hostPort);
    var hostPort = nohttp.split('/')[1];
    var hostPort1 = hostPort.split('?')[0];
    //alert("hp1"+hostPort1);
    //var hostPort2 = hostPort1.split('?')[0];
    //alert("hp"+hostPort2);
    
    var duration = document.form.duration.value;
    var dates = form.date_range.options[form.date_range.options.selectedIndex].value;
    var group = form.no_adults.options[form.no_adults.options.selectedIndex].value;
    var val = form.date_range_start.options[form.date_range_start.options.selectedIndex].value;
    var destination = form.destination.options[form.destination.options.selectedIndex].value;
    var dep_airport = form.dep_airport.options[form.dep_airport.options.selectedIndex].value;
    var resort = form.resort.options[form.resort.options.selectedIndex].value;
    
    if (group > 7) {
        //alert('index.php?url=group_bookings&date_range_start=' + val + '&no_adults=' + group + '&date_range=' + dates + '&destination=' + destination;);
        alert("Bookings over 8 please contact us on 0844 770 4070");
        return false;
        //self.location= 'index.php?url=group_bookings&date_range_start=' + val + '&no_adults=' + group + '&date_range=' + dates + '&destination=' + destination + '&dep_airport=' + dep_airport;
    }
    else {
        //alert("Norma");
        //			self.location= hostPort1 + '?duration=' + duration +'&date_range_start=' + val + '&no_adults=' + group + '&date_range=' + dates + '&destination=' + destination + '&dep_airport=' + dep_airport;
        self.location = 'http://www.alpineelements.co.uk/ski-weekend-deals/booking.php?duration=2&date_range_start=' + val + '&no_adults=' + group + '&date_range=' + dates + '&resort=' + resort + '&destination=' + destination + '&dep_airport=' + dep_airport;
    }
}


function toggleSlideSubNav(objname){

var div_array = new Array();
div_array[0]="div_a";
div_array[1]="div_b";
div_array[2]="div_c";
div_array[3]="div_d";
div_array[4]="div_e";
div_array[5]="div_f";
div_array[6]="div_g";
div_array[7]="div_h";
div_array[8]="div_aa";

    if (document.getElementById(objname).style.display == "none") {

	  for (x in div_array) {
			  if (objname != div_array[x] )
			{
			  slideup(div_array[x]);
			}
			
		  }
		slidedown(objname);
 }
    else {
       slideup(objname);
}
}


