//**********************************************************************
// This script is used to manipulate the appearance of aggregated hotel
// data which has been pulled from Vignette and other sources.  Any page
// which uses this script must also include AEVCommons.js and
// jquery.aev.js.
//**********************************************************************

var hi_photoToolTip = null;
var hi_showLinkNum = 0;
var hi_showContentNum = 0;
var hi_expandLinkNum = 0;
var hi_expandContentNum = 0;
var hi_condenseContentNum = 0;



$(function() {
    
    //Load Trip Advisor
	if (hi_reducedTA == "true") {
		loadReducedTripAdvisor(hi_destHotelCode);
	}
	else {
		loadTripAdvisor(hi_destHotelCode);
	}
				

	//Load Google map
	if (hi_mapCoordinates != null && hi_mapCoordinates != undefined && hi_mapCoordinates != "") {
		$(window).load(function () {
			try {
				loadHotelMap("googleMap", hi_mapCoordinates, 320, 320);
			}
			catch (error) {
				$("#googleMap").html("<br/><br/><br/><span style='font-weight:bold; color:#FF6600;'>We're sorry!  Map could not be loaded for this property.</span>");
				$("#googleMap").css("height", "110px");
				$("#googleMap").css("border", "1px solid #FF6600");
			}
		});
	}
	else {
		$("#googleMap").html("<br/><br/><br/><span style='font-weight:bold; color:#FF6600;'>We're sorry!  No map is available for this property.</span>");
		$("#googleMap").css("height", "110px");
		$("#googleMap").css("border", "1px solid #FF6600");
	}
	
	
    //Load photo gallery
	if (hi_photoCount > 0) {
		setUpImage(Math.ceil(hi_photoCount / 8));
	}

	
	
	$(".showLink").each(
		function(i) {
			$(this).attr("id", "showLink" + hi_showLinkNum);
			hi_showLinkNum++;
    });
	
	
	
	$(".showContent").each(
		function(i) {
			$(this).attr("id", "showContent" + hi_showContentNum);
			hi_showContentNum++;
    });
	
	
	
	$(".expandLink").each(
		function(i) {
			$(this).attr("id", "expandLink" + hi_expandLinkNum);
			hi_expandLinkNum++;
    });
	
	
	
	$(".expandContent").each(
		function(i) {			
			$(this).attr("id", "expandContent" + hi_expandContentNum);
			hi_expandContentNum++;
    });
	
	
	
	$(".condenseContent").each(
		function(i) {
			$(this).attr("id", "condenseContent" + hi_condenseContentNum);			
			hi_condenseContentNum++;
    });
	
	
	
	$(".ratingImg").click(
        function(event){                  
        	popUp("/aev/pages/static/Ratings.html",600,450,"hotelRating","menubar=no,toolbar=no,resizable=0");
    });
	
	
	
	$(".showLink").click(
        function(event){
        	var linkNum = $(this).attr("id").substr(8);
        	$(this).html($(this).html() == "More" ? "Less" : "More");
        	$("#showContent" + linkNum).toggle();
    });
	
	
	
	$(".expandLink").click(
        function(event){
        	var linkNum = $(this).attr("id").substr(10);
        	$(this).html($(this).html() == "More" ? "Less" : "More");
        	$("#condenseContent" + linkNum).toggle();
        	$("#expandContent" + linkNum).toggle();
    });
    
});



function loadTripAdvisor(destHotelCode) {    
    var taContent = '<iframe src="' + TRIP_ADVISOR_URL + destHotelCode + '" width="240" height="320" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>';
    $("#tripAdvisor").html(taContent);
}



function loadReducedTripAdvisor(destHotelCode) {    
    var taContent = '<iframe src="' + REDUCED_TRIP_ADVISOR_URL + destHotelCode + '" width="240" height="130" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" style="border:2px solid #006699;"></iframe>';
    $("#tripAdvisor").html(taContent);
}
