/**
 * Cafe Atlantico jQuery Calls
 *
 */
$(document).ready(function(){
/**
 * Fix flash (youtube z-index problem)
 *
 */
	
	fix_flash();
	
/**
 * Menus - when mousover, raise them a little
 *
 */

	var menuOffset = 15;
	
	$('.menu').mouseenter(function(){
	    
		// over
		var originalTop = $(this).css("top").replace("px","");
		$(this).css("top", parseInt(originalTop.replace("px","")) - menuOffset)
	
	}).mouseleave(function(){
		
		// leave
		var originalTop = $(this).css("top").replace("px","");
		$(this).css("top", parseInt(originalTop.replace("px","")) + menuOffset)
		
	});


/**
 * Parties - if choose 12 or under (value 11) then display message / grey out submit
 *
 */
	$("#message").hide();
	$("#formPartiesSize").change(function() {
		var selectedPartySize = $("#formPartiesSize").val();
		if(selectedPartySize == 11)
		{
			$("#message").show();
			$("#formPartiesSubmit").hide();
		}
		else
		{
			$("#message").hide();
			$("#formPartiesSubmit").show();
		}
	});

/**
 * Navigation drop downs
 *
 */

	// dropdown jQuery
	$("#nav ul:not(.stay-visible)").hide();
	
	var config = {    
	     over: makeTall, // function = onMouseOver callback (REQUIRED)    
	     timeout: 1000, // number = milliseconds delay before onMouseOut    
	     out: makeShort // function = onMouseOut callback (REQUIRED)    
	};

	$("#nav li a").hoverIntent( config )
	
	function makeTall()
	{
		$(this).next(".sub").css('display', 'block'); 
	}
	
	function makeShort()
	{
		
	}
	
	// we only want to make short if not on #nav
	$("#nav").mouseleave(function() {
		$("#nav ul:not(.stay-visible)").hide();		
	});
	
	// when we mouseover a different item, kill all subs
	$("#nav li a.main").mouseover(function() {
		$("#nav ul:not(.stay-visible)").hide();		
	});


/**
 * Logo Scroll
 *
 */

	// init
	$("#logo").css('top', -10); 
	
	// on scroll
	$(window).bind('scroll', function()
	{
		var windowHeight = $(window).height();
		
		// how many pixels to top?
		var pixelTop = parseInt($(this).scrollTop());
		var offset = parseInt(-10);
		
		var total = pixelTop + offset;
		
		$("#logo").css('top', total); 
	});
	
/**
 * Open all external links in a new window
 *
 */
	
//	$("a[href^='http://']").not("a[href^='http://www.zaytinya.com/']").not("a[href^='http://www.zaytinya.com/']").attr("target","_blank");
	//$("a[href^='http://']").not("a[href^='http://php5.local.dev/']").not("a[href^='http://php5.local.dev/']").attr("target","_blank");
	$("a[href^='http://']").not("a[href^='http://www.cafeatlantico.com/']").not("a[href^='http://www.cafeatlantico.com/']").attr("target","_blank");
    
    $("a[href^='https://']").attr("target","_blank");
    $("#reservations").attr("target","_blank");
    $("#formContactJoin").attr("target","_blank");
    $("#formJoin").attr("target","_blank");

/**
 * Datepicker
 *
 */

	$('#formPartiesDate').datepicker({
		buttonImage: 'assets/images/icon-calendar.gif',
		buttonImageOnly: true,
		showOn : 'both',
		beforeShow: function(input, inst)
		{
			$("#panel-4 #ui-datepicker-div").addClass("test");
			inst.dpDiv.css({marginTop: '-80px !important', marginLeft: '0px !important'});
		}
	});	
	
	$('#formReservationsDate').datepicker({
		beforeShow: function(input, inst)
		{
			$("#panel-4 #ui-datepicker-div").addClass("test");
			inst.dpDiv.css({marginTop: '0px !important', marginLeft: '0px !important'});
		}
	});
	
});



