$(function() {	
		   
	$('#modal-wrapper').jqm({closeClass:'jqmClose'}).jqmShow();	
	if ($("body").is(".home")) {
		$("div#masthead-wrapper").flash(
			{src:"flash/homepage.swf",
			 width:721,
			 height:315,
			 wmode:"transparent",
			 quality:"high"},
			 {version:"8"}
		);
	}
	//$("a").click(function(){return false;});


	// intPadding array order is: left, top, right, bottom - must match css for corresponding element
		$('div#content-body p').sifr(
		{ strSWF: 'flash/palatino-linotype.swf', strColor: '#2d754b', strLinkColor: '#2d754b', strHoverColor: '#2d754b', strWmode: 'transparent', strCase: 'normal' },
		{ expressInstall: true }
	);
	

	// Adds hover class for IE and animation for drop down nav - remove if not needed
	/*$("ul#nav-primary li").hover(
        function(){ $("ul", this).fadeIn("fast"); }, 
        function() { } 
    );*/
    //if (document.all) {
        $("ul#nav-primary li").hoverClass("over");
		$("ul#nav-primary li ul li").hoverClass("over");
    //}

	//PNG fix for IE
	$('.png-bg-fix').ifixpng();

    $('#survey').each(function() {
	// since we cant edit the markup directly.. 
	var first = $('div:first', this),
	    firstLabel = $('<div class="label-first survey-headings"><strong>Prior to your stay:</strong><div class="labels"><label class="expectations">Exceeded Expectations</label><label class="not-expectations">Did Not Meet Expectations</label></div></div>'),
	    secondSet = $('input:text:eq(0)').parents('.field').next(),
	    secondLabel = $('<div class="label-second survey-headings"><strong>During your stay:</strong><div class="labels"><label class="expectations">Exceeded Expectations</label><label class="not-expectations">Did Not Meet Expectations</label></div></div>'),
		/*
		<div class="labels">
		<label class="label-location">Location</label>\
		<label class="label-eco">Eco</label>\
		<label class="label-prince">Prince</label>\
		<label class="label-osteria">Osteria</label>\
		<label class="label-terra">Hotel Terra</label>
		</div>) */
	    thirdSet = $('#div_3328bdf9a4b9504b9398284244fe97c2'),
	    thirdLabel = $('<div class="label-third survey-headings"><strong>Reflecting on your stay:</strong><div class="labels"><label class="expectations">Exceeded Expectations</label><label class="not-expectations">Did Not Meet Expectations</label></div></div>');

	    $(first).before(firstLabel);
	    $(secondSet).after(secondLabel);
	    $(thirdSet).before(thirdLabel)

	    $('input.button', this).wrap('<div class="button"></div>');
    });

$('ul#update-items li a').hover(function(){
			$('ul#update-items li div.update-popup').hide();
			elemPos = this;
			$(this).parent().children('div.update-popup').show();
		},function(){
			$('ul#update-items li div.update-popup').hide();
		});

 		$('#mycarousel').jcarousel({
			auto: 3,
			scroll: 1,
			wrap: 'last',
			initCallback: mycarousel_initCallback
		});
		
$('.follow-link').initializeFollowing();


	//MSN Map
	var openFn=function(hash){
		hash.w.show();
		var difference = $(window).width() - $('#msnmap-wrapper').width();
		difference = difference / 2;
		$('#msnmap-wrapper').css({left:difference+275,top:$(window).scrollTop()+10});
		$('#map').msnMap({listView:true,hotelOnly:true});
		setTimeout(function() {
			$('.place:eq(0) .name').click();
		}, 500);
	};
	var hideFn=function(hash){
		hash.w.hide()
		hash.o.remove();
		$('.places').remove();
	};
	$("#view-map-btn").each(function() {
		$('#msnmap-wrapper').jqm({trigger:'#view-map-btn', onShow: openFn, onHide: hideFn});
	});

});

$.fn.initializeFollowing = function() {
	return this.each(function() {
		$('.follow-link').live('click',function(event) {
			event.preventDefault();
			$('.follow-panel').hide();
			$(this).siblings('.follow-panel').css('display','inline');
		});
		$('.follow-close').live('click',function(event){
			event.preventDefault();
			$(this).parent().slideUp('fast');
		});
	});
};

// Function to add/remove "over" class for drop down nav - remove if not needed
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};   

function mycarousel_initCallback(carousel){
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};
