$(function() {

	// Sifr rules
	
	
 	$('#sausalito-california-restaurants #content-wrapper h1').sifr(
		{ strSWF: 'flash/humanist521bt-light-text.swf', strColor: '#344765', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strCase: 'upper' },
		{ expressInstall: true }
	);

	$('#content-wrapper h1').sifr(
		{ strSWF: 'flash/humanist521bt-light-text.swf', strColor: '#ffffff', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strCase: 'upper' },
		{ expressInstall: true }
	);
	
	$(' h3.push').sifr(
		{ strSWF: 'flash/humanist521bt-italic-text.swf', strColor: '#ffffff', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strCase: 'upper' },
		{ expressInstall: true }
	);

	$('#interior-push-wrapper h3').sifr(
		{ strSWF: 'flash/humanist521bt-italic-text.swf', strColor: '#295073', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strCase: 'upper' },
		{ expressInstall: true }
	);

	$('#push-email h3').sifr(
		{ strSWF: 'flash/humanist521bt-text.swf', strColor: '#778bab', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strCase: 'upper' },
		{ expressInstall: true }
	);

	// Home page Flash masthead
	$("body.home div#masthead-flash").flash({
		swf:"/flash/homepage-masthead.swf",
		width:670,
		height:417,
		params:{
			allowscriptaccess:"always",
			wmode:"transparent",
			flashvars:{
				xmlPath:'/flash/xml/home-masthead.xml'
			}
		}
	});

	$('div#photo-gallery').flash({
	    swf:"flash/photo-gallery.swf",
	    width:600,
	    height:451,
		params:{
			allowscriptaccess:"always",
			wmode:"transparent",
			flashvars:{
				imagesXML:'/flash/xml/images.xml'
			}
		}
	});

	// Remove xslt generated pipe 'bullet' before privacy policy link
	$('.footer-links span:first').each(function() {
		$(this).remove();
	});

	// Variable content min-height
	$('#sidebar').each(function() {
		var sidebarHeight = $(this).height();
		var minHeight = sidebarHeight + 20;
		$('#content').css('min-height', minHeight);
	});
	
	// Remove Sidebar nav wrapper if empty
	if($.trim($("#sidebar-nav-wrapper").text()) == "") {
		  $("#sidebar-nav-wrapper").remove();
		  //$("#sidebar-nav-wrapper").css('background-color','#ffffff');
	}
	
	// Clear field on user click
	$('#push-email').each(function() {
		var defaultVal = $('#email').val();
		$('#email').click(function() {
			if ($(this).val() == defaultVal)
				$(this).val('').css('background-color','#dde8f8'); // add css function needed for IE7
		}); 
	});
	
	// Booking Console animation
	$('#booking-console-wrapper').each(function() {
		$('#booking-console').addClass('inactive');
		$('#reservations-console .buttons').hide();
		
		$('.arrival-wrapper').click(function() {
			$(this).parent().parent().parent().animate({marginLeft:'0'},'1000', function() {
				$('#booking-console').removeClass('inactive');
				$('.ui-datepicker-trigger-inactive').remove();
				$('#reservations-console .buttons').show();
				$('#reservations-console').initializeForm();
				$('#arrival').focus();
			});

		});
	});

	// Home push cycle
	$('div#jcycle-home-push').each(function() { $(this).cycle({ 
		fx: 'scrollHorz', 
		after: function(){
            $('h3.push').sifr(
            	{ strSWF: 'flash/humanist521bt-italic-text.swf', strColor: '#295073', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strCase: 'upper' },
				{ expressInstall: true }
            );
        },
        //delay: 950,
		speed:  1000, 
		timeout: 0, 
		next:   '#next-push', 
		cleartypeNoBg:true
		});
	});	
	
	//Bing map
	var openFn=function(hash){
		hash.w.show();
		var leftPos = ($(window).width()-$('#map-jqmodal').width())/2;
		var topPos = Math.max($(window).scrollTop(),parseInt($('#map-jqmodal').css('top')));
		$('#map-jqmodal').css({left:leftPos,top:topPos});
		$('#map').msnMap({listView:true});
	};
	var hideFn=function(hash){
		hash.w.hide()
		hash.o.remove();
		$('.places').remove();
	};
	$('#map-jqmodal').jqm({trigger:'#btn-msnmap', onShow: openFn, onHide: hideFn});

});
