//Request a Quote Animation (UI)
$(document).ready(function(){	
	
if(! ($.browser.msie && ($.browser.version == "6.0")) ) {

	$('.hotel a.zoom').each(function(){ $(this).append('<span class="png"></span>') });
	$('.hotel a.zoom').hover(
						function(){ $(this).find('span').slideDown(); },
						function(){ $(this).find('span').slideUp() }
	);

}
	$('#gallery ul li').hover(
		   function() {
            $(this).animate({ marginTop: 5 }, 250);
			$(this).children().animate({ height:48 }, 250);
			//$('#gallery ul li').not(this).animate({ opacity: 0.75 }, 250);
        }, function() {
            $(this).animate({ marginTop: 10 }, 150);
			$(this).children().animate({ height:38 }, 250);
			//$('#gallery ul li').not(this).animate({ opacity: 1 }, 250);
    	}
	);
	
	//$('#gallery ul li').mouseout(function(){ $(this).animate({top:2}), 50});
	
			 
	togUp = function(e) {e.preventDefault();var togID = $(this).attr('id') + '_text';$('#'+togID).slideDown();window.location.hash = $(this).attr('href');};
	togDown = function(e) {e.preventDefault();var togID = $(this).attr('id') + '_text';$('#'+togID).slideUp();window.location.hash = '#_';};
	


		// CHECK IF URL ALREADY HAS A FRAGMENT...IF SO OPEN THE RELEVANT TOGGEL CONTENT
		if (window.location.hash) {

			


			// CHECK IF THE TARGET ID EXISTS THEN OPEN CONTENT...ELSE DO NOTHING
			// IF A MACTHING ID EXISTS - OPEN IT
			if ($('#tog_'+window.location.hash.substring(1)+'_text')) {
				
				$('#tog_'+window.location.hash.substring(1)+'_text').slideDown();
				
				//$('#tog_'+window.location.hash.substring(1)).click(function(){
				//	$('#tog_'+window.location.hash.substring(1)+'_text').slideUp();
				//});
			}
		}

		$(".toggle").toggle(
			togUp,
			togDown
		);
		
$(".packcontent").each(function(){$(this).addClass("closed")});$(".showpack").click(function(e){e.preventDefault();var showID = $(this).attr('id') + '_text'; $(".packcontent.opened").not('#'+showID).each(function(){$(this).slideUp().removeClass("opened").addClass("closed");});if ($('#'+showID).hasClass("opened")){$('#'+showID).slideUp().removeClass("opened").addClass("closed");}else{$('#'+showID).slideDown().removeClass("closed").addClass("opened");window.location.hash = $(this).attr('href');}});

	// DYNAMIC FLOATER
	// BUILD THE MENU
	$('.hotel h1 span').each(function(){
		$('#hotel_menu ul').append('<li><a href="#" class="scrollTo" id="' + $(this).html() + '" >' + $(this).html() + '</a></li>')
	})
		$('#hotel_menu ul').append('<li><a href="#" id="totop" >back to top</a></li>')
	
	// RESET RIGHT POSITION TO SUIT BROWSER SIZE
	var cOffset = $('#container').offset();
	$('#hotel_menu').css('left', cOffset.left+5);	
	
	//alert(cOffset.left);
		
	var fadeSpeed = 250, fadeTo = 0.85, topDistance = 150;
	var topbarME = function() { $("#hotel_menu").fadeTo(fadeSpeed,0); }, 
		topbarML = function() { $("#hotel_menu").fadeTo(fadeSpeed,fadeTo); };
	var inside = false;
		// IF RESIZE, RESET RIGHT POSITION AGAIN WITH ANIMATION
		//$(window).bind("resize", resizeWindow);
		//function resizeWindow( e ) {
		//	var cOffset = $('#container').offset();
		//	$('#hotel_menu').animate({opacity: 0.2}, 150)
		//					.animate({left: cOffset.left+5, opacity: 1}, 300);
		//alert(cOffset.left);
		//}
	
	$(window).scroll(function() {
		position = $(window).scrollTop();
		if(position > topDistance && !inside) {
		topbarML();
		$("#hotel_menu").bind("mouseleave",topbarML);
		inside = true;
		}
		else if (position < topDistance){
		topbarME();
		$("#hotel_menu").unbind("mouseenter",topbarME);
		$("#hotel_menu").unbind("mouseleave",topbarML);
		inside = false;
		}
	});
	
	$('.scrollTo').click(function(e) { 
		var secID = $(this).attr('id');
		var offset = $('#sec_'+ secID).offset();
		e.preventDefault();
		$.scrollTo((offset.top-50),500); 
		$('.viewing').removeClass('viewing');
		$('#sec_'+secID).addClass('viewing');
	});
	
	$('#totop').click(function(e) { e.preventDefault();$.scrollTo(0,400); });
		
});

// END
//
