function initMenu() {
	/*$('#dropDown ul.topBlock').hide();*/
	$('#dropDown li a.topLink').click(function() {$(this).next().slideToggle('normal');});
}
$(document).ready(function() {
initMenu();
// lightbox
$("#airlinelink").colorbox({width:"80%", inline:true, href:"#inlineAirline"});

});
var prevHotel = 0;
function showDetail(hotelID)
{
	$("#hotelDeet"+prevHotel).hide();
	$("#hotelDeet"+hotelID).slideDown();
	prevHotel = hotelID;
}

function mouseoverCB(e)
{
  if (e.elementID != null)
  {
	//Cancel default action
	return true;
  }
}

function mouseoutCB(e)
{
  if (e.elementID != null)
  {
	//Cancel default action
	return true;
  }
}


var map = null;
window.onload = function() {
$('#hotelsDetail').html("");
    map = new VEMap('myMap');
    map.LoadMap(new VELatLong(29.946674, 90.067993), 14 ,'r' ,false);
    var layer = new VEShapeLayer();
    var veLayerSpec = new VEShapeSourceSpecification(VEDataType.VECollection, 'A8A9DA3572C8CF13!149', layer);
    map.ImportShapeLayerData(veLayerSpec, function() {
        var numShapes = layer.GetShapeCount();
        var s, n, icon, itemli, newinnerpart;
        for (var i = 0; i < numShapes; ++i) {
            s = layer.GetShapeByIndex(i);
			var description = s.GetDescription();
			var title = s.GetTitle();
			var sout = title.substr(title.length-8);
			sout = sout.toLowerCase();
			if (sout == "sold out") { title = title.substr(0,title.length-8)+"<font style='color:#F00'>SOLD OUT</font>"; }
			var hotelPhoto = s.GetPhotoURL();
			description = description.split(";"); 
			var detailhead = "";
			var detailbody = "";
			var hoteladd = "";
			var mainline = "";
			var detailContent = "";
			var detailbreak = "";
			var hotelurl = s.GetMoreInfoURL();
			var fax = "";
			for (x = 0; x < description.length; x++)
			{
				if (x == 0) {
					hoteladd = description[x].split("<br>"); 
					hoteladd = hoteladd[0];
				} else if (x == 1) {
					mainline = description[x].split("<br>"); 
					mainline = mainline[1];
				} else if (x == 2) {
					fax = description[x];
				} else {
					descriptionpart = description[x].split(":"); 
					detailhead += "<th>"+descriptionpart[0]+"</th>";
					detailbody += "<td>"+descriptionpart[1]+"</td>";
					detailbreak = descriptionpart[0].split("<br>"); 
					detailContent += "<div style='clear:both'><span class='colOne'>"+detailbreak[1]+"</span><span class='colTwo'>"+descriptionpart[1]+"</span></div>";
				}
			}

			var details = "";
			if (i == 0) {
				details = "<div id='hotelDeet"+i+"' class='hoteldetails' style='width: 200px;'><img src='"+hotelPhoto+"' width='130' style='margin:0px; padding:0px' /><p style='margin:0px; padding:0px'><strong>"+title+"</strong><br>"+hoteladd+"</p><p style='margin:0px; padding:0px'><a href='"+hotelurl+"' target='_blank'>Website</a><br>"+mainline+fax+detailContent+"</p></div>";
			} else {
				details = "<div id='hotelDeet"+i+"' style='display:none' class='hoteldetails'><img src='"+hotelPhoto+"' width='160' style='margin:0px; padding:0px' /><p style='margin:0px; padding:0px'><strong>"+title+"</strong><br>"+hoteladd+"</p><p style='margin:0px; padding:0px'><a href='"+hotelurl+"' target='_blank'>Website</a><br>"+mainline+fax+detailContent+"</p></div>";
			}
			
			$('#hotelsDetail').append(details);
			
            n = i + 1;
            if (i == 0) {
                icon = "<img src='/p/TENA10/resources/pin_hotel.gif' id='pinhotel"+i+"' class='pinposition'><span class='pinText pinVenue'>" + n + "</span>";
				itemli = "<span class='venue'></span><a href='javascript:showDetail("+i+")'>" + title + "</a>";
				$('#hotels').append( $('<li id="hotel'+i+'"><a name="hotelpos'+i+'" id="hotelpos'+i+'"></a>'+itemli+'</li>') );
            } else {
                icon = "<img src='/p/TENA10/resources/pin_number.gif' id='pinhotel"+i+"' class='pinposition'><span class='pinText'>" + n + "</span>";
				itemli = "<span>" + n + "</span><a href='javascript:showDetail("+i+")'>" + title + "</a>";
				$('#hotels').append( $('<li id="hotel'+i+'"><a name="hotelpos'+i+'" id="hotelpos'+i+'"></a>'+itemli+'</li>') );
			}
			//newinnerpart.inject(hotelList);
            s.SetCustomIcon(icon);
        }
		
		$("#hotels li:even").addClass("altRow");
        setMapHovers();
        setListHovers();
		map.AttachEvent("onmouseover", mouseoverCB);
		map.AttachEvent("onmouseout", mouseoutCB);
        map.SetZoomLevel(14);
    }, true);

}
var prevHotel = 0;
function setMapHovers() {
	$('#myMap a.VEAPI_Pushpin').hover(function() {
		var hotelID = $(this).find("span").html();
		if (hotelID == 1) {
			$("#hotel"+(hotelID-1)).find("span").addClass('venueover');
			$("#pinhotel"+(hotelID-1)).attr("src","/p/TENA10/resources/pin_hotel_over.gif");
		} else {
			$("#hotel"+(hotelID-1)).find("span").addClass('over');
			$("#pinhotel"+(hotelID-1)).attr("src","/p/TENA10/resources/pin_number_over.gif");
		}
		//$(this).scrollTo($("#hotelpos"+(hotelID-1)),200);
		$("#hotelDeet"+prevHotel).hide();
		$("#hotelDeet"+(hotelID-1)).show();
		prevHotel = hotelID-1;
	}, function() {
		var hotelID = $(this).find("span").html();
		if (hotelID == 1) {
			$("#hotel"+(hotelID-1)).find("span").removeClass('venueover');
			$("#pinhotel"+(hotelID-1)).attr("src","/p/TENA10/resources/pin_hotel.gif");
		} else {
			$("#hotel"+(hotelID-1)).find("span").removeClass('over');
			$("#pinhotel"+(hotelID-1)).attr("src","/p/TENA10/resources/pin_number.gif");
		}
	});
	
	//.each(function() { alert($(this).html()); });
	/*
    $('#myMap a.VEAPI_Pushpin').each(function(myPlotedPoint, index) {
        if (index != 0) {
            myPlotedPoint.addEvent('mouseenter', function(event) {
                myPlotedPoint.getElement('img').src = '/p/TENA10/resources/pin_hotel.gif';
                myPlotedPoint.getElement('span.pinText').addClass('pinTextOn');
            });
            myPlotedPoint.addEvent('mouseleave', function(event) {
                myPlotedPoint.getElement('img').src = '/p/TENA10/resources/pin_hotel.gif';
                myPlotedPoint.getElement('span.pinText').removeClass('pinTextOn');
            });
        }
    });*/
}

function setListHovers() {
    $('#hotels li').hover(function() {
		var hotelID = $(this).find("span").html();
		if (hotelID == "") {
			$("#hotel0").find("span").addClass('venueover');
			$("#pinhotel0").attr("src","/p/TENA10/resources/pin_hotel_over.gif");
			$("#hotelDeet"+prevHotel).hide();
			$("#hotelDeet0").show();
			prevHotel = 0;
		} else {
			$("#hotel"+(hotelID-1)).find("span").addClass('over');
			$("#pinhotel"+(hotelID-1)).attr("src","/p/TENA10/resources/pin_number_over.gif");
			$("#hotelDeet"+prevHotel).hide();
			$("#hotelDeet"+(hotelID-1)).show();
			prevHotel = hotelID-1;
		}
	}, function() {
		var hotelID = $(this).find("span").html();
		if (hotelID == "") {
			$("#hotel0").find("span").removeClass('venueover');
			$("#pinhotel0").attr("src","/p/TENA10/resources/pin_hotel.gif");
		} else {
			$("#hotel"+(hotelID-1)).find("span").removeClass('over');
			$("#pinhotel"+(hotelID-1)).attr("src","/p/TENA10/resources/pin_number.gif");
		}
	});
}




