// Onload When Document Ready
$(document).ready(function() {
  $('a[rel=external]').attr('target', '_blank');
  $('.equalize').equalHeights('true');
  $("img[src$=png],.pngfix").pngfix();
  //$(document).stickyfooter();
//  $("div#nav > ul > li:not(:last),div#subnav ul li:not(:last), ul#footernav li:not(:last)").append("<span class=\"spacer\">|</span>");
  $('.photocap > img[title]').each(function(){$(this).after("<p>"+this.title+"</p>").parent().css("width", $(this).width());});
  $('a.popup').live('click',function(){var data=$(this).metadata();var name=(data.name==null)?'popup':data.name;w=screen.availWidth;h=screen.availHeight;var leftPos=(w-data.width)/2,topPos=(h-data.height)/2;window.open($(this).attr('href'),name,'width='+data.width+',height='+data.height+',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes,top='+topPos+',left='+leftPos);return false;});
  
  if($('.rotate').length){
	  $('.rotate').cycle({
	  	timeout: 6000
	  });
	}
	
	if($('.image').length){
		$('.image').lightbox();			
	}
  
	var disabledDays = ["11-24-2011", "12-3-2011","12-24-2011","12-26-2011","12-31-2011","1-2-2012","3-2-2012","3-20-2012"];
	function disableAllTheseDays(date) {
    var m = date.getMonth(), d = date.getDate(), y = date.getFullYear(), day = date.getDay();
    for (i = 0; i < disabledDays.length; i++) {
      if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1) {
          return [false];
	      } else if (day == 0) {
	      	return [false];
	      }
    }
    return [true];
	}

	$('#resDate').datepicker({
		minDate: 0,
		beforeShowDay: disableAllTheseDays,
 		beforeShow: function() {
     setTimeout(function() {
       $(".ui-datepicker").css("z-index", 99);
     }, 10); 
    }
	});
	
	$('#resDateN').datepicker({
		minDate: 1,
		beforeShowDay: disableAllTheseDays,
 		beforeShow: function() {
     setTimeout(function() {
       $(".ui-datepicker").css("z-index", 99);
     }, 10); 
    }
	});


	if($('#reservation').length){
		$('#reservation').validate();			
	}
	
	if($('#contact').length){
		$('#contact').validate();			
	}

	if($('#eventRSVP').length){
		$('#eventRSVP').validate();			
	}
	
	
	
	
  $('ul.sf-menu').superfish({
    autoArrows:  false,
    delay: 500,
    dropShadows: false
  });	
	
});
