$(function() {
  //If home show drawers
  if(is_home()) {
    $('#california-modern').append('<ul style="display: none; visibility: hidden;"><li><a href="/california-modern"></a></li></ul>');
    $('#ocean-terrace').append('<ul style="display: none; visibility: hidden;"><li><a href="/ocean-terrace"></a></li></ul>');
    $('#georges-bar').append('<ul style="display: none; visibility: hidden;"><li><a href="/georges-bar"></a></li></ul>');
	$('body').addClass('homepage');
  }
  //Slideshow
  $('#slideshow').cycle({ fx: 'fade', timeout: 4000, pause: 1, random: 1  });
  $('#slideshow p:first').addClass('first').show();
  //Add classes to all li
  $('ul li:first-child').addClass('first');
  $('ul li:last-child').addClass('last');

  //Add dropdown footers
  $('#chef-trey ul li:last').append('<div class="dropdown-bottom"></div>');
  $('#group-events ul li:last').append('<div class="dropdown-bottom"></div>');

  //Reservations drawer
  $('#reservations').append($('<ul />').attr('style','display: none; visibility: hidden;').html($("#reservations-sub").html()));
  $('#reservations ul').wrapInner('<div class="res-content" />');

  //Navbar
  $('ul.sf-menu').superfish({
    delay:       1000,                          	// one second delay on mouseout
    animation:   {opacity:'show',height:'show'},	// fade-in and slide-down animation
    speed:       'fast',                        	// faster animation speed
    autoArrows:  false                         		// disable generation of arrow mark-up
  });
	$('#main a').each(function() {
		var a = new RegExp('/' + window.location.host + '/');
		if(!a.test(this.href)) {
			$(this).click(function(event) {
				event.preventDefault();
				event.stopPropagation();
				window.open(this.href, '_blank');
			});
		}
	});

  //Slideshow Within Content Areas
        if($('.sub-slideshow-small div').length) { 
			$('.sub-slideshow-small').wrap('<div class="sub-slideshow-small-container" />');
            $('.sub-slideshow-small').after('<div class=\"sub-slideshow-small-nav\"><a href=\"#\" class=\"sub-slideshow-small-prev\">Previous Image</a><a href=\"#\" class=\"sub-slideshow-small-next\">Next Image</a></div>');
			$('.sub-slideshow-small').cycle({ 
                height: '259', width: '388',
                fx: 'fade', 
				random:  0, 
                timeout: 0, 
                prev: '.sub-slideshow-small-prev', 
                next: '.sub-slideshow-small-next'
            });
			$('.sub-slideshow-small').fadeIn();
        }
		
  //qtip errors
  $("ul.error_list, ul.error").hide().each(function(){
    $(this).parents('li, td').qtip({
      content: $(this).html(),
      position: {
        adjust: {y: -0, x:-5}, my: 'left middle', at: 'right middle',
        target: $(this).siblings(":input")
      },
      show: {ready: true},
      hide: {
        target: $(this).siblings(":input"),
        event: 'change'
      },
      style: { classes: 'ui-tooltip-red ui-tooltip-shadow ui-tooltip-rounded' }
    });
  });

});


function is_home()
{
  return location.pathname.replace('front_dev.php','') =="/";
}

