jQuery(document).ready(function($){
	var contentDivs = new Array('hotelDescription', 'hotelAmenities', 'hotelPhotos', 'hotelMap', 'hotelPoi', 'hotelReviews');
	for(var i = 1; i < contentDivs.length; i++)
		$('#'+contentDivs[i]+'Body').hide();
	
	var currentSelected = $("#hotelDescription");
	if(window.location.href.indexOf('#') > 0) {
    	if(window.location.href.substring(window.location.href.indexOf('#')).indexOf('map') > 0)
    		changeInformation($("#hotelMap"));
    	else if(window.location.href.substring(window.location.href.indexOf('#')).indexOf('amenities') > 0)
    		changeInformation($("#hotelAmenities"));
    	else if(window.location.href.substring(window.location.href.indexOf('#')).indexOf('photos') > 0)
    		changeInformation($("#hotelPhotos")); 
    	else if(window.location.href.substring(window.location.href.indexOf('#')).indexOf('reviews') > 0 && $("#hotelReviews").length > 0)
    		changeInformation($("#hotelReviews"));
	} 	
	function changeInformation(head) {
		currentSelected.toggleClass('ihs8_17');
		currentSelected.toggleClass('tabSelected');
		head.toggleClass('ihs8_17');		
		head.toggleClass('tabSelected');
		$('#'+currentSelected.attr("id")+'Body').hide();
		$('#'+head.attr("id")+'Body').show();
		currentSelected = head;
	}
	for(var i = 0; i < contentDivs.length; i++)
		$('#'+contentDivs[i]).click(function () {
			changeInformation($(this));
		});
	
	$("#topMapLink").click(function () {
		changeInformation($("#hotelMap"));
		return false;
	});

	$("#topPhotoLink").click(function () {
		changeInformation($("#hotelPhotos"));
		return false;
	});
	
	$("#getRates").submit(function() {
		if($("#arrivalDateDisplay").val() == "" || $("#arrivalDateDisplay").val() == "mm/dd/yyyy") {
			alert("Please fill in your travel dates in order to view rates");
			$("#arrivalDateDisplay").focus();
			return false;
		} else if($("#departureDateDisplay").val() == "" || $("#departureDateDisplay").val() == "mm/dd/yyyy") {
			alert("Please fill in your travel dates in order to view rates");
			$("#departureDateDisplay").focus();
			return false;
		} else {
			$("#normalView").hide();
			$("#processingView").show();
			window.scroll(0, 0);
		}
	});
	$("#reviews a[target=_blank]").click(function () {
		var err = {errorCode: "javaScriptException",
				javaClassname: "javaScriptException",
				message: "Clicked Review Link"};
		try {
			ihs.util.ErrorHandler.logError(err, 'review()', null);
		} catch(err) {}
	});
});