//Full URL to the loading image, used with the ajax offers.
var LOADING_IMAGE = 'http://www.epsilonecho.com/general_img/looping.gif';

//Full URL to the AJAX handler file for the package offers.
var AJAX_PACKAGE = 'http://www.holidayholidayholiday.co.uk/ajax/index.php';

//Full URL to the AJAX handler file for the ski offers.
var AJAX_SKI = 'http://www.holidayholidayholiday.co.uk/ajax/index.php';

//Full URL to the AJAX handler file for the cruise offers.
var AJAX_CRUISE = 'http://www.holidayholidayholiday.co.uk/ajax/index.php';
	
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validate_multi_check_box(my_multicheck) {
  for (var j=0; j<my_multicheck.length; j++) {
	if ((my_multicheck[j].checked)){ 
		return true;
	}
  }
  return false;
}

function confirmDelete(message){
	if(confirm(message)){
		return true;
	}else{
		return false;
	}
}

function validate_multi_select_box(my_multiselect) {
  for (var j=0; j<my_multiselect.length; j++) {
		if ((my_multiselect.options[j].selected)&(my_multiselect.options[j].value !='')){ 
			return true;
		}
  }
  return false;
}


//epsilonmedia functions start
function checkNewsletter(form) {
	if(!isValidEmail(form.email_address.value)){
		alert("Please type in a valid email address - Example: yourname@hotmail.com ");
		form.email_address.focus();
		return false;
	}else{
		return true;
	}
}

function isValidEmail(email_address) {
	if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email_address)){
		return false;
	}else{
		return true;
	}
}

function package_page_link(div_id, pageID, destination_id, depart_airport, 
							date_depart, budget_type, budget_value, agent_id, 
							sort_by, ajax_offers, list_url, hot_offer, nights, 
							holiday_type, tier, search_type, rating, board_basis, 
							note_id, gateways, tour_operator, template_search, 
							family_price_only, ppp_adult_share, ppp_child_share, 
							accom_name, accom_sellingcode, accom_reference, use_index, ddate) {
	
    window.scrollTo(0,0);
    
    if($('date_depart_month') != null){
    	var dmonth = $('date_depart_month').value;
    }else{
    	var dmonth = '';
    }

    if($('date_depart_day') != null){
    	var dday = $('date_depart_day').value;
    }else{
    	var dday = '';
    }
    
    if(dmonth != '' && dday == ''){
    	date_depart = dmonth;
    }
    
    if(dday != '' && dmonth == ''){
    	date_depart = dday;
    }    
    
	$(div_id).innerHTML = "<div id=\"looping\" class=\"looping\">Please Wait - "
							+"Searching for holidays<br />"
							+"<img src='"+LOADING_IMAGE+"' width=\"75\""
							+" height=\"15\" alt=\"Please Wait - Searching for"
							+" holidays\" /></div>";

	var url = AJAX_PACKAGE+'?c=PackageOffers&amp;m=search_offers&amp;pageID='+pageID+
							'&amp;destination_id='+destination_id+
							'&amp;depart_airport='+depart_airport+
							'&amp;date_depart='+date_depart+
							'&amp;budget_type='+budget_type+
							'&amp;budget='+budget_value+
							'&amp;agent_id='+agent_id+
							'&amp;sort_by='+sort_by+
							'&amp;ajax_offers='+ajax_offers+
							'&amp;list_url='+list_url+
							'&amp;hot_offer='+hot_offer+
							'&amp;nights='+nights+
							'&amp;holiday_type='+holiday_type+
							'&amp;tier='+tier+
							'&amp;search_type='+search_type+
							'&amp;rating='+rating+
							'&amp;board_basis='+board_basis+
							'&amp;note_id='+note_id+
							'&amp;gateways='+gateways+
							'&amp;tour_operator='+tour_operator+
							'&amp;template_search='+template_search+
							'&amp;family_price_only='+family_price_only+
							'&amp;ppp_adult_share='+ppp_adult_share+
							'&amp;ppp_child_share='+ppp_child_share+
							'&amp;accom_name='+accom_name+
							'&amp;accom_sellingcode='+accom_sellingcode+
							'&amp;accom_reference='+accom_reference+
							'&amp;use_index='+use_index+
							'&amp;ddate='+ddate;

	new Ajax.Request(url,
					{
						method: "get",
						onSuccess : function(transport){
		
							if(transport.responseText == ''){
								window.location.href = '/no-results.html';
							}else{
								Effect.BlindDown(div_id);
								$(div_id).update(transport.responseText);
							}
						}					
					}		
	);	
}

function ski_page_link(div_id, pageID, destination_id, resort, depart_airport, 
						date_depart, nights, agent_id, sort_by, ajax_offers, 
						list_url, hot_offer, search_level, search_type, rating, 
						board_basis, note_id, gateways, tour_operator, 
						template_search, family_price_only, ppp_adult_share, 
						ppp_child_share, below_price, accom_name, 
						accom_sellingcode, accom_reference, use_index) {

	window.scrollTo(0,0);
	
    if($('date_depart_month') != null){
    	var dmonth = $('date_depart_month').value;
    }else{
    	var dmonth = '';
    }

    if($('date_depart_day') != null){
    	var dday = $('date_depart_day').value;
    }else{
    	var dday = '';
    }
    
    if(dmonth != '' && dday == ''){
    	date_depart = dmonth;
    }

    if(dday != '' && dmonth == ''){
    	date_depart = dday;
    }  	

	$(div_id).innerHTML = "<div id=\"looping\" class=\"looping\">Please Wait - "
							+"Searching for holidays<br /><br />"
							+"<img src='"+LOADING_IMAGE+"' width=\"75\" "
							+"height=\"15\" alt=\"Please Wait - Searching for "
							+"holidays\" /></div>";

	var url = AJAX_SKI+'?c=SkiOffers&amp;m=search_offers&amp;pageID='+pageID+
						'&amp;destination_id='+destination_id+
						'&amp;resort='+resort+
						'&amp;depart_airport='+depart_airport+
						'&amp;date_depart='+date_depart+
						'&amp;nights='+nights+
						'&amp;agent_id='+agent_id+
						'&amp;sort_by='+sort_by+
						'&amp;ajax_offers='+ajax_offers+
						'&amp;list_url='+list_url+
						'&amp;hot_offer='+hot_offer+
						'&amp;search_level='+search_level+
						'&amp;search_type='+search_type+
						'&amp;rating='+rating+
						'&amp;board_basis='+board_basis+
						'&amp;note_id='+note_id+
						'&amp;gateways='+gateways+
						'&amp;tour_operator='+tour_operator+
						'&amp;template_search='+template_search+
						'&amp;family_price_only='+family_price_only+
						'&amp;ppp_adult_share='+ppp_adult_share+
						'&amp;ppp_child_share='+ppp_child_share+
						'&amp;below_price='+below_price+
						'&amp;accom_name='+accom_name+
						'&amp;accom_sellingcode='+accom_sellingcode+
						'&amp;accom_reference='+accom_reference+
						'&amp;use_index='+use_index;
	
	new Ajax.Request(url,
			{
				method: "get",
				onSuccess : function(transport){

					if(transport.responseText == ''){
						window.location.href = '/no-results.html';
					}else{
						Effect.BlindDown(div_id);
						$(div_id).update(transport.responseText);
					}
				}					
			}		
	);
}

function cruise_page_link(div_id, pageID, destination_id, travel_from, from_date, 
							cruise_line, cruise_ship, agent_id, sort_by, 
							ajax_offers, list_url, hot_offer, search_level, 
							search_type, note_id, tour_operator, nights, 
							template_search, family_price_only, ppp_adult_share, 
							ppp_child_share, below_price, accom_name, 
							accom_sellingcode, accom_reference, use_index) {

	
	window.scrollTo(0,0);
	
	
    if($('date_depart_month') != null){
    	var dmonth = $('date_depart_month').value;
    }else{
    	var dmonth = '';
    }

    if($('date_depart_day') != null){
    	var dday = $('date_depart_day').value;
    }else{
    	var dday = '';
    }
    
    if(dmonth != '' && dday == ''){
    	from_date = dmonth;
    }

    if(dday != '' && dmonth == ''){
    	from_date = dday;
    }  	

	$(div_id).innerHTML = "<div id=\"looping\" class=\"looping\">Please Wait - "
							+"Searching for holidays<br /><br />"
							+"<img src='"+LOADING_IMAGE+"' width=\"75\" "
							+"height=\"15\" alt=\"Please Wait - Searching for "
							+"holidays\" /></div>";

	
	
	var url = AJAX_CRUISE+'?c=CruiseOffers&amp;m=search_offers'+
							'&amp;pageID='+pageID+
							'&amp;destination_id='+destination_id+
							'&amp;travel_from='+travel_from+
							'&amp;from_date='+from_date+
							'&amp;cruise_line='+cruise_line+
							'&amp;cruise_ship='+cruise_ship+
							'&amp;agent_id='+agent_id+
							'&amp;sort_by='+sort_by+
							'&amp;ajax_offers='+ajax_offers+
							'&amp;list_url='+list_url+
							'&amp;hot_offer='+hot_offer+
							'&amp;search_level='+search_level+
							'&amp;search_type='+search_type+
							'&amp;note_id='+note_id+
							'&amp;tour_operator='+tour_operator+
							'&amp;nights='+nights+
							'&amp;template_search='+template_search+
							'&amp;family_price_only='+family_price_only+
							'&amp;ppp_adult_share='+ppp_adult_share+
							'&amp;ppp_child_share='+ppp_child_share+
							'&amp;below_price='+below_price+
							'&amp;accom_name='+accom_name+
							'&amp;accom_sellingcode='+accom_sellingcode+
							'&amp;accom_reference='+accom_reference+
							'&amp;use_index='+use_index;
	
	new Ajax.Request(url,
			{
				method: "get",
				onSuccess : function(transport){

					if(transport.responseText == ''){
						window.location.href = '/no-results.html';
					}else{
						Effect.BlindDown(div_id);
						$(div_id).update(transport.responseText);
					}
				}					
			}		
	);
}


function getXmlHotelData(package_id, selling_code, tour_operator, gateway_code) {

	var url = AJAX_PACKAGE+'?c=xml_hotel_request&amp;m='+
							'&amp;package_id='+package_id+
							'&amp;selling_code='+selling_code+
							'&amp;tour_operator='+tour_operator+
							'&amp;gateway_code='+gateway_code;


	new Ajax.Request(
			url,
			{
				method: "get",
				onLoading: function() {
					$('xml_additional_text').update("Loading hotel data...");
					$('show_package_image').update("Loading hotel images...");
					$('show_hotel_image').update("Loading hotel images...");
				},
				onSuccess: function(transport){
							
					var data = transport.responseText.split('~~~');

					$('xml_additional_text').update(data['2']);
					$('show_package_image').update(data['1']);
					$('show_hotel_image').update(data['0']);
				}
			}
	);

}

function getXmlHotelDataSki(package_id, selling_code, tour_operator, 
																gateway_code) {

	var url = AJAX_SKI+'?c=xml_hotel_request&amp;m=&amp;package_id='+package_id+
							'&amp;selling_code='+selling_code+
							'&amp;tour_operator='+tour_operator+
							'&amp;gateway_code='+gateway_code;

	new Ajax.Request(
			url,
			{
				method: "get",
				onLoading: function() {
					$('xml_additional_text').update("Loading hotel data...");
					$('show_package_image').update("Loading hotel images...");
					$('show_hotel_image').update("Loading hotel images...");
				},
				onSuccess: function(transport){
							
					var data = transport.responseText.split('~~~');

					$('xml_additional_text').update(data['2']);
					$('show_package_image').update(data['1']);
					$('show_hotel_image').update(data['0']);
				}
			}
	);

}

function getXmlHotelDataCruise(package_id, selling_code, tour_operator, 
																gateway_code) {

	var url = AJAX_CRUISE+'?c=xml_hotel_request&amp;m='
										'&amp;package_id='+package_id+
										'&amp;selling_code='+selling_code+
										'&amp;tour_operator='+tour_operator+
										'&amp;gateway_code='+gateway_code;

	new Ajax.Request(
			url,
			{
				method: "get",
				onLoading: function() {
					$('xml_additional_text').update("Loading hotel data...");
					$('show_package_image').update("Loading hotel images...");
					$('show_hotel_image').update("Loading hotel images...");
				},
				onSuccess: function(transport){
							
					var data = transport.responseText.split('~~~');

					$('xml_additional_text').update(data['2']);
					$('show_package_image').update(data['1']);
					$('show_hotel_image').update(data['0']);
				}
			}
	);
}

function checkEmailToAgent(form){

	shortcontact = $F('contactnumber');
	shortcontact = shortcontact.replace(/ /g, '');
	if($F('firstname') == ''){
		alert("Type your name, please!");
		$('firstname').focus();
		return false;
	}else if($F('surname') == ''){
		alert("Type your surname, please!");
		$('surname').focus();
		return false;
	}else if(!isValidEmail($F('email'))){
		alert("Type your email address, please!");
		$('email').focus();
		return false;
	}else if(!isValidEmail($F('emailconfirm'))){
		alert("Confirm your email address, please!");
		$('emailconfirm').focus();
		return false;
	}else if($F('email') != $F('emailconfirm')){
		alert("Re-type and confirm your email address, please!");
		$('email').value = '';
		$('emailconfirm').value = '';
		$('email').focus();
		return false;
	}else if ($F('contactnumber') == ''){
		alert("Type your contact number, please!");
		return false;
	}else if (shortcontact.length < 6){
		alert("Please type a valid contact number!");
		return false;
	}else if (!shortcontact.match(/^[0-9]+$/)) {
		alert("Please type a valid contact number!");
		return false;	
	}else{
		return true;
	}
	
}

function checkCallbackRerquest(form){

	if($F('firstname') == ''){
		alert("Type your name, please!");
		$('firstname').focus();
		return false;
	}else if($F('surname') == ''){
		alert("Type your surname, please!");
		$('surname').focus();
		return false;
	}else if(!isValidEmail($F('email'))){
		alert("Type your email address, please!");
		$('email').focus();
		return false;
	}else if(!isValidEmail($F('emailconfirm'))){
		alert("Confirm your email address, please!");
		$('emailconfirm').focus();
		return false;
	}else if($F('email') != $F('emailconfirm')){
		alert("Re-type and confirm your email address, please!");
		$('email').value = '';
		$('emailconfirm').value = '';
		$('email').focus();
		return false;
	}else{
		return true;
	}	
	
}

function getResorts(country_id, element) {

	var url = AJAX_SKI+'?c=SkiOffers&amp;m=getResortsByCountry&amp;country_id='
																	+country_id;

	new Ajax.Request(
		url,
		{
			method: "get",
			onLoading: function() {
				$(element).update("Loading Resorts...");
			},
			onSuccess: function(transport){
				$(element).update(transport.responseText);
			}
		}	
	);
}

function getAirports(destination_id, element, selected) {

	var url = AJAX_SKI+"?c=SkiOffers&amp;m=getAirportsByDestination&amp;destination_id="+destination_id+"&amp;selected="+selected;

	new Ajax.Updater(element, url, {method: "get"});
}

function getMonths(destination_id, airport, element, selected){

		var url = AJAX_SKI+"?c=SkiOffers&amp;m=getDatesByDestinationAndAirport&amp;destination_id="+destination_id+"&amp;airport="+airport+"&amp;selected="+selected;

		new Ajax.Updater(element, url, {method: "get"});
}

function getFullDates(year_month, element) {

	var url = AJAX_SKI+"?c=SkiOffers&amp;m=getAllAvailabeFullDates&amp;year_month="+year_month;

	new Ajax.Updater(element, url, {method: "get"});

}

function getShips(cruise_line_id, element){

	var url = AJAX_CRUISE+'?c=CruiseOffers&amp;m=getShips&amp;cruise_line_id='
																+cruise_line_id;

	new Ajax.Request(
		url,
		{
			method: "get",
			onLoading: function() {
				$(element).update("Loading Ships...");
			},
			onSuccess: function(transport){
				$(element).update(transport.responseText);
			}
		}	
	);
}

function showForm(element) {

	$('hreq5', 'hreq8', 'hreq9', 'hreq10', 'hreq11').invoke('hide');

	if(element > 0){
		Effect.toggle('hreq'+element, 'blind');
	}
}

function checkSave(){
	
	if($F('first_name') == ''){
		alert("Type your name, please!");
		$('first_name').focus();
		return false;
	}else if($F('surname') == ''){
		alert("Type your surname, please!");
		$('surname').focus();
		return false;
	}else if(!isValidEmail($F('email'))){
		alert("Type your email address, please!");
		$('email').focus();
		return false;
	}else if(!isValidEmail($F('emailconfirm'))){
		alert("Confirm your email address, please!");
		$('emailconfirm').focus();
		return false;
	}else if($F('email') != $F('emailconfirm')){
		alert("Re-type and confirm your email address, please!");
		$('email').value = '';
		$('emailconfirm').value = '';
		$('email').focus();
		return false;
	}else{
		return true;
	}	
	
}

function checkSendInbox(){

	if($F('firstname') == ''){
		alert("Type your name, please!");
		$('firstname').focus();
		return false;
	}else if($F('surname') == ''){
		alert("Type your surname, please!");
		$('surname').focus();
		return false;
	}else if(!isValidEmail($F('email'))){
		alert("Type your email address, please!");
		$('email').focus();
		return false;
	}else if(!isValidEmail($F('emailconfirm'))){
		alert("Confirm your email address, please!");
		$('emailconfirm').focus();
		return false;
	}else if($F('email') != $F('emailconfirm')){
		alert("Re-type and confirm your email address, please!");
		$('email').value = '';
		$('emailconfirm').value = '';
		$('email').focus();
		return false;
	}else{
		return true;
	}
}

function checkSendFriend(){
	
	if($F('firstname') == ''){
		alert("Type your name, please!");
		$('firstname').focus();
		return false;
	}else if($F('surname') == ''){
		alert("Type your surname, please!");
		$('surname').focus();
		return false;
	}else if(!isValidEmail($F('email'))){
		alert("Type your email address, please!");
		$('email').focus();
		return false;
	}else if(!isValidEmail($F('emailconfirm'))){
		alert("Confirm your email address, please!");
		$('emailconfirm').focus();
		return false;
	}else if($F('email') != $F('emailconfirm')){
		alert("Re-type and confirm your email address, please!");
		$('email').value = '';
		$('emailconfirm').value = '';
		$('email').focus();
		return false;
	}if($F('friend_firstname') == ''){
		alert("Type your friend's name, please!");
		$('friend_firstname').focus();
		return false;
	}else if($F('friend_surname') == ''){
		alert("Type your friend's surname, please!");
		$('friend_surname').focus();
		return false;
	}else if(!isValidEmail($F('friend_email'))){
		alert("Your email friend's address, please!");
		$('friend_email').focus();
		return false;
	}else if(!isValidEmail($F('friend_emailconfirm'))){
		alert("Confirm your friend's email address, please!");
		$('friend_emailconfirm').focus();
		return false;
	}else if($F('friend_email') != $F('friend_emailconfirm')){
		alert("Re-type and confirm your friend's email address, please!");
		$('friend_email').value = '';
		$('friend_emailconfirm').value = '';
		$('friend_email').focus();
		return false;
	}else{
		return true;
	}
		
}

function ha_destinations(holiday_type, selected_destination, selected_airport){
	
	$('ha_dest').update("<span class=\"load\">Loading destinations...</span>");

	$('ha_airport').update("<span class=\"load\" style=\"padding-left: 140px; "
							+"line-height: 30px;\">Loading airports...</span>");

	$('ha_resort').update("");

	var url = AJAX_PACKAGE+'?c=HolidayAlert&amp;m=getDestinations'+
							'&amp;holiday_type='+holiday_type+
							'&amp;destination='+selected_destination+
							'&amp;airport='+selected_airport;

	new Ajax.Request(url, 
						{
							method: "get",
							onSuccess: function(transport){
								var res = transport.responseText.split('~~~~');
										
								$('ha_dest').update(res[1]);
								$('ha_airport').update(res[0]);
							}										
						}	
	);
}

function ha_ski_resorts(element, country_id, resort_id){

	$(element).update("<label>&nbsp;</label><span class=\"load\">Loading ski "+
						"resorts...</span><br /><br />");

	var url = AJAX_SKI+"?c=HolidayAlert&amp;m=getSkiResorts"+
					"&amp;country_id="+country_id+"&amp;resort_id="+resort_id;

	new Ajax.Updater(element, url, {method: "get"});

}

function show_hotel_image(img_src, width, height) {
	document['hotel_image'].src = img_src;	
	document['hotel_image'].width = width;
	document['hotel_image'].height = height;
}

function getCruiseDestinations(travel_from, element, selected) {

	var url = AJAX_CRUISE+"?c=CruiseOffers&amp;m=getDestinationsByAirport&amp;travel_from="+travel_from+"&amp;selected="+selected;

	new Ajax.Updater(element, url, {method: "get"});
}

function getCruiseMonths(travel_from, destination_id, element, selected){

	var url = AJAX_CRUISE+"?c=CruiseOffers&amp;m=getDatesByDestinationAndAirport&amp;travel_from="+travel_from+"&amp;destination_id="+destination_id+"&amp;selected="+selected;

	new Ajax.Updater(element, url, {method: "get"});

}

function getMonthsByCruiseLine(cruise_line, element, selected_date){

	var url = AJAX_CRUISE+"?c=CruiseOffers&amp;m=getDatesByCruiseLine&amp;cruise_line="+cruise_line+'&amp;selected_date='+selected_date;

	new Ajax.Updater(element, url, {method: "get"});

}

function showCalendar(element, subelement){

    Calendar.setup({
        inputField     :    element,
        ifFormat       :    "%d/%m/%Y",
        button		   :	element,
        onUpdate       :    secondCalendar
     });	

    //this will be used at the callback function
    scfull = subelement;
}

function secondCalendar(cal1){
	
	if($(scfull)){
		var date1 = cal1.date;
		var time = date1.getTime();
		time += Date.DAY;
	
		var date2 = new Date(time);
		$(scfull).value = date2.print("%d/%m/%Y");
	}

}

function fb_forms(agent_reply){
	
	if(agent_reply == 1){
		$('fb_sorry').hide();
		Effect.BlindDown('fb_questionnaire');
	}else if(agent_reply == 2){
		Effect.BlindDown('fb_sorry');
		$('fb_questionnaire').hide();
	}
	
	$('got_reply').disable();
}

function fb_send_again(send_now, request_id){

	$('send_again').disable();
	$('send_again_result').hide();
	
	if(send_now == 1){
		var url = AJAX_PACKAGE+'?c=EnquiryRequest&m=send_again&request_id='+request_id;
	
		new Ajax.Request(url,
			{
				method: "get",
				onSuccess : function(transport){
			
					if(transport.responseText != ''){
						alert(transport.responseText);
					}else{
						$('send_again_result').show();
						$('send_again_result').update('Thank you for giving us the opportunity server your enquiry again.<br />Our travel agent will be intouch soon.');
						new Effect.Shake('send_again_result');
					}
				}					
			}		
		);
		
	}else if(send_now == 2){
		
		var url = AJAX_PACKAGE+'?c=EnquiryRequest&m=no_send&request_id='+request_id;
		
		new Ajax.Request(url,
			{
				method: "get",
				onSuccess : function(transport){
			
					if(transport.responseText != ''){
						alert(transport.responseText);
					}else{
						$('send_again_result').show();
						$('send_again_result').update('Sorry you do not want us to resend this enquiry to a new travel agent.<br />We hope you return to our site soon.');
						new Effect.Shake('send_again_result');
					}
				}					
			}		
		);		

	}else{
		$('send_again_result').update('');		
	}
}

function fb_other(how_find){
	if(how_find == 7){
		new Effect.BlindDown('how_find_other_container');
	}else{
		new Effect.BlindUp('how_find_other_container');
	}
}

function checkReportAgent(){
	
	if($F('firstname') == ""){
		alert("Type your first name, please!");
		$('firstname').focus();
		return false;
	}else if($F('surname') == ""){
		alert("Type your surname, please!");
		$('surname').focus();
		return false;
	}else if(!isValidEmail($F('email'))){
		alert("Type a valid email address, please!");
		$('email').value = '';
		$('email').focus();
		return false;
	}else if(!isValidEmail($F('emailconfirm'))){
		alert("Confirm your email address, please!");
		$('emailconfirm').value = '';
		$('emailconfirm').focus();
		return false;
	}else if($F('email') != $F('emailconfirm')){
		alert('Re-type and confirm your email address, please!');
		$('email').value = '';
		$('emailconfirm').value = '';
		$('email').focus();
		return false;
	}else if($F('user_action') == ''){
		alert('Select your interaction with the agent, please!');
		$('user_action').focus();
		return false;
	}else if($F('rating_id') == ''){
		alert("Rate the agent, please!");
		$('rating_id').focus();
		return false;
	}else if($F('recommend_agent') == ''){
		alert('Define your recommendation preference on this agent, please!');
		$('recommend_agent').focus();
		return false;
	}else{
		return true;
	}
}

function destination_data_window(url){
	
	var left = (screen.availWidth - 650) / 2;
    var top  = (screen.availHeight - 400) / 2;	
	
	var dwin = window.open(url, 'destination_data_window', 'width=650,height=400,location=no,toolbar=no,resizable=yes,scrollbars=yes,directories=no,menubar=no,top='+top+',left='+left);

}

function switchCallData(cb_option){

	new Ajax.Request(
				AJAX_PACKAGE+'?c=Misc&m=eta_cb&callback='+cb_option,
				{
					method: 'get',
					
					onSuccess: function(transport){

						var menus = transport.responseText.evalJSON();
						
						$('cb_hours').update(menus[0]);
						$('cb_day').update(menus[1]);						
					}
					
				}
	);
	
}

function ph_ratings(destination_id){
	
	$('page_hotels_star_rating').update("<select><option>Any Star Rating</option></select>");
	$('page_hotels_available').update("<select><option></option></select>");	
	
	if(destination_id > 0){
	
		new Ajax.Updater(
				'page_hotels_star_rating',
				AJAX_PACKAGE+'?c=PageHotel&m=getRatingsToUpdateHotels&destination_id='+destination_id,
				{
					method: 'get'
				}
		);		
	}
}

function ph_get_available_hotels(){
	
	var destination_id = $('ph_destination_id').value;
	var rating = $('ph_rating').value;
	
	new Ajax.Updater(
				'page_hotels_available',
				AJAX_PACKAGE+'?c=PageHotel&m=getAvailableHotels&destination_id='+destination_id+'&rating='+rating,
				{
					method: 'get'
				}
	);			
	
}
