/*jQuery().ready(function(){
	jQuery('#subnav').accordion({ 
			active: 0, 
			header: '.head', 
			event: 'click',
			fillSpace: false,
			animated: 'easeslide' 
		});
	
});

jQuery().ready(function(){
	jQuery('#subnav').accordion({ 
			active: 0, 
			header: '.head', 
			event: 'click',
			fillSpace: false,
			animated: 'easeslide' 
		});
	//$("ul#subnav li a").showContent();
});

*/
var currentPicker = "";

jQuery.fn.showContent = function() {
	return this.each(function(){
		var caller = this;
		$(caller).click(function (event) {
			alert()
			if($(caller).hasClass("current")){}else{
				show_div(caller.id);
			}
			return false;
		})
	})
}

function goToByScroll(id){
     	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}
function handleAccordion(which) {
    var index = ($('a#'+which).parent().parent().attr('id') == 'subnav') ? $('a#'+which).parent().index() : $('a#'+which).parent().parent().index();
    $( "#subnav" ).accordion( "option", "active", index);
}
function show_div(which) {
	if(which && which!="subnav"){
		$('#content div.current').removeClass('current').addClass("hidden");
		var el = $('div#'+which);
		if(el.length==1){
			el.toggleClass("hidden").addClass("current");
		}
	}
	_gaq.push(['_trackPageview', '/content/'+which]);
	return false;
}
function killIt(e){
	e.stopPropagation();
}
$(document).ready(function(){
	$("#subnav").accordion({
		header: '.head',
		autoHeight: false,
		animated: 'easeslide'
	});
	
	//$("ul#subnav li a.subnavClick").showContent();
	$("#book_now").click(function(e) {
		//$("#resform").toggle('slow');
		//e.stopPropagation();
	});
	$("body").click(function(e){
		//$("#resform").hide('slow');
		if (currentPicker !="") {
		    var targetClass = $(e.target).attr('class');
		    if(targetClass.indexOf("ui-") < 0) {
		        $("#datepicker-"+currentPicker).hide("slow");
    		    currentPicker = "";
		    }
		} 
	});
	$("#resform").click(function(e){
		e.stopPropagation();
	});
	
	$(".datepickerUI").datepicker({
		onSelect: function(value, date) {
			$("input[name='"+currentPicker+"']").val(value);
			$("#datepicker-"+currentPicker).hide();
			currentPicker = "";
		}
	});
	$(".datepicker").click(function(e){
	    if (currentPicker == "") {
	        currentPicker = $(this).attr('name');
    		$("#datepicker-"+currentPicker).show("fast");
    		e.stopPropagation();
	    }
	});
	$('a.subnavClick').click(function(event){
		if($(event.target).hasClass("current")){}else{
			show_div(event.target.id);
		}
	});
	$('a.book_now').click(function(){
	   var clicked = $(this).attr('class').replace('book_now ','');
	   if (clicked != '') {
	       _gaq.push(['_trackPageview', '/reservations/'+clicked]);
       }
	});
	$('a.msg').click(function(){
	    $('div.current').removeClass('current').addClass('hidden');
	    $('div#msg').removeClass('hidden').addClass('current');
	})
});
