/**
 * @author Rafael Hernandez Guzman
 * Company: CancunShuttle, eletourim
 * Dynamic Ajax form for - www.cancun-airport.com, cancunshuttle.com, viptravelclubservices.com, rivieramaya-hotels.com 
 * This software is protected under United States and international copyright laws and are the property of eletourism. All rights reserved. Copying, distributing, transmitting, displaying, modifying, or otherwise using the software in any form or by any means without the express written permission of eletourism is prohibited and may violate the copyright laws of the United States and/or other countries.
 * English Version
 */
//Global variables
window.onload = initAll;
window.onunload = function(){};
var xhr = false;

var sharedServer = "http://ww11.aitsafe.com/cf/add.cfm";
var sharedId = "D229456";
var privateServer = "http://ww8.aitsafe.com/cf/add.cfm";
var privateId = "A5112580";

var hotelsArray = [];
var destino = " ";
var ChosenHotel = " ";
var roundDiscount = 0.6;
var oneWayDiscount = 0.4;
var oneWayTotal = 0;
var roundTotal = 0;
var roundPrice = 0;
var onePrice = 0;
var finalRound = 0;
var finalOne = 0;
var resType = " ";
var exceptionState = " ";
var sharedCoupon = 0;
var privateCoupon = 0;
//var paxNumber = 0;
var offerMsg = " ";
var exception = ["CLUB MED","CLUB MED CANCUN","CLUB MED CANCUN YUCATAN","CLUB MED RESORT","CLUB MED YUCATAN","CLUB MED YUCATAN CANCUN","CLUB MEDITERRANEO","MARRIOT COURTYARD","MOON PALACE CANCUN","MOON PALACE CANCUN NIZUC","MOON PALACE GOLF AND RESORT","MOON PALACE GOLF AND SPA","MOON PALACE GOLF AND SPA RESORT","MOON PALACE GOLF CLUB","MOON PALACE GOLF RESORT","MOON PALACE NIZUC","MOON PALACE RESORT","MOON PALACE SUNRISE"];
var privateIncludesList = "<h3>Includes:</h3> <ul><li>Private vehicle with A/C</li><li>Travel insurance</li><li>Meet & greet at the airport</li> <li>Flight monitoring</li><li>Professional bilingual driver</li><li>24 hrs transportation service</li><li>24 hrs customer service in Mexico</li><li>No fees for flight changes and delays</li><li>100% refundable 24 hrs prior to service</li><li>Spacious vehicle for passengers and luggage</li><li>All applicable taxes and Airport fees</li></ul>";
var sharedIncludesList = "<h3>Includes:</h3> <ul><li>Available from <span class='sharedAvailable'>8:00a.m. to 7:00 p.m. ONLY</span></li><li>Share vehicle with up to 10 passengers</li><li>Shuttles depart every 20 minutes</li><li>Multiple stops &#45; Up to 4 stops</li><li>Meet & Greet at the airport</li><li>Professional Drivers</li><li>24 hrs. customer service in Mexico</li><li>No fees for flight changes</li><li>100% refundable 24hrs. prior to service</li><li>Travel insurance</li><li>All applicable taxes & airport fees</li></ul>";
var destMsgPart1 = "<div id='lng-msg'><p>Your place of lodging is located in";
var destMsgPart2 = "from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up and you must make reservations in advance. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>";

var CShuttlePList = {
	"cancun":{
		"round":{
			"1-2 Pax":65,
			"3-7 Pax":75,
			"8-10 Pax":95
		},
		"oneway":{
			"1-2 Pax":45,
			"3-7 Pax":50,
			"8-10 Pax":55	
		},
		
		"airportRound":{
			"1-2 Pax":115,
			"3-7 Pax":125,
			"8-10 Pax":145
		},		
		"airportOneWay":{
			"1-2 Pax":70,
			"3-7 Pax":75,
			"8-10 Pax":80	
		},
		
		"shared":{
			"oneway":14,
			"round":23
		},

		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in <strong>Cancun</strong> about 40 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
		headerMsg:destMsgPart1 + " <strong>Cancun</strong> about 40 minutes " + destMsgPart2
	},	
	
	"isla mujeres":{
		"round":{
			"1-2 Pax":70,
			"3-7 Pax":75,
			"8-10 Pax":95
		},
		"oneway":{
			"1-2 Pax":45,
			"3-7 Pax":50,
			"8-10 Pax":55	
		},
		"airportRound":{
			"1-2 Pax":120,
			"3-7 Pax":125,
			"8-10 Pax":145
		},		
		"airportOneWay":{
			"1-2 Pax":70,
			"3-7 Pax":75,
			"8-10 Pax":80	
		},		
		"shared":{
			"oneway":18,
			"round":30
		},
	 	headerMsg:destMsgPart1 + " <strong>Isla Mujeres</strong>. We will transfer you to the ferry dock in Puerto Juarez. Which is located about 30 minutes " + destMsgPart2
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Isla Mujeres. We will transfer you to the ferry dock in Puerto Juarez. Which is located about 30 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"

	},	
	
	"puerto juarez":{
		"round":{
			"1-2 Pax":70,
			"3-7 Pax":75,
			"8-10 Pax":95
		},
		"oneway":{
			"1-2 Pax":45,
			"3-7 Pax":50,
			"8-10 Pax":55	
		},
		"airportRound":{
			"1-2 Pax":120,
			"3-7 Pax":125,
			"8-10 Pax":145
		},		
		"airportOneWay":{
			"1-2 Pax":70,
			"3-7 Pax":75,
			"8-10 Pax":80	
		},		
		"shared":{
			"oneway":18,
			"round":30
		},
		headerMsg:destMsgPart1 + " <strong>Puerto Juarez</strong> about 30 minutes " + destMsgPart2
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Puerto Juarez about 30 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},		
	
	"playa mujeres":{
		"round":{
			"1-2 Pax":90,
			"3-7 Pax":100,
			"8-10 Pax":110
		},
		"oneway":{
			"1-2 Pax":60,
			"3-7 Pax":65,
			"8-10 Pax":70	
		},
		"airportRound":{
			"1-2 Pax":140,
			"3-7 Pax":150,
			"8-10 Pax":160
		},		
		"airportOneWay":{
			"1-2 Pax":85,
			"3-7 Pax":90,
			"8-10 Pax":95	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},		
		headerMsg:destMsgPart1 + " <strong>Playa Mujeres</strong> about 30 minutes " + destMsgPart2
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Playa Mujeres about 30 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},		
	
	"puerto morelos":{
		"round":{
			"1-2 Pax":90,
			"3-7 Pax":100,
			"8-10 Pax":110
		},
		"oneway":{
			"1-2 Pax":60,
			"3-7 Pax":65,
			"8-10 Pax":70	
		},
		"airportRound":{
			"1-2 Pax":140,
			"3-7 Pax":150,
			"8-10 Pax":160
		},		
		"airportOneWay":{
			"1-2 Pax":85,
			"3-7 Pax":90,
			"8-10 Pax":95	
		},		
		"shared":{
			"oneway":23,
			"round":45
		},
		headerMsg:destMsgPart1 + " <strong>Puerto Morelos</strong> about 25 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Puerto Morelos about 25 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},
	
	"paraiso beach":{
		"round":{
			"1-2 Pax":95,
			"3-7 Pax":105,
			"8-10 Pax":115
		},
		"oneway":{
			"1-2 Pax":65,
			"3-7 Pax":70,
			"8-10 Pax":75	
		},
		"airportRound":{
			"1-2 Pax":145,
			"3-7 Pax":155,
			"8-10 Pax":165
		},		
		"airportOneWay":{
			"1-2 Pax":90,
			"3-7 Pax":95,
			"8-10 Pax":100	
		},		
		"shared":{
			"oneway":23,
			"round":45
		},		
		headerMsg:destMsgPart1 + " <strong>Paraiso Beach</strong> about 25 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Paraiso Beach about 25 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},			
	
	"playa del carmen":{
		"round":{
			"1-2 Pax":125,
			"3-7 Pax":135,
			"8-10 Pax":145
		},
		"oneway":{
			"1-2 Pax":80,
			"3-7 Pax":85,
			"8-10 Pax":90	
		},
		"airportRound":{
			"1-2 Pax":175,
			"3-7 Pax":185,
			"8-10 Pax":195
		},		
		"airportOneWay":{
			"1-2 Pax":105,
			"3-7 Pax":110,
			"8-10 Pax":115	
		},		
		"shared":{
			"oneway":23,
			"round":45
		},		
		headerMsg:destMsgPart1 + " <strong>Playa del Carmen</strong> about 1 hour " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Playa del Carmen about 1 hour from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},		
	
	"maroma beach":{
		"round":{
			"1-2 Pax":95,
			"3-7 Pax":105,
			"8-10 Pax":115
		},
		"oneway":{
			"1-2 Pax":65,
			"3-7 Pax":70,
			"8-10 Pax":75	
		},
		"airportRound":{
			"1-2 Pax":145,
			"3-7 Pax":155,
			"8-10 Pax":165
		},		
		"airportOneWay":{
			"1-2 Pax":90,
			"3-7 Pax":95,
			"8-10 Pax":100	
		},		
		"shared":{
			"oneway":23,
			"round":45
		},		
		headerMsg:destMsgPart1 + " <strong>Maroma Beach</strong> about 30 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Maroma Beach about 30 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},	
	
	"playacar":{
		"round":{
			"1-2 Pax":125,
			"3-7 Pax":135,
			"8-10 Pax":145
		},
		"oneway":{
			"1-2 Pax":80,
			"3-7 Pax":85,
			"8-10 Pax":90	
		},
		"airportRound":{
			"1-2 Pax":175,
			"3-7 Pax":185,
			"8-10 Pax":195
		},		
		"airportOneWay":{
			"1-2 Pax":105,
			"3-7 Pax":110,
			"8-10 Pax":115	
		},		
		"shared":{
			"oneway":23,
			"round":45
		},
		headerMsg:destMsgPart1 + " <strong>Playacar</strong> about 1 hour and 10 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Playacar about 1 hour and 10 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},	
	
	"cozumel":{
		"round":{
			"1-2 Pax":125,
			"3-7 Pax":135,
			"8-10 Pax":145
		},
		"oneway":{
			"1-2 Pax":80,
			"3-7 Pax":85,
			"8-10 Pax":90	
		},
		"airportRound":{
			"1-2 Pax":175,
			"3-7 Pax":185,
			"8-10 Pax":195
		},		
		"airportOneWay":{
			"1-2 Pax":105,
			"3-7 Pax":110,
			"8-10 Pax":115	
		},		
		"shared":{
			"oneway":23,
			"round":45
		},		
		headerMsg:destMsgPart1 + " <strong>Cozumel</strong>. We will transfer you to the ferry dock in Playa del Carmen which is located about 1 hour " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Cozumel. We will transfer you to the ferry dock in Playa del Carmen which is located about 1 hour from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},		
	
	"xcaret":{
		"round":{
			"1-2 Pax":135,
			"3-7 Pax":145,
			"8-10 Pax":165
		},
		"oneway":{
			"1-2 Pax":90,
			"3-7 Pax":95,
			"8-10 Pax":105	
		},
		"airportRound":{
			"1-2 Pax":185,
			"3-7 Pax":195,
			"8-10 Pax":215
		},		
		"airportOneWay":{
			"1-2 Pax":115,
			"3-7 Pax":120,
			"8-10 Pax":130	
		},		
		"shared":{
			"oneway":23,
			"round":45
		},		
		headerMsg:destMsgPart1 + " <strong>Xcaret</strong> about 1 hour and 20 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Xcaret about 1 hour and 20 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},		
	
	"puerto aventuras":{
		"round":{
			"1-2 Pax":150,
			"3-7 Pax":155,
			"8-10 Pax":165
		},
		"oneway":{
			"1-2 Pax":95,
			"3-7 Pax":100,
			"8-10 Pax":105	
		},
		"airportRound":{
			"1-2 Pax":200,
			"3-7 Pax":205,
			"8-10 Pax":215
		},		
		"airportOneWay":{
			"1-2 Pax":120,
			"3-7 Pax":125,
			"8-10 Pax":130	
		},		
		"shared":{
			"oneway":28,
			"round":55
		},		
		headerMsg:destMsgPart1 + " <strong>Puerto Aventuras</strong> about 1 hour and 20 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Puerto Aventuras about 1 hour and 20 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},
	
	"calica":{
		"round":{
			"1-2 Pax":135,
			"3-7 Pax":145,
			"8-10 Pax":165
		},
		"oneway":{
			"1-2 Pax":90,
			"3-7 Pax":95,
			"8-10 Pax":105	
		},
		"airportRound":{
			"1-2 Pax":185,
			"3-7 Pax":195,
			"8-10 Pax":215
		},		
		"airportOneWay":{
			"1-2 Pax":115,
			"3-7 Pax":120,
			"8-10 Pax":130	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},			
		headerMsg:destMsgPart1 + " the <strong>Port of Calica</strong> about 1 hour and 25 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in the Port of Calica about 1 hour and 25 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},	
	
	"paamul":{
		"round":{
			"1-2 Pax":150,
			"3-7 Pax":155,
			"8-10 Pax":165
		},
		"oneway":{
			"1-2 Pax":95,
			"3-7 Pax":100,
			"8-10 Pax":105	
		},
		"airportRound":{
			"1-2 Pax":200,
			"3-7 Pax":205,
			"8-10 Pax":215
		},		
		"airportOneWay":{
			"1-2 Pax":120,
			"3-7 Pax":125,
			"8-10 Pax":130	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},	
		headerMsg:destMsgPart1 + " <strong>Paamul</strong> about 1 hour and 20 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Paamul about 1 hour and 20 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},	
	
	"xpu ha":{
		"round":{
			"1-2 Pax":150,
			"3-7 Pax":155,
			"8-10 Pax":165
		},
		"oneway":{
			"1-2 Pax":95,
			"3-7 Pax":100,
			"8-10 Pax":105	
		},
		"airportRound":{
			"1-2 Pax":200,
			"3-7 Pax":205,
			"8-10 Pax":215
		},		
		"airportOneWay":{
			"1-2 Pax":120,
			"3-7 Pax":125,
			"8-10 Pax":130	
		},		
		"shared":{
			"oneway":35,
			"round":70
		},			
		headerMsg:destMsgPart1 + " <strong>Xpu Ha</strong> about 1 hour and 40 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Xpu Ha about 1 hour and 40 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},			
	
	"akumal":{
		"round":{
			"1-2 Pax":170,
			"3-7 Pax":180,
			"8-10 Pax":195
		},
		"oneway":{
			"1-2 Pax":105,
			"3-7 Pax":110,
			"8-10 Pax":115	
		},
		"airportRound":{
			"1-2 Pax":220,
			"3-7 Pax":230,
			"8-10 Pax":245
		},		
		"airportOneWay":{
			"1-2 Pax":130,
			"3-7 Pax":135,
			"8-10 Pax":140	
		},		
		"shared":{
			"oneway":35,
			"round":70
		},				
		
		headerMsg:destMsgPart1 + " <strong>Akumal</strong> about 1 hour and 30 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Akumal about 1 hour and 30 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},
	
	"tankah":{
		"round":{
			"1-2 Pax":190,
			"3-7 Pax":195,
			"8-10 Pax":215
		},
		"oneway":{
			"1-2 Pax":110,
			"3-7 Pax":115,
			"8-10 Pax":125	
		},
		"airportRound":{
			"1-2 Pax":240,
			"3-7 Pax":245,
			"8-10 Pax":265
		},		
		"airportOneWay":{
			"1-2 Pax":135,
			"3-7 Pax":140,
			"8-10 Pax":150	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},		
		headerMsg:destMsgPart1 + " <strong>Tankah</strong> about 1 hour and 50 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Tankah about 1 hour and 50 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},	
	
	"tulum":{
		"round":{
			"1-2 Pax":190,
			"3-7 Pax":195,
			"8-10 Pax":215
		},
		"oneway":{
			"1-2 Pax":110,
			"3-7 Pax":115,
			"8-10 Pax":125	
		},
		"airportRound":{
			"1-2 Pax":240,
			"3-7 Pax":245,
			"8-10 Pax":265
		},		
		"airportOneWay":{
			"1-2 Pax":135,
			"3-7 Pax":140,
			"8-10 Pax":150	
		},		
		"shared":{
			"oneway":35,
			"round":70
		},				
		headerMsg:destMsgPart1 + " <strong>Tulum</strong> about 1 hour and 45 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Tulum about 1 hour and 45 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},
	
	"tulum hotel zone":{
		"round":{
			"1-2 Pax":195,
			"3-7 Pax":200,
			"8-10 Pax":220
		},
		"oneway":{
			"1-2 Pax":115,
			"3-7 Pax":120,
			"8-10 Pax":130	
		},
		"airportRound":{
			"1-2 Pax":245,
			"3-7 Pax":250,
			"8-10 Pax":270
		},		
		"airportOneWay":{
			"1-2 Pax":140,
			"3-7 Pax":145,
			"8-10 Pax":155	
		},		
		"shared":{
			"oneway":35,
			"round":70
		},	
		headerMsg:destMsgPart1 + " <strong>Tulum Hotel Zone</strong> about 2 hours " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Tulum Hotel Zone about 2 hours from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"

	},	
	
	"holbox":{
		"round":{
			"1-2 Pax":430,
			"3-7 Pax":570,
			"8-10 Pax":680
		},
		"oneway":{
			"1-2 Pax":215,
			"3-7 Pax":285,
			"8-10 Pax":340	
		},
		"airportRound":{
			"1-2 Pax":638,
			"3-7 Pax":772,
			"8-10 Pax":772
		},		
		"airportOneWay":{
			"1-2 Pax":319,
			"3-7 Pax":386,
			"8-10 Pax":386	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},	
		headerMsg:destMsgPart1 + " <strong>Holbox</strong> about 2 hours " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Holbox about 2 hours from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},		
	
	"chiquila":{
		"round":{
			"1-2 Pax":430,
			"3-7 Pax":570,
			"8-10 Pax":680
		},
		"oneway":{
			"1-2 Pax":215,
			"3-7 Pax":285,
			"8-10 Pax":340	
		},
		"airportRound":{
			"1-2 Pax":638,
			"3-7 Pax":772,
			"8-10 Pax":772
		},		
		"airportOneWay":{
			"1-2 Pax":319,
			"3-7 Pax":386,
			"8-10 Pax":386	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},	
		headerMsg:destMsgPart1 + " <strong>Chiquila</strong> about 2 hours " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Chiquila about 2 hours from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},		
	
	"valladolid":{
		"round":{
			"1-2 Pax":430,
			"3-7 Pax":570,
			"8-10 Pax":680
		},
		"oneway":{
			"1-2 Pax":215,
			"3-7 Pax":285,
			"8-10 Pax":340	
		},
		"airportRound":{
			"1-2 Pax":650,
			"3-7 Pax":772,
			"8-10 Pax":772
		},		
		"airportOneWay":{
			"1-2 Pax":325,
			"3-7 Pax":386,
			"8-10 Pax":386	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},				
		headerMsg:destMsgPart1 + " <strong>Valladolid</strong> about 2 hours " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Valladolid about 2 hours from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},	
	
	"boca paila":{
		"round":{
			"1-2 Pax":430,
			"3-7 Pax":570,
			"8-10 Pax":680
		},
		"oneway":{
			"1-2 Pax":215,
			"3-7 Pax":285,
			"8-10 Pax":340	
		},
		"airportRound":{
			"1-2 Pax":878,
			"3-7 Pax":878,
			"8-10 Pax":1000
		},		
		"airportOneWay":{
			"1-2 Pax":439,
			"3-7 Pax":439,
			"8-10 Pax":500	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},		
		headerMsg:destMsgPart1 + " <strong>Boca Paila</strong> about 2 hours and 10 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Boca Paila about 2 hours and 10 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},				
	
	"chichen itza":{
		"round":{
			"1-2 Pax":540,
			"3-7 Pax":760,
			"8-10 Pax":860
		},
		"oneway":{
			"1-2 Pax":270,
			"3-7 Pax":380,
			"8-10 Pax":430	
		},
		"airportRound":{
			"1-2 Pax":700,
			"3-7 Pax":700,
			"8-10 Pax":900
		},		
		"airportOneWay":{
			"1-2 Pax":400,
			"3-7 Pax":400,
			"8-10 Pax":500	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},	
		headerMsg:destMsgPart1 + " <strong>Chichen Itza</strong> about 2 hours and 30 minutes " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Chichen Itza about 2 hours and 30 minutes from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only. </p></div>"
	},
	
	"merida":{
		"round":{
			"1-2 Pax":810,
			"3-7 Pax":1030,
			"8-10 Pax":1140
		},
		"oneway":{
			"1-2 Pax":405,
			"3-7 Pax":515,
			"8-10 Pax":570	
		},
		"airportRound":{
			"1-2 Pax":824,
			"3-7 Pax":1038,
			"8-10 Pax":1038
		},		
		"airportOneWay":{
			"1-2 Pax":412,
			"3-7 Pax":519,
			"8-10 Pax":519	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},			
		headerMsg:destMsgPart1 + " <strong>Merida</strong> about 4 hours " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Merida about 4 hours from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only.</p></div>"
	},			
	
	"chetumal":{
		"round":{
			"1-2 Pax":810,
			"3-7 Pax":1030,
			"8-10 Pax":1140
		},
		"oneway":{
			"1-2 Pax":405,
			"3-7 Pax":515,
			"8-10 Pax":570	
		},
		"airportRound":{
			"1-2 Pax":878,
			"3-7 Pax":1170,
			"8-10 Pax":1170
		},		
		"airportOneWay":{
			"1-2 Pax":439,
			"3-7 Pax":585,
			"8-10 Pax":585	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},				
		headerMsg:destMsgPart1 + " <strong>Chetumal</strong> about 5 hours " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Chetumal about 5 hours from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only.</p></div>"
	},			
	
	"costa maya":{
		"round":{
			"1-2 Pax":730,
			"3-7 Pax":920,
			"8-10 Pax":1030
		},
		"oneway":{
			"1-2 Pax":365,
			"3-7 Pax":460,
			"8-10 Pax":515	
		},
		"airportRound":{
			"1-2 Pax":1100,
			"3-7 Pax":1100,
			"8-10 Pax":1200
		},		
		"airportOneWay":{
			"1-2 Pax":600,
			"3-7 Pax":600,
			"8-10 Pax":700	
		},		
		"shared":{
			"oneway":0,
			"round":0
		},		
		headerMsg:destMsgPart1 + " <strong>Costa Maya</strong> about 5 hours " + destMsgPart2		
		//headerMsg:"<div id='lng-msg'><p>Your place of lodging is located in Costa Maya about 5 hours from the airport. You have two options, Shared Shuttle and Private Transportation. Please be aware that Taxis are not available at the airport, only authorized transportation companies can pick you up. Below you can read about the two options and select the best service for your transportation needs. Take advantage of the discounts available for online reservations only.</p></div>"
	}	
};

//Initialize event handlers and XMLHttpRequests
//Calls : setHotelsArray
function initAll() {
	//We want to monitor when the user enters information on the search field
	//so that we can grab this entered information and look at it.
	//We do this by setting up an event handler "onkeyup" which checks when the
	//user press a key and then lets it go. When this happens we call function
	//searchSuggest which makes suggestions on the hotel.
	
	//modificacion para variable PHP
	destino=document.getElementById("destino").value;	
	
	document.getElementById("searchField").onkeyup = searchSuggest;
	
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = setHotelsArray;
		xhr.open("GET", "scripts/hlist.xml", true);
		xhr.send(null);
	}
	else {
		alert("Sorry, but I couldn't create an XMLHttpRequest");
	}
	
	$("#shared-warning").hide();
	
	//event handlers
		$("#reserve-shared").bind("click",function(e){
			$('html, body').animate({scrollTop:200}, 'slow');
			//dynform.cname.focus();
			if($("#tripType").css("display")== "block"){
				resType = "shared shuttle";
				$("#shared-warning").show();
				var tripTypeIndex = document.getElementById("tripMenuID").selectedIndex;
				removeAllChildren("tripType");
				
				if(document.getElementById("CarInfoId")){
					deleteElementByID("CarInfoId");
				}
				
				if(offerMsg !== " "){
					//document.getElementById("tenPercent").innerHTML = offerMsg;	
				}

				var tMenu = populateTripMenu(roundTotal,oneWayTotal);
				document.getElementById("tripType").appendChild(tMenu);	
				$("#tripType").fadeIn("slow");
				$("#tenPercent").fadeIn("slow");
				document.getElementById("tripType").className = "tripshow";	
				document.getElementById("tenPercent").className = "tshow";
				//$("#tripType").fadeIn("slow");
				//$("#tenPercent").fadeIn("slow");
				document.getElementById("tripMenuID").selectedIndex = tripTypeIndex;
				document.getElementById("tripMenuID").onchange = genLastSection;	
				document.getElementById("carType").innerHTML = "<img src='images/daffyImgs/shared-img-bottom.jpg' />";	
				
				document.getElementById("dynform").action = sharedServer; 
				document.getElementById("userid").value = sharedId; 
				
				//document.getElementById("dynform").action = "http://ww11.aitsafe.com/cf/add.cfm";
				//document.getElementById("userid").value = "D229456";
				
				if(document.getElementById("resTypeHeader")){
					if(tripTypeIndex == 1){
						var hmsg = "You are making a " + resType + " round trip reservation"; 
					}else if(tripTypeIndex == 2){
						var hmsg = "You are making a " + resType + " one way reservation";
					}
					document.getElementById("resTypeHeader").innerHTML = hmsg;
				}
			}else{
				resType = "shared shuttle";
				$("#shared-warning").show();
				
				if(document.getElementById("CarInfoId")){
					deleteElementByID("CarInfoId");
				}
				
				var tMenu = populateTripMenu(roundTotal,oneWayTotal);
				document.getElementById("tripType").appendChild(tMenu);					
				$("#tripType").fadeIn("slow");
				$("#tenPercent").fadeIn("slow");
				document.getElementById("tripType").className = "tripshow";	
				document.getElementById("tenPercent").className = "tshow";
				//$("#tripType").fadeIn("slow");
				//$("#tenPercent").fadeIn("slow");
				document.getElementById("tripMenuID").selectedIndex = 0;
				document.getElementById("tripMenuID").onchange = genLastSection;	
				document.getElementById("carType").innerHTML = "<img src='images/daffyImgs/shared-img-bottom.jpg' />";	
				
				//document.getElementById("dynform").action = "http://ww11.aitsafe.com/cf/add.cfm";
				//document.getElementById("userid").value = "D229456";
				
				document.getElementById("dynform").action = sharedServer;
				document.getElementById("userid").value = sharedId;
			}		
		});
		
		$("#reserve-private").bind("click",function(e){
			$('html, body').animate({scrollTop:200}, 'slow');
			if($("#tripType").css("display")=== "block"){
				resType = "private";
				$("#shared-warning").hide();
				var tripTypeIndex = document.getElementById("tripMenuID").selectedIndex;
				removeAllChildren("tripType");
				
				//var tMenu = populateTripMenu(roundPrice,onePrice);
				var tMenu = populateTripMenu(finalRound,finalOne);
				document.getElementById("tripType").appendChild(tMenu);		
				document.getElementById("tripType").className = "tripshowpriv";	
				document.getElementById("tenPercent").className = "tshowpriv";
				$("#tripType").fadeIn("slow");
				$("#tenPercent").fadeIn("slow");
				document.getElementById("tripMenuID").selectedIndex = tripTypeIndex;
				document.getElementById("tripMenuID").onchange = genLastSection;
				document.getElementById("carType").innerHTML = "<img src='images/daffyImgs/private-img-bottom.jpg' />";	
				
				document.getElementById("dynform").action = privateServer;
				document.getElementById("userid").value = privateId;
				
				if(document.getElementById("resTypeHeader")){
					if(tripTypeIndex === 1){
						var hmsg = "You are making a " + resType + " round trip reservation"; 
					}else if(tripTypeIndex == 2){
						var hmsg = "You are making a " + resType + " one way reservation";
					}
					document.getElementById("resTypeHeader").innerHTML = hmsg;
				}
			}else{
				resType = "private";
				$("#shared-warning").hide();
				//var tMenu = populateTripMenu(roundPrice,onePrice);
				var tMenu = populateTripMenu(finalRound,finalOne);
				document.getElementById("tripType").appendChild(tMenu);		
				document.getElementById("tripType").className = "tripshowpriv";	
				document.getElementById("tenPercent").className = "tshowpriv";
				$("#tripType").fadeIn("slow");
				$("#tenPercent").fadeIn("slow");
				document.getElementById("tripMenuID").selectedIndex = 0;
				document.getElementById("tripMenuID").onchange = genLastSection;
				document.getElementById("carType").innerHTML = "<img src='images/daffyImgs/private-img-bottom.jpg' />";	
				
				document.getElementById("dynform").action = privateServer;
				document.getElementById("userid").value = privateId;
			}		
		});			
		
		function kH(e) {
			var pK = e ? e.which : window.event.keyCode;
			return pK != 13;
		}
		document.onkeypress = kH;
		if (document.layers) {
			document.captureEvents(Event.KEYPRESS);
		}
		
	if (ChosenHotel != "") 
		if (destino != "") {
			fillDestInfo();
			document.getElementById("foldingContent").className = "hide";
		}	 
						
}

//It´s going to be called whenever the ready state field in our xhr object changes. Sets the initial Hotel Array
function setHotelsArray() {
	if (xhr.readyState === 4) {
		if (xhr.status === 200) {
			if (xhr.responseXML) { //checking if everything is fine with what we expect to get
				//Get all the hotels from the xml file and place them in allHotels
				var allHotels = xhr.responseXML.getElementsByTagName("item");
				//Going through the allHotels array and getting the name of the hotels and putting
				//them in the hotelsArray array. We only get the text. That's why we use firstChild
				for (var i=0; i<allHotels.length; i++) {
					hotelsArray[i] = allHotels[i].getElementsByTagName("label")[0].firstChild;
				}
			}
		}
		else {
			alert("There was a problem with the request " + xhr.status);
		}
	}
}


function BuscameloJEJE()
{
	if(document.getElementById("searchField").value=="")
	{
	ChosenHotel=document.getElementById("searchField").value;
	destino=getValue(ChosenHotel);
	document.getElementById("paxMenuID").onchange=checkConditions;
	}	
}

//Dynamic function that reads the search field value and uses that to generate a dynamic field that
//the user can choose.
//Calls: makeChoice
function searchSuggest() {
	//this is the function that gets called whenever a user inputs something into the search field
	//so the first thing we do is get whatever value is entered into the field. We put that in str
	var str = document.getElementById("searchField").value;
	//Next we want to clear any errors there might have been. We do that by setting the class name
	// equals to nothing. If there is an error the class would be error.
	document.getElementById("searchField").className = "";
	
	if (str !== "") { //This means that they typed something
		//we set the content of the popups div to nothing to start from scratch
		document.getElementById("popups").innerHTML = "";
		
		for (var i = 0; i < hotelsArray.length; i++) {
			var thisHotel = hotelsArray[i].nodeValue;
			
			//Set whatever was entered to lowercase for easier comparison and checks if what was 
			//entered on the search field can be found on thisHotel
			if (thisHotel.toLowerCase().indexOf(str.toLowerCase()) === 0) {
				var tempDiv = document.createElement("div");
				tempDiv.innerHTML = thisHotel;
				//Event handler in case the user clicks the choice given. onclick calls makeChoice function
				tempDiv.onclick = makeChoice;
				tempDiv.className = "suggestions";
				document.getElementById("popups").appendChild(tempDiv);
			}
		}
		
		//At this point we have looped through every hotel and for every hotel that matches we
		//have added a new div to the popups
		
		//foundCT = foundCount which is will contain the amount of items in popups. How many matching
		//states we found.
		var foundCt = document.getElementById("popups").childNodes.length;
		//If we didn't found any there was an error. This changes the color of the search field
		if (foundCt === 0) {
			document.getElementById("searchField").className = "error";
		}
		//Autocomplete code
		/*
		if (foundCt == 1) {
			document.getElementById("searchField").value = document.getElementById("popups").firstChild.innerHTML;
			ChosenHotel = document.getElementById("popups").firstChild.innerHTML;
			destino = getValue(ChosenHotel);
			document.getElementById("popups").innerHTML = "";	
		}
		*/
	}					
	//Hide folding content
	document.getElementById("foldingContent").className = "hide";
	
	//if hotel is chosen first and then pax number, do this
	document.getElementById("paxMenuID").onchange = checkConditions;	

	if(ChosenHotel === "other"){	
		if(document.getElementById("otherHotel").className !== "othershow"){
			if($("#destInfo").css("display") === "block" ){
				$("#destInfo").css({display:"none"});
			}
			if($("#tripType").css("display") === "block"){
				removeAllChildren("tripType");
				$("#tripType").css({ display: "none" });
				$("#tenPercent").css({ display:"none" });
			}
			if($("#flightInfo").css("display") === "block"){
				removeAllChildren("flightInfo");
				$("#flightInfo").css({ display: "none" });
				document.getElementById("carType").className = "";
				document.getElementById("formSubmit").className = "";
			}
		
			//Display otherHotel section
			document.getElementById("otherHotel").className = "othershow";
			
			genLabel("otherHotelInput","Hotel Name/Lodging: ");
			
			var hotelNode = document.createElement("input");
			hotelNode.name ="product[]";
			hotelNode.type = "text";
			hotelNode.size = "31";
			document.getElementById("otherHotelInput").appendChild(hotelNode);
			
			genBreakLine("otherHotelInput");
			genLabel("otherHotelInput","Destination:");
			
			var dMenu = populateDestinationMenu();
			document.getElementById("otherHotelInput").appendChild(dMenu);
			
			genBreakLine("otherHotelInput");
			//Place event handler on menu
			
			document.getElementById("destMenu").selectedIndex = 0;
			document.getElementById("destMenu").onchange = storeDest;	
		}
	}		
	//If both hotel and pax fields have valid values		
	else if (document.getElementById("paxMenuID").selectedIndex !== 0 && ChosenHotel !== " ") {
		
		if($("#destInfo").css("display") === "block"){
			removeAllChildren("sharedPrices");
			removeAllChildren("sharedIncludes");
	
			removeAllChildren("privatePrices");
			removeAllChildren("privateIncludes");
		}
		
		fillDestInfo();
	}
		
	
}

//Function that handles the situation where the user clicks one of the popup options of the hotel search field
//Calls: storeDest if the hotel is not on the list. choosePax if it's on the list
function makeChoice(evt) {
	//If event exists set thisDiv to the target of the event otherwise set it to window.event.srcElement
	//in either case it will be the name of the hotel
	var thisDiv = (evt) ? evt.target : window.event.srcElement;
	document.getElementById("searchField").value = thisDiv.innerHTML;
	ChosenHotel = thisDiv.innerHTML; //debugging for ie, added to save the chosen hotel
	document.getElementById("popups").innerHTML = "";
	
	destino = getValue(ChosenHotel);
	
	//Hide folding content
	document.getElementById("foldingContent").className = "hide";
	
	//if hotel is chosen first and then pax number, do this

	document.getElementById("paxMenuID").onchange = checkConditions;	



	if(ChosenHotel === "other"){	
		if(document.getElementById("otherHotel").className !== "othershow"){
			if($("#destInfo").css("display") === "block" ){
				$("#destInfo").css({display:"none"});
			}
			if($("#tripType").css("display") === "block"){
				removeAllChildren("tripType");
				$("#tripType").css({ display: "none" });
				$("#tenPercent").css({ display:"none" });
			}
			if($("#flightInfo").css("display") === "block"){
				removeAllChildren("flightInfo");
				$("#flightInfo").css({ display: "none" });
				document.getElementById("carType").className = "";
				document.getElementById("formSubmit").className = "";
			}
		
			//Display otherHotel section
			document.getElementById("otherHotel").className = "othershow";
			
			genLabel("otherHotelInput","Hotel Name/Lodging: ");
			
			var hotelNode = document.createElement("input");
			hotelNode.name ="product[]";
			hotelNode.type = "text";
			hotelNode.size = "31";
			document.getElementById("otherHotelInput").appendChild(hotelNode);
			
			genBreakLine("otherHotelInput");
			genLabel("otherHotelInput","Destination:");
			
			var dMenu = populateDestinationMenu();
			document.getElementById("otherHotelInput").appendChild(dMenu);
			
			genBreakLine("otherHotelInput");
			//Place event handler on menu
			
			document.getElementById("destMenu").selectedIndex = 0;
			document.getElementById("destMenu").onchange = storeDest;	
		}
	}		
	//If both hotel and pax fields have valid values		
	else if (document.getElementById("paxMenuID").selectedIndex !== 0 && ChosenHotel !== " ") {
		
		if($("#destInfo").css("display") === "block"){
			removeAllChildren("sharedPrices");
			removeAllChildren("sharedIncludes");
	
			removeAllChildren("privatePrices");
			removeAllChildren("privateIncludes");
		}
		
		fillDestInfo();
	}
}

//Handles one of the conditions when hotel name and passenger number are chosen in the normal way
function checkConditions(){
	if (document.getElementById("otherHotel").className === "othershow" && document.getElementById("destMenu").selectedIndex === 0) {
		$("#otherValidation").css({
			display: "block"
		});
		document.getElementById("otherValidation").innerHTML = "You must enter a destination to continue";
	}
	else{	
		if($("#more-than-ten").css("display") === "block" ){
			$("#more-than-ten").css({display: "none"}); 
			if($("#destInfo").css("display") === "block"){
				$("#destInfo").css({display: "none"}); 	
			}
			
			cleanBelowFlightInfo();

		
		}		
		 
		if (($("#destInfo").css("display") === "block") && (document.getElementById("paxMenuID").selectedIndex === 0)) {
			alert("You need to choose a number of passengers");
			document.getElementById("paxMenuID").selectedIndex = 1;
		} 
		if ($("#destInfo").css("display") === "block") {
			removeAllChildren("sharedPrices");
			removeAllChildren("sharedIncludes");
			
			removeAllChildren("privatePrices");
			removeAllChildren("privateIncludes");	
		}
		if (ChosenHotel != " ") {
			fillDestInfo();
		}
	}
}

function fillDestInfo(){
		//make the information box visible
		//document.getElementById("destInfo").className = "destInfoShow";
		if(document.getElementById("paxMenuID").selectedIndex === 11){
			$("#more-than-ten").css({display:"block"});
			if($("#destInfo").css("display") === "block"){
				$("#destInfo").css({display: "none"}); 	
			}	
			
			cleanBelowFlightInfo();			
		}
		else{
			//$().append();
			$("#destInfo").fadeIn("slow");
			$("#logos-wrap").fadeIn("slow");
			//shared section, not visible if shared service not available
			//if (CShuttlePList[destino].shared.oneway !== 0) {
			exceptionState = checkExceptions();
			if (CShuttlePList[destino].shared.oneway !== 0 && exceptionState ) {
				addSharedPriceInfo();
				document.getElementById("sharedIncludes").className = "showBak"; 
				document.getElementById("sResButton").className = "";			
			}
			else{
				removeAllChildren("sharedPrices");
				removeAllChildren("sharedIncludes");
				document.getElementById("sResButton").className = "noShow";
				document.getElementById("sharedIncludes").className = "";
				document.getElementById("sharedPrices").innerHTML = "<h3>Shared Shuttle Service is not available at this hotel</h3>";
			}
			//private section
			addPrivatePriceInfo();
			addIncludesInfo();		
			
			if($("#more-than-ten").css("display") === "block" ){
				$("#more-than-ten").css({display:"none"});
				if($("#destInfo").css("display") === "block"){
					$("#destInfo").css({display: "none"}); 	
				}		
				cleanBelowFlightInfo();		
			}						
		}
}

function addIncludesInfo(){
		document.getElementById("dest-msg").innerHTML = CShuttlePList[destino].headerMsg;
		document.getElementById("privateIncludes").innerHTML = privateIncludesList;
		if (CShuttlePList[destino].shared.oneway !== 0 && exceptionState) {
			document.getElementById("sharedIncludes").innerHTML = sharedIncludesList;
		}
}

function addPrivatePriceInfo(){
	var paxmenu = document.getElementById("paxMenuID");	
	var paxno = paxmenu.options[paxmenu.selectedIndex].innerHTML;
	var vehicleType = processPaxNum(paxno);
	roundPrice = CShuttlePList[destino].round[vehicleType];
	onePrice = CShuttlePList[destino].oneway[vehicleType];	
	//var oneAirPrice = (onePrice * oneWayDiscount)+ onePrice;
	//var roundAirPrice = (roundPrice * roundDiscount) + roundPrice;
	var oneAirPrice = CShuttlePList[destino].airportOneWay[vehicleType];
	var roundAirPrice = CShuttlePList[destino].airportRound[vehicleType];
	var oneSave = oneAirPrice - onePrice;
	var roundSave = roundAirPrice - roundPrice;
	var carImg =" ";
	
	switch(vehicleType){
		case "1-2 Pax":
		carImg ='<img src="images/daffyImgs/vehicle1to2.jpg"/>';
		break;
		case "3-7 Pax":
		carImg ='<img src="images/daffyImgs/vehicle3to7.jpg"/>';
		break;
		case "8-10 Pax":
		carImg ='<img src="images/daffyImgs/vehicle8to10.jpg"/>';
		break;
		default:alert("error on addPrivatePriceInfo");
	}
	
	/*
	if (onePrice >= 100) {
		var beSafeOne = onePrice * 0.1;
		finalOne = onePrice - beSafeOne;
	}else{
		var beSafeOne = 0;
		finalOne = onePrice;
	}
	
	if(roundPrice >= 100){
		var beSafeRound = roundPrice * 0.1;
		finalRound = roundPrice - beSafeRound;
	}else{
		var beSafeRound = 0;
		finalRound = roundPrice;
	}
	*/
	
	var beSafeOne = 0;
	var beSafeRound = 0;
	finalOne = onePrice;
	finalRound = roundPrice;
	
	
	
	//var priceContent = "<h3>Private Transportation<br/>(Price Per Vehicle in US Dollars)</h3><table width='100%'border='0'><tr><td width='30%'></td><th width='15%'>One Way</th><th width='15%'>Round Trip</th><td width='40%'></td></tr><tr><td class='tText'><span class='pricePer'>Price at the airport:</span></td><td class='demPrice'>" + "$" + oneAirPrice.toFixed(2) + "</td><td class='demPrice'>" + "$" + roundAirPrice.toFixed(2) + "</td><td></td></tr><tr><td class='tText'>Online Discount:</td><td>" + "-$" + oneSave.toFixed(2) + "</td><td>" + "-$" + roundSave.toFixed(2) + "</td><td></td></tr><tr><td class='tText'>Airport \"Be Safe Credit\"</td><td>" + "-$" + beSafeOne.toFixed(2) + "</td><td>" + "-$" + beSafeRound.toFixed(2) + "</td><td></td></tr><tr><td class='tText rPrice'>Total Online Price:</td><td class='rPrice'>" + "$" + finalOne.toFixed(2) + "</td><td class='rPrice'>" + "$" + finalRound.toFixed(2) + "</td><td class='promo-msg'>(Your Best Option)</td></tr><tr><td class='tText'>Tour Rebate Coupon</td><td style='border-bottom:1px solid;'>-$" + (privateCoupon / 2) +".00</td><td style='border-bottom:1px solid;'>-$" + privateCoupon + ".00</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td class='emPrice'>" + displayDiscount(finalOne - (privateCoupon / 2)) + "</td><td class='emPrice'>" + displayDiscount( finalRound - privateCoupon) + "</td><td style='text-align:left;'>(after Tour Rebate Coupon)</td></tr></table>";
	//var priceContent = "<h3>Private Transportation<br/>(Price Per Vehicle in US Dollars)</h3><table width='100%'border='0'><tr><td width='30%'></td><th width='15%'>One Way</th><th width='15%'>Round Trip</th><td width='40%'></td></tr><tr><td class='tText'><span class='pricePer'>Price at the airport:</span></td><td class='demPrice'>" + "$" + oneAirPrice.toFixed(2) + "</td><td class='demPrice'>" + "$" + roundAirPrice.toFixed(2) + "</td><td></td></tr><tr><td class='tText'>Online Discount:</td><td>" + "-$" + oneSave.toFixed(2) + "</td><td>" + "-$" + roundSave.toFixed(2) + "</td><td></td></tr></tr><tr><td class='tText rPrice'>Total Online Price:</td><td class='rPrice'>" + "$" + finalOne.toFixed(2) + "</td><td class='rPrice'>" + "$" + finalRound.toFixed(2) + "</td><td class='promo-msg'>(Your Best Option)</td></tr><tr><td class='tText'>Tour Rebate Coupon</td><td style='border-bottom:1px solid;'>-$" + (privateCoupon / 2) +".00</td><td style='border-bottom:1px solid;'>-$" + privateCoupon + ".00</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td class='emPrice'>" + displayDiscount(finalOne - (privateCoupon / 2)) + "</td><td class='emPrice'>" + displayDiscount( finalRound - privateCoupon) + "</td><td style='text-align:left;'>(after Tour Rebate Coupon)</td></tr></table>";	
	//	var priceContent = "<h3>Private Transportation<br/>(Price Per Vehicle in US Dollars)</h3><table width='100%'border='0'><tr><td width='30%'></td><th width='15%'>One Way</th><th width='15%'>Round Trip</th><td width='40%'></td></tr><tr><td class='tText'><span class='pricePer'>Price at the airport:</span></td><td class='demPrice'>" + "$" + oneAirPrice.toFixed(2) + "</td><td class='demPrice'>" + "$" + roundAirPrice.toFixed(2) + "</td><td></td></tr><tr><td class='tText'>Online Discount:</td><td>" + "-$" + oneSave.toFixed(2) + "</td><td>" + "-$" + roundSave.toFixed(2) + "</td><td></td></tr></tr><tr><td class='tText rPrice'>Total Online Price:</td><td class='rPrice emPrice'>" + "$" + finalOne.toFixed(2) + "</td><td class='rPrice emPrice'>" + "$" + finalRound.toFixed(2) + "</td><td class='promo-msg'>(Your Best Option)</td></tr></table>";	
		var priceContent = "<div id='small-cars'>"+carImg+"</div><h3>Private Transportation<br/>(Price Per Vehicle in US Dollars)</h3><table width='100%'border='0'><tr><td width='30%'></td><th width='15%'>One Way</th><th width='15%'>Round Trip</th><td width='40%'></td></tr><tr><td class='tText'><span class='pricePer'>Price at the airport:</span></td><td class='demPrice'>" + "$" + oneAirPrice.toFixed(2) + "</td><td class='demPrice'>" + "$" + roundAirPrice.toFixed(2) + "</td><td></td></tr><tr><td class='tText'>Online Discount:</td><td class='online-discount'>" + "-$" + oneSave.toFixed(2) + "</td><td class='online-discount'>" + "-$" + roundSave.toFixed(2) + "</td><td></td></tr></tr><tr><td class='tText rPrice'>Total Online Price:</td><td class='rPrice emPrice'>" + "$" + finalOne.toFixed(2) + "</td><td class='rPrice emPrice'>" + "$" + finalRound.toFixed(2) + "</td><td class='promo-msg'>(Your Best Option)</td></tr></table>";	

	document.getElementById("privatePrices").innerHTML = priceContent;
	
	if(oneWayTotal > onePrice){
		document.getElementById("priv-recommend").className = "show";
		$("td.promo-msg").css("display","block");	
		$("#departs").css("display","none");
	}else{
		document.getElementById("priv-recommend").className = "";
		$("#departs").css("display","block");
	}
	
	if((onePrice >= 100) && (roundPrice >= 100)){
		$("#pResMsg").addClass("show");
		$("#priv-recommend").addClass("showPromo");
		//$("td.promo-msg").css("display","block");

		if ($("#priv-recommend").hasClass("show")) {
			$("#priv-recommend").removeClass("show");
			$("#priv-recommend").addClass("showPromo");
		}
	}else if($("#pResMsg").hasClass("show")){
		$("#pResMsg").removeClass("show");
		if ($("#priv-recommend").hasClass("showPromo"))
			$("#priv-recommend").removeClass("showPromo");		 
	}
	
	if((onePrice < 100) && (roundPrice >= 100)){
		$("#rResMsg").addClass("show");
		$("#priv-recommend").addClass("showPromo");
		//$("td.promo-msg").css("display","block");

		if ($("#priv-recommend").hasClass("show")) {
			$("#priv-recommend").removeClass("show");
			$("#priv-recommend").addClass("showPromo");
		}
	}else if($("#rResMsg").hasClass("show")){
		$("#rResMsg").removeClass("show");
		if ($("#priv-recommend").hasClass("showPromo"))
			$("#priv-recommend").removeClass("showPromo");		 
	}	
	

	if(resType == "private"){
		//rePopulateTripMenu(roundPrice,onePrice);
		rePopulateTripMenu(finalRound,finalOne);
	}

}

function addSharedPriceInfo(){
	var paxmenu = document.getElementById("paxMenuID");	
	var paxStr = paxmenu.options[paxmenu.selectedIndex].innerHTML;
	var paxno = processString(paxStr);
	findDiscount(paxno);


	//Change added on May 26 2k9. If the user chooses 2pax and cancun as destino they get a discount per pax.
	//Original code block
	//	var oneWayShared = CShuttlePList[destino].shared.oneway;
	//	var roundShared = CShuttlePList[destino].shared.round;
	//	oneWayTotal = CShuttlePList[destino].shared.oneway * paxno;
	//	roundTotal = CShuttlePList[destino].shared.round * paxno;
	if(paxno == 2 && destino == "cancun" ){
		var oneWayShared = 14;
		var roundShared = 17;
		oneWayTotal = 14 * paxno;
		roundTotal = 17 * paxno;
	}else{
		var oneWayShared = CShuttlePList[destino].shared.oneway;
		var roundShared = CShuttlePList[destino].shared.round;
		oneWayTotal = CShuttlePList[destino].shared.oneway * paxno;
		roundTotal = CShuttlePList[destino].shared.round * paxno;
	}

	attachOffer(paxno);
		
/*Code changed on may 27 2009, to add a departs every 20 minutes notice
	if(oneWayTotal > onePrice){
		//document.getElementById("priv-recommend").className = "show";
		$("#see-priv").css("display","block");
	}else{
		$("#see-priv").css("display","none");
		//document.getElementById("priv-recommend").className = "";
	}
*/	
	
	
	
	//var priceContent = "<h3>Shared Shuttle</h3><table width='100%' border='0'><tr><th width='30%'></th><th width='15%'>One Way</th><th width='15%'>Round Trip</th><th width='40%'></th></tr><tr><td class='tText'><span class='pricePer'>Price Per Person:</span></td><td>" + "$" + oneWayShared + ".00" + "</td><td>" + "$" + roundShared + ".00" + "</td><td>&nbsp;</td></tr><tr><td class='rPrice tText'>Total Online Price:</td><td class='rPrice'>" + "$" + oneWayTotal + ".00" + "</td><td class='rPrice'>" + "$" + roundTotal + ".00" + "</td><td>&nbsp;</td></tr><tr><td class='tText'>Tour Rebate Coupon</td><td style='border-bottom:1px solid;'>-$" + (sharedCoupon / 2) + ".00</td><td style='border-bottom:1px solid;'>-$" + sharedCoupon + ".00</td><td>&nbsp;</td></tr><tr><td class='tText'>&nbsp;</td><td class='emPrice'>" + displayDiscount(oneWayTotal - (sharedCoupon / 2))+ "</td><td class='emPrice'>" + displayDiscount(roundTotal - sharedCoupon) + "</td><td style='text-align:left;'>(after Tour Rebate Coupon)</td></tr></table>";
	var priceContent = "<div id='departs'><img src='images/daffyImgs/departs-every-20.png' /></div><h3>Shared Shuttle</h3><table width='100%' border='0'><tr><th width='30%'></th><th width='15%'>One Way</th><th width='15%'>Round Trip</th><th width='40%'></th></tr><tr><td class='tText'><span class='pricePer'>Price Per Person:</span></td><td>" + "$" + oneWayShared + ".00" + "</td><td>" + "$" + roundShared + ".00" + "</td><td>&nbsp;</td></tr><tr><td class='rPrice tText'>Total Online Price:</td><td class='rPrice emPrice'>" + "$" + oneWayTotal + ".00" + "</td><td class='rPrice emPrice'>" + "$" + roundTotal + ".00" + "</td><td class='promo-msg'>See Private Option<img src='images/daffyImgs/sm-red-arrow.png' /></td></tr><tr></table>";
	document.getElementById("sharedPrices").innerHTML = priceContent;
	
	
	//may 29 2009
	//Removed the see private option noticed and placed a departs-20 notice with css
	/*
	if(oneWayTotal < onePrice){
		$("#see-priv").css("display","none");
		$("#departs").css("display","block");
	}else{
		$("#see-priv").css("display","block");
		$("#departs").css("display","none");
	}
	*/
	
	if(resType == "shared shuttle"){
		rePopulateTripMenu(roundTotal,oneWayTotal);
	}
}

function rePopulateTripMenu(rPrice,oPrice){
	if(document.getElementById("tripMenuID")){
		var savedIndex = document.getElementById("tripMenuID").selectedIndex;
		removeAllChildren("tripType");
		var tripmenu = populateTripMenu(rPrice,oPrice);
		tripmenu.selectedIndex = savedIndex;
		document.getElementById("tripType").appendChild(tripmenu);
		document.getElementById("tripMenuID").onchange = genLastSection;
	}
}

function storeDest(){
	if(	$("#otherValidation").css("display")== "block"){
		$("#otherValidation").css({
			display: "none"
		});
		document.getElementById("otherValidation").innerHTML = "";	
	}
	
	var dMenu = document.getElementById("destMenu");
	destino = dMenu.options[dMenu.selectedIndex].value;
	
	if(document.getElementById("paxMenuID").selectedIndex !== 0){
		fillDestInfo();
	}
}

//Creates a menu for the custormer to choose the type of trip: Round or One way
/*Backup
function populateTripMenu(roundPrice,owayPrice){
	var tripMenu = document.createElement("select");
	tripMenu.name = "productpr";
	tripMenu.id = "tripMenuID";
	
	var optionToAdd = document.createElement("option");
	optionToAdd.selected = "selected";
	optionToAdd.innerHTML = "Please Select One";
	tripMenu.appendChild(optionToAdd);	
	
	if(resType === "private"){
		createTripOption(tripMenu,"Round Trip",roundPrice,"(Save 60%)");
		createTripOption(tripMenu,"One Way",owayPrice,"(Save 40%)");		
	}else if(resType === "shared shuttle"){
		createTripOption(tripMenu,"Round Trip",roundPrice,"");
		createTripOption(tripMenu,"One Way",owayPrice,"");		
	}

	return tripMenu;
}
*/
function populateTripMenu(rPrice,owayPrice){
	var tripMenu = document.createElement("select");
	tripMenu.name = "productpr";
	tripMenu.id = "tripMenuID";
	
	var optionToAdd = document.createElement("option");
	optionToAdd.selected = "selected";
	optionToAdd.innerHTML = "Please Select One";
	tripMenu.appendChild(optionToAdd);	
	
	if(resType === "private"){
		createTripOption(tripMenu,"Round Trip",rPrice,"",roundPrice);
		createTripOption(tripMenu,"One Way",owayPrice,"",onePrice);		
	}else if(resType === "shared shuttle"){
		createTripOption(tripMenu,"Round Trip",rPrice,"",rPrice);
		createTripOption(tripMenu,"One Way",owayPrice,"",owayPrice);		
	}

	return tripMenu;
}

//Creates options for the trip menu
function createTripOption(menu,kind,price,savings,priceSent){
	var optionToAdd = document.createElement("option");
	optionToAdd.value = ":" + priceSent;
	optionToAdd.innerHTML = kind + ": $" + price.toFixed(2) + savings;
	menu.appendChild(optionToAdd);
}

//Function that generates the last section of the form which contains the flight info depending if the user chose
//round trip or one way
function genLastSection(){
	if ($("#flightInfo").css("display") === "block") {
		removeAllChildren("flightInfo");
		
		if (document.getElementById("tripMenuID").selectedIndex === 1) {
			generateRound();
			document.getElementById("formSubmit").className = "subShow";
		}
		else 
			if (document.getElementById("tripMenuID").selectedIndex === 2) {
				generateOneWay();
				document.getElementById("formSubmit").className = "subShow";
			}
			else 
				if (document.getElementById("tripMenuID").selectedIndex === 0) {
					if(document.getElementById("formSubmit").className === "subShow"){
						document.getElementById("formSubmit").className = "";
					}
					if(($("#flightInfo").css("display:block"))){

					}

					addH3("flightInfo","You need to choose a round trip or one way to continue","warningMsg");
					$("#carType").removeClass("show");
					
				}
				else {
					alert("error on genLastSection");
				}			
	}
	else{
		$("#flightInfo").fadeIn("slow");
		//document.getElementById("flightInfo").className = "flightshow";
		
		if (document.getElementById("tripMenuID").selectedIndex === 1) {
			generateRound();
			document.getElementById("formSubmit").className = "subShow";
		}
		else 
			if (document.getElementById("tripMenuID").selectedIndex === 2) {
				generateOneWay();
				document.getElementById("formSubmit").className = "subShow";
			}
			else 
				if (document.getElementById("tripMenuID").selectedIndex === 0) {
					if(document.getElementById("formSubmit").className === "subShow"){
						document.getElementById("formSubmit").className = "";
					}
					if(document.getElementById("flightInfo").className === "flightshow"){
						document.getElementById("flightInfo").className = "";
					}
					alert("Please choose Round trip or One way trip");
				}
				else {
					alert("error on genLastSection");
				}	
	}
}

function genLastSectionTempCopy(){
	if (document.getElementById("flightInfo").className === "flightshow") {
		removeAllChildren("flightInfo");
		
		if (document.getElementById("tripMenuID").selectedIndex === 1) {
			generateRound();
			document.getElementById("formSubmit").className = "subShow";
		}
		else 
			if (document.getElementById("tripMenuID").selectedIndex === 2) {
				generateOneWay();
				document.getElementById("formSubmit").className = "subShow";
			}
			else 
				if (document.getElementById("tripMenuID").selectedIndex === 0) {
					if(document.getElementById("formSubmit").className === "subShow"){
						document.getElementById("formSubmit").className = "";
					}
					if(document.getElementById("flightInfo").className === "flightshow"){
						document.getElementById("flightInfo").className = "";
					}
					document.getElementById("tripTypeValidation").className = "show";
				}
				else {
					alert("error on genLastSection");
				}			
	}
	else{
		document.getElementById("flightInfo").className = "flightshow";
		
		if (document.getElementById("tripMenuID").selectedIndex === 1) {
			generateRound();
			document.getElementById("formSubmit").className = "subShow";
		}
		else 
			if (document.getElementById("tripMenuID").selectedIndex === 2) {
				generateOneWay();
				document.getElementById("formSubmit").className = "subShow";
			}
			else 
				if (document.getElementById("tripMenuID").selectedIndex === 0) {
					if(document.getElementById("formSubmit").className === "subShow"){
						document.getElementById("formSubmit").className = "";
					}
					if(document.getElementById("flightInfo").className === "flightshow"){
						document.getElementById("flightInfo").className = "";
					}
					alert("Please choose Round trip or One way trip");
				}
				else {
					alert("error on genLastSection");
				}	
	}
}

//Generates the content for one way trip
function generateOneWay(){
	document.getElementById("carType").className = "show";						
	
	//Generate name fields	
	if(document.getElementById("tripTypeValidation").className === "show"){
		document.getElementById("tripTypeValidation").className = "";
	}
	
	var firstHeader = "You are making a " + resType + " one way reservation";
	
	if ($("#otherHotel").css("display") !== "block") {
		if (document.getElementById("destinoInfo")) {
			document.getElementById("destinoInfo").value = destino;
		}
		else {
			genHiddenField("destinoDiv", destino, "destinoInfo");
		}
	}
	
	addH3("flightInfo",firstHeader,"resTypeHeader");	
	
	//July 6 2k9 change
	//generateDiv("flightInfo","infoName");
	//genLabel("infoName", "Your Name: ");
	//genInputTextField("infoName","text","product[]","customerName","");
	
	//generateDiv("flightInfo","nameWarning");
	
	//Create label for transfer select
	generateDiv("flightInfo","infoTransfer");
	genLabel("infoTransfer","Type of Transfer: ");
	
	//Create type of transfer select
	var transfer_type = document.createElement("select");
	transfer_type.name = "product[]";
	transfer_type.id = "transferType";
		
	createOption(transfer_type,"Please Select One");
	createOption(transfer_type,"Arrival");	
	createOption(transfer_type,"Departure");

		
	document.getElementById("infoTransfer").appendChild(transfer_type);
	
	document.getElementById("transferType").onchange = departureCheck;	
	
	generateDiv("flightInfo","infoTransferWarning");
	
	generateDiv("flightInfo","infoDate");
	

	genFlightDateField("infoDate","one_way");
	
	$("#one_way").datepicker({
		beforeShowDay: $.datepicker.restrictDays,
		
		minDate: '0d'
	});

	
	
	generateDiv("flightInfo","infoFlight");
	genFlightNumField("infoFlight","oneFlightInfo");
	generateDiv("flightInfo","infoTime");
	genFlightTimeField("infoTime","oneWayTime");
	
	generateDiv("flightInfo","flightWarningMsg");
}

//Generates the content for round trip
function generateRound(){
	document.getElementById("carType").className = "show";						
	
	if(document.getElementById("tripTypeValidation").className === "show"){
		document.getElementById("tripTypeValidation").className = "";
	}	
	var firstHeader = "You are making a " + resType + " round trip reservation";
	
	if ($("#otherHotel").css("display") !== "block") {
		if (document.getElementById("destinoInfo")) {
			document.getElementById("destinoInfo").value = destino;
		}
		else {
			genHiddenField("destinoDiv", destino, "destinoInfo");
		}
	}
	addH3("flightInfo",firstHeader,"resTypeHeader");
	
	//July 6 2k9 change
	//Generate name fields
	//generateDiv("flightInfo","infoName");
	//genLabel("infoName", "Your Name: ");
	//genInputTextField("infoName","text","product[]","customerName","");	
	
	//generateDiv("flightInfo","nameWarning");
	
	genHiddenField("flightInfo", "Arriving","arrivingNote");
	generateDiv("flightInfo","infoArrivalLabel");
	genLabel("infoArrivalLabel","ARRIVAL INFORMATION");
	generateDiv("flightInfo","infoADate");
	genFlightDateField("infoADate","aDate");
	generateDiv("flightInfo","infoAFlight");
	genFlightNumField("infoAFlight","arrivalFlightInfo");
	generateDiv("flightInfo","infoATime");
	genFlightTimeField("infoATime","arrivalTime");
	
	generateDiv("flightInfo","ArrivalWarningMsg");
	
	genHiddenField("flightInfo", "Departing","departingNote");
	generateDiv("flightInfo","infoDepartureLabel");
	genLabel("infoDepartureLabel","DEPARTURE INFORMATION");	
	generateDiv("flightInfo","infoDDate");
	genFlightDateField("infoDDate","dDate");
	generateDiv("flightInfo","infoDFlight");
	genFlightNumField("infoDFlight","departureFlightInfo");
	generateDiv("flightInfo","infoDTime");
	genFlightTimeField("infoDTime","departureTime");
	
	var departureMsg = document.createElement("p");
	departureMsg.innerHTML = "  *The time your flight leaves from Cancun.";
	document.getElementById("infoDTime").appendChild(departureMsg);	
			
	generateDiv("flightInfo","DepartureWarningMsg");
	
	//Attach calendars on dynamic fields
	$("#aDate").datepicker({
		beforeShowDay: $.datepicker.restrictDays,
		minDate: '0d'
	});
	$("#dDate").datepicker({
		beforeShowDay: $.datepicker.restrictDays,
		minDate: '0d'
	});
}

function addH3(divToAdd,Msg,itemId){
	var header = document.createElement("h3");
	header.innerHTML = Msg;
	header.id = itemId;
	document.getElementById(divToAdd).appendChild(header);
}

//Generates a date field with an Id of CalID and appends it to divToAdd
function genFlightDateField(divToAdd,CalID){
	genLabel(divToAdd,"Date");
	
	var calField = document.createElement("input");
	calField.name = "product[]";
	calField.id = CalID;
	calField.size = "16";
	
	document.getElementById(divToAdd).appendChild(calField);
}

//Generates a flight number field with label
function genFlightNumField(divToAdd,flightId){
	genLabel(divToAdd,"Airline & Flight#");
	var fInfo = document.createElement("input");
	fInfo.name = "product[]";
	fInfo.type = "text";
	fInfo.id = flightId;
	fInfo.size = "12";
	document.getElementById(divToAdd).appendChild(fInfo);
}

//generates a time field with label and appends it to divToAdd
function genFlightTimeField(divToAdd,timeId){
	genLabel(divToAdd,"Time");
	var tInfo = document.createElement("select");
	tInfo.name = "product[]";
	tInfo.id = timeId + "Hour";
	createOption(tInfo,"--");	
	createOption(tInfo,"1");
	createOption(tInfo,"2");
	createOption(tInfo,"3");
	createOption(tInfo,"4");	
	createOption(tInfo,"5");
	createOption(tInfo,"6");
	createOption(tInfo,"7");
	createOption(tInfo,"8");	
	createOption(tInfo,"9");
	createOption(tInfo,"10");
	createOption(tInfo,"11");
	createOption(tInfo,"12");						
	document.getElementById(divToAdd).appendChild(tInfo);
	
	var mInfo = document.createElement("select");
	mInfo.name = "product[]";
	mInfo.id = timeId + "Minutes";
	createOption(mInfo,"--");		
	createOption(mInfo,"00");
	createOption(mInfo,"05");
	createOption(mInfo,"10");
	createOption(mInfo,"15");
	createOption(mInfo,"20");
	createOption(mInfo,"25");		
	createOption(mInfo,"30");	
	createOption(mInfo,"35");
	createOption(mInfo,"40");
	createOption(mInfo,"45");
	createOption(mInfo,"50");	
	createOption(mInfo,"55");						
	document.getElementById(divToAdd).appendChild(mInfo);	
	
	var tInfoAmPm = document.createElement("select");
	tInfoAmPm.name = "product[]";
	tInfoAmPm.id = timeId + "Ampm";
	createOption(tInfoAmPm,"--");		
	createOption(tInfoAmPm,"A.M.");
	createOption(tInfoAmPm,"P.M.");						
	document.getElementById(divToAdd).appendChild(tInfoAmPm);			
}

function generateDiv(divToAdd,divId){
	var newdiv = document.createElement("div");
	newdiv.id = divId;
	document.getElementById(divToAdd).appendChild(newdiv);
}

function genInputTextField(divToAdd,fieldType,fieldName,fieldId,fieldClass){
	var newElm = document.createElement("input");
	newElm.name = fieldName;
	newElm.type = fieldType;
	newElm.id = fieldId;
	newElm.className = fieldClass;
	document.getElementById(divToAdd).appendChild(newElm);	
}

function departureCheck(){
	if(document.getElementById("transferType").selectedIndex === 0){
		if(document.getElementById("departureMsg")){
			deleteElementByID("departureMsg");
		}	
	}
	else if(document.getElementById("transferType").selectedIndex === 1){
		if(document.getElementById("departureMsg")){
			deleteElementByID("departureMsg");
		}		
	}
	else if(document.getElementById("transferType").selectedIndex === 2){
		var depMsg = document.createElement("p");
		depMsg.innerHTML = "*The time your flight leaves from Cancun.";
		depMsg.id = "departureMsg";
		document.getElementById("infoTime").appendChild(depMsg);
	}	
}

//Removes all children of the element passed to the function
function removeAllChildren(elementID){
	var cell = document.getElementById(elementID);
	
	if ( cell.hasChildNodes() )
	{
	    while ( cell.childNodes.length >= 1 )
	    {
	        cell.removeChild( cell.firstChild );       
	    } 
	}	
}

function validate(dynform) {
  //Get the values of the fields in the form. The if conditions are to make sure that such
  //value exists in the form.	
  var name = dynform.customerName.value;
  if(dynform.one_way){
  	  var oneWayDate = dynform.one_way.value;
  }
  if(dynform.aDate){
  	var arrivalDate = dynform.aDate.value;	
  }

  if(dynform.dDate){
  	var departureDate = dynform.dDate.value;
  }
  
  if(dynform.transferType){
  	var tType = dynform.transferType;
  }
  
  if(dynform.oneFlightInfo){
  	var oneFInfo = dynform.oneFlightInfo.value;
  }  
  
  if(dynform.arrivalFlightInfo){
  	var arrivalInfo = dynform.arrivalFlightInfo.value;
  }    
 
  if(dynform.departureFlightInfo){
  	var departureInfo = dynform.departureFlightInfo.value;
  }     
  
  if(dynform.oneWayTime){
  	var oneTime = dynform.oneWayTime.value;
  }   
  
  if(dynform.arrivalTime){
  	var aTime = dynform.arrivalTime.value;
  }
  
  if(dynform.departureTime){
  	var dTime = dynform.departureTime.value;
  }    
  
  //one way time values
  if(dynform.oneWayTimeHour){
  	var oneTimeHour = dynform.oneWayTimeHour.value;
  }    
  if(dynform.oneWayTimeMinutes){
  	var oneTimeMinutes = dynform.oneWayTimeMinutes.value;
  }   
  if(dynform.oneWayTimeAmpm){
  	var oneTimeAmpm = dynform.oneWayTimeAmpm.value;
  }     
  
  //arrival time values
  if(dynform.arrivalTimeHour){
  	var aTimeHour = dynform.arrivalTimeHour.value;
  }
  if(dynform.arrivalTimeMinutes){
  	var aTimeMinutes = dynform.arrivalTimeMinutes.value;
  }
  if(dynform.arrivalTimeAmpm){
  	var aTimeAmpm = dynform.arrivalTimeAmpm.value;
  }      
  
  //departure time values
  if(dynform.departureTimeHour){
  	var dTimeHour = dynform.departureTimeHour.value;
  }
  if(dynform.departureTimeMinutes){
  	var dTimeMinutes = dynform.departureTimeMinutes.value;
  } 
  if(dynform.departureTimeAmpm){
  	var dTimeAmpm = dynform.departureTimeAmpm.value;
  }        
 
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  	//If round trip is chosen
	if(document.getElementById("tripMenuID").selectedIndex == 1){
		  if(name === "") {
		  	eraseRoundWarnings();
			document.getElementById("nameWarning").innerHTML = "Please enter your name";
			dynform.customerName.focus();
		    return false;
		  }
		  if(!name.match(nameRegex)) {
		  	eraseRoundWarnings();
		    document.getElementById("nameWarning").innerHTML = "You have entered an invalid name";
			dynform.customerName.focus();
		    return false;
		  }
		  			
		  if(arrivalDate === "") {
		  	eraseRoundWarnings();
			document.getElementById("ArrivalWarningMsg").innerHTML = "Please enter the date of your arrival";
			document.getElementById("ArrivalWarningMsg").className = "showLeft";
			dynform.aDate.focus();
		    return false;
		  }
		  
		  ////
		  
		  if((arrivalDate === "December 24, 2008")||(arrivalDate === "December 25, 2008")||(arrivalDate === "December 31, 2008")||(arrivalDate === "January 1, 2009")) {
		  	eraseRoundWarnings();
			document.getElementById("ArrivalWarningMsg").innerHTML = "Unfortunately, December 24th, 25th, 31st and January 1st are sold out. Please choose a different date from the calendar";
			document.getElementById("ArrivalWarningMsg").className = "showBlue";
		    return false;
		  }
		  
		  		  
		 
		  if(arrivalInfo === "") {
		  	eraseRoundWarnings();
			document.getElementById("ArrivalWarningMsg").innerHTML = "Enter Airline Name and Flight Number";
			document.getElementById("ArrivalWarningMsg").className = "show";
			dynform.arrivalFlightInfo.focus();
		    return false;
		  }		 
		  //arrival time fields 
		  if(aTimeHour === "--") {
		  	eraseRoundWarnings();
			document.getElementById("ArrivalWarningMsg").innerHTML = "Enter the hour of your flight";
			document.getElementById("ArrivalWarningMsg").className = "showRight";
			dynform.arrivalTimeHour.focus();
		    return false;
		  }		
		  if(aTimeMinutes === "--") {
		  	eraseRoundWarnings();
			document.getElementById("ArrivalWarningMsg").innerHTML = "Please Enter the minutes";
			document.getElementById("ArrivalWarningMsg").className = "showRight";
			dynform.arrivalTimeMinutes.focus();
		    return false;
		  }	
		  if(aTimeAmpm === "--") {
		  	eraseRoundWarnings();
			document.getElementById("ArrivalWarningMsg").innerHTML = "Please enter AM or PM";
			document.getElementById("ArrivalWarningMsg").className = "showRight";
			dynform.arrivalTimeAmpm.focus();
		    return false;
		  }			  		     
		  
		  if(departureDate === "") {
		  	eraseRoundWarnings();
			document.getElementById("DepartureWarningMsg").innerHTML = "Enter the date of your departure";
			document.getElementById("DepartureWarningMsg").className = "showLeft";
			dynform.dDate.focus();
		    return false;
		  }        
		  
		  
		  
		  if((departureDate === "December 24, 2008")||(departureDate === "December 25, 2008")||(departureDate === "December 31, 2008")||(departureDate === "January 1, 2009")) {
		  	eraseRoundWarnings();
			document.getElementById("DepartureWarningMsg").innerHTML = "Unfortunately, December 24th, 25th, 31st and January 1st are sold out. Please choose a different date from the calendar";
			document.getElementById("DepartureWarningMsg").className = "showBlue";
		    return false;
		  }  
		  
		  
		  		  

		  if(departureInfo === "") {
		  	eraseRoundWarnings();
			document.getElementById("DepartureWarningMsg").innerHTML = "Enter Airline Name and Flight Number";
			document.getElementById("DepartureWarningMsg").className = "show";
			dynform.departureFlightInfo.focus();
		    return false;
		  }       

		  //departure time fields		  	  
		  if(dTimeHour === "--") {
		  	eraseRoundWarnings();
			document.getElementById("DepartureWarningMsg").innerHTML = "Enter the hour of your flight";
			document.getElementById("DepartureWarningMsg").className = "showRight";
			dynform.departureTimeHour.focus();
		    return false;
		  }                
		  if(dTimeMinutes === "--") {
		  	eraseRoundWarnings();
			document.getElementById("DepartureWarningMsg").innerHTML = "Please Enter the minutes";
			document.getElementById("DepartureWarningMsg").className = "showRight";
			dynform.departureTimeMinutes.focus();
		    return false;
		  } 
		  if(dTimeAmpm === "--") {
		  	eraseRoundWarnings();
			document.getElementById("DepartureWarningMsg").innerHTML = "Please enter AM or PM";
			document.getElementById("DepartureWarningMsg").className = "showRight";
			dynform.departureTimeAmpm.focus();
		    return false;
		  } 		  		    		
	}  
	//If one way is chosen
	else if(document.getElementById("tripMenuID").selectedIndex == 2){
		  if(name === "") {
		  	eraseOneWayWarnings();
			document.getElementById("nameWarning").innerHTML = "Please enter your name";
			dynform.customerName.focus();
		    return false;
		  }
		  if(!name.match(nameRegex)) {
		  	eraseOneWayWarnings();
		    document.getElementById("nameWarning").innerHTML = "You have entered an invalid name";
			dynform.customerName.focus();
		    return false;
		  }
		  
		  if(tType){
			  if(tType.selectedIndex === 0){
			  	eraseOneWayWarnings();
				document.getElementById("infoTransferWarning").innerHTML = "Please choose the type of transfer you need";
				dynform.transferType.focus();
			    return false;  	
			  }    	
		  }  
		  
		  if(oneWayDate === "") {
		  	eraseOneWayWarnings();
			document.getElementById("flightWarningMsg").innerHTML = "Please enter the date of your flight";
			document.getElementById("flightWarningMsg").className = "showLeft";
			dynform.one_way.focus();
		    return false;
		  }  
		  
		  if((oneWayDate === "December 24, 2008")||(oneWayDate === "December 25, 2008")||(oneWayDate === "December 31, 2008")||(oneWayDate === "January 1, 2009")){
			eraseOneWayWarnings();
			document.getElementById("flightWarningMsg").innerHTML = "Unfortunately, December 24th, 25th, 31st and January 1st are sold out. Please choose a different date from the calendar";
			document.getElementById("flightWarningMsg").className = "showBlue";
			return false;
		  }
		  
		  if(oneFInfo === "") {
		  	eraseOneWayWarnings();
			document.getElementById("flightWarningMsg").innerHTML = "Enter Airline Name and Flight Number";
			document.getElementById("flightWarningMsg").className = "show";
			dynform.oneFlightInfo.focus();
		    return false;
		  }
		  //one way time fields
		  if((oneTimeHour === "--")) {
		  	eraseOneWayWarnings();
			document.getElementById("flightWarningMsg").innerHTML = "Enter the hour of your flight";
			document.getElementById("flightWarningMsg").className = "showRight";
			dynform.oneWayTimeHour.focus();
		    return false;
		  }     		
		  
		  if((oneTimeMinutes === "--")) {
		  	eraseOneWayWarnings();
			document.getElementById("flightWarningMsg").innerHTML = "Please Enter the minutes";
			document.getElementById("flightWarningMsg").className = "showRight";
			dynform.oneWayTimeMinutes.focus();
		    return false;
		  }  	
		  
		  if((oneTimeAmpm === "--")) {
		  	eraseOneWayWarnings();
			document.getElementById("flightWarningMsg").innerHTML = "Please enter AM or PM";
			document.getElementById("flightWarningMsg").className = "showRight";
			dynform.oneWayTimeAmpm.focus();
		    return false;
		  } 	  	  
		  
	}
  return true;
}


function eraseOneWayWarnings(){
	document.getElementById("nameWarning").innerHTML = "";
	document.getElementById("infoTransferWarning").innerHTML = "";
	document.getElementById("flightWarningMsg").innerHTML = "";
	document.getElementById("flightWarningMsg").className = "";
}

function eraseRoundWarnings(){
	document.getElementById("nameWarning").innerHTML = "";	
	document.getElementById("ArrivalWarningMsg").innerHTML = "";
	document.getElementById("DepartureWarningMsg").innerHTML = "";
	document.getElementById("ArrivalWarningMsg").className = "";
	document.getElementById("DepartureWarningMsg").className = "";	
}

function cleanBelowFlightInfo(){
	if($("#tripType").css("display") === "block"){
		$("#tripType").css({display:"none"});
		removeAllChildren("tripType");
		$("#tenPercent").css({display:"none"});
	}
	if($("#flightInfo").css("display") === "block"){
		$("#flightInfo").css({display:"none"});
		document.getElementById("carType").className = "";
		document.getElementById("formSubmit").className = "";
		//$("#carType").css({display:"none"});
		//$("#formSubmit").css({display:"none"});
		removeAllChildren("flightInfo");
	}
}








//Utility Functions 

//Function that returns the value of an item on the list when given a label.
//In the context of this program it gets the destiny where a hotel is located when given its name
//Used by: makeChoice
function getValue(hname){
	
	if (xhr.readyState === 4) {
		if (xhr.status === 200) {
			if (xhr.responseXML) { //checking if everything is fine with what we expect to get
				//Get all the hotels from the xml file and place them in allHotels
				var allHotelsVar2 = xhr.responseXML.getElementsByTagName("item");
				//Going through the allHotels array and getting the name of the hotels and putting
				//them in the hotelsArray array. We only get the text. That's why we use firstChild
				for (var i=0; i<allHotelsVar2.length; i++) {					
					//we use textContent for comparison purposes and to return the text value in firstChild
					if( allHotelsVar2[i].getElementsByTagName("label")[0].firstChild.nodeValue == hname ){
						return allHotelsVar2[i].getElementsByTagName("value")[0].firstChild.nodeValue;
					}			
				}
				return "error, there was no such hotel in the list";
			}
		}
		else {
			alert("There was a problem with the request " + xhr.status);
		}
	}	
}

//Function process the number of passenters to return the 3 different categories in which customers are charged
function processPaxNum(paxnum){
	paxnum = processString(paxnum);
	paxNumber = paxnum;
	if(paxnum < 3){
		if(document.getElementById("CarInfoId")){
			deleteElementByID("CarInfoId");
			genHiddenField("carInfo","Car 1-2 Pax","CarInfoId");	
		}
		else{
			genHiddenField("carInfo","Car 1-2 Pax","CarInfoId");
		}
		return "1-2 Pax";
	}
	else if(paxnum < 8){
		if(document.getElementById("CarInfoId")){
			deleteElementByID("CarInfoId");
			genHiddenField("carInfo","Van 3-7 Pax","CarInfoId");
		}
		else{
			genHiddenField("carInfo","Van 3-7 Pax","CarInfoId");	
		}
		return "3-7 Pax";
	}
	else{
		if(document.getElementById("CarInfoId")){
			deleteElementByID("CarInfoId");
			genHiddenField("carInfo","Van 8-10 Pax","CarInfoId");
		}
		else{
			genHiddenField("carInfo","Van 8-10 Pax","CarInfoId");
		}
		return "8-10 Pax";
	}	
	alert("error in processPaxNum");
}

//This function creates a destination menu. Calls createOption to fill the menu and returns the filled menu
//Calls: createOption
//Used by: makeChoice
function populateDestinationMenu(){
	var destinationMenu = document.createElement("select");
	destinationMenu.name = "product[]";
	destinationMenu.id = "destMenu";
	
	var optionToAdd = document.createElement("option");
	optionToAdd.selected = "selected";
	optionToAdd.innerHTML = "Please Select Your Destination";
	destinationMenu.appendChild(optionToAdd);	
	
	createOption(destinationMenu,"akumal");
	createOption(destinationMenu,"boca paila");
	createOption(destinationMenu,"calica");
	createOption(destinationMenu,"cancun");
	createOption(destinationMenu,"chetumal");
	createOption(destinationMenu,"chichen itza");
	createOption(destinationMenu,"chiquila");
	createOption(destinationMenu,"cozumel");	
	createOption(destinationMenu,"holbox");
	createOption(destinationMenu,"isla mujeres");
	createOption(destinationMenu,"maroma beach");
	createOption(destinationMenu,"merida");
	createOption(destinationMenu,"paamul");
	createOption(destinationMenu,"paraiso beach");
	createOption(destinationMenu,"playa del carmen");
	createOption(destinationMenu,"playa mujeres");
	createOption(destinationMenu,"playacar");
	createOption(destinationMenu,"puerto aventuras");
	createOption(destinationMenu,"puerto juarez");
	createOption(destinationMenu,"puerto morelos");
	createOption(destinationMenu,"tankah");
	createOption(destinationMenu,"tulum");
	createOption(destinationMenu,"tulum hotel zone");
	createOption(destinationMenu,"valladolid");
	createOption(destinationMenu,"xcaret");
	createOption(destinationMenu,"xpu ha");
		
	return destinationMenu;
}

//Create option creates option nodes and appends them to menu with a value and text of opt
//Used by: populatePaxMenu
function createOption(Menu,opt){
	var optionToAdd = document.createElement("option");
	optionToAdd.value = opt;
	optionToAdd.innerHTML = opt;
	Menu.appendChild(optionToAdd);
}


function processString(str){
	if(str.charAt(0)=== " "){
		return str.charAt(0);
	}
	else return str.substr(0,2);
}

















//Utility functions for dom scripting
function deleteElementByID(elementID){
		//Retrieve the element by its ID
		var elementToDelete = document.getElementById(elementID);
		//We can only remove an element through its parent node so we need to get that and store it in a variable
		var parentNode = elementToDelete.parentNode;
		//Retrive the first sibling of the element to delete
		var nodeVar = parentNode.firstChild;
		//Counter starts at one because we already retrieved the first sibling
		var j=1;
		
		//If the first sibling is the one with an Id of elementId we remove the first element, the one with index 0, which is the first one.
		if(nodeVar.id === elementID){
			parentNode.removeChild(parentNode.childNodes[0]);
		}	
		//Otherwise we need to go through all the siblings and since we dont know how many there are we use a while loop
		else{
			var nodeBro = nodeVar.nextSibling;
			while(nodeBro.id != elementID){
				nodeBro = nodeBro.nextSibling; 
				j++;
			}
			parentNode.removeChild(parentNode.childNodes[j]);
		}	
}

//generates a hidden field with infoToSend as value and appends it to divToAdd div
function genHiddenField(divToAdd, infoToSend, fieldId){
	var info = document.createElement("input");
	info.name = "product[]";
	info.type = "hidden";
	info.value = infoToSend;
	info.id = fieldId;
	document.getElementById(divToAdd).appendChild(info);
}

//Generates a label with text of labelText and appends it to divToAdd
function genLabel(divToAdd,labelText){
	var transTypeLabel = document.createElement("label");
	transTypeLabel.innerHTML = labelText;
	document.getElementById(divToAdd).appendChild(transTypeLabel);	
} 

//generates a br to add to the divToAdd div
function genBreakLine(divToAdd){
	var bLine = document.createElement("br");
	document.getElementById(divToAdd).appendChild(bLine);
}

function attachOffer(pxnum){
	var offer = pxnum * 10;
	if(offer > 50){
		offer = 50;
	}
	//offerMsg = "<p>Extra, Extra… with this reservation you’ll receive a $" + offer + ".00 Gift Card for tours and excursions.</p>";
	offerMsg = " ";
		//document.getElementById("tenPercent").innerHTML = offerMsg;
	
}

function findDiscount(paxnum){
	if(paxnum < 3){
		sharedCoupon = 30;
		privateCoupon = 30;
	}
	else if(paxnum < 8){
		sharedCoupon = 60;
		privateCoupon = 60;
	}
	else{
		sharedCoupon = 60;
		privateCoupon = 90;
	}	
}

function displayDiscount(num){
	if(num <= 0){
		return "Free";
	}
	else{
		return "$"+ num.toFixed(2);
	}
}

function checkExceptions(){ 
	var i;
	for(i=0; i<exception.length; i+=1){
		if (ChosenHotel === exception[i]) 
			return false;
	}
	return true;
}
