$(document).ready(function() {

/* VENUE FINDER - FILTERS HIDE when no search results */
if ($(".results-container").size() == 0) {
	$("#map-bottom").css("background-image", "url('/assets/images/venue/map-bottom-without-arrow.png')");
}


var windowHeight = $(window).height();
var windowWidth = $(window).width();

var documentHeight = $(document).height();
var documentWidth = $(document).width();

if ($('#home-page').size()>0) {
	$('.tag').delay(1000).animate({
		'top':'20px'
	}, 1000, 'easeOutBack');
	$('#meal-one').delay(1000).animate({
		'top':'-210px'
	}, 1000, 'easeOutBack');

	$('#meal-two').delay(1250).animate({
		'top':'-210px'
	}, 1000, 'easeOutBack');

	$('#meal-three').delay(1500).animate({
		'top':'-210px'
	}, 1000, 'easeOutBack');

/*	setTimeout(function(){
		$('#meal-one').delay(1000).animate({
			'top':'-460px'
		}, 1000, 'easeInBack');

		$('#meal-two').delay(1250).animate({
			'top':'-663px'
		}, 1000, 'easeInBack');

		$('#meal-three').delay(1500).animate({
			'top':'-519px'
		}, 1000, 'easeInBack');

		$('#light-three').delay(1500).animate({
			'top':'-210px'
		}, 1000, 'easeOutBack');
		$('#light-four').delay(2000).animate({
			'top':'-210px'
		}, 1000, 'easeOutBack');
		$('#light-two').delay(1750).animate({
			'top':'-210px'
		}, 1000, 'easeOutBack');
	}, 2000)
*/};

if ($('#food-page').size() < 1 && $('#drinks-page').size() < 1) {

	function mainWrap() {
		
		//console.log($(window).width());
		if ($(window).width()>1300) {
			$('#main').width($(window).width() - $('#left-feature').width());
			$('#main').addClass('widescreen');
		} else {
				$('#main').removeClass('widescreen');
				$('#main').width(740);
		};
		
		if($(window).width() < 992) {
			$('#main-wrap').css('width','992px');
		} else {
			$('#main-wrap').css('width','auto');
		}
	}
	//hide all elements that have a class of column
	//if div#main has a class of widescreen then hide all row classes and show all column classes
	function altLayout() {
		if ($('#main').hasClass('widescreen')) {
				
				$('#links-quick-left').removeClass('quick-left');
				$('#links-quick-center').removeClass('quick-center');
				$('#links-quick-left, #links-quick-center').addClass('quick-right');
			} else {
				
				$('#links-quick-left, #links-quick-center').removeClass('quick-right');				
				$('#links-quick-left').addClass('quick-left');
				$('#links-quick-center').addClass('quick-center');
		};
	}

	mainWrap();
	altLayout();
	$(window).bind('resize', mainWrap);
	$(window).bind('resize', altLayout);
};



/*$('#left-feature').css({
	height: mainWrapHeight + 'px'
});*/

//FRESH TALENT SIDEBAR
	var slideOut = $('.latest-talent-body').width();

	$('#latest-talent').css({left: '-650px'});
	$('#latest-talent').ready(function(){
		$('#latest-talent').delay(500).animate({left: '-'+ slideOut + 'px'}, 1000, 'easeOutElastic');
	});

	var talenttab = 0;
	
	$('#latest-talent-tab').click(function () {
		if (talenttab == 0) {
			$('#latest-talent').stop(true,true).animate({left: '0px'}, 1000, 'easeInOutQuint');
			talenttab = 1;
		} else {
			$('#latest-talent').stop(true,true).animate({left: '-'+ slideOut + 'px'}, 1000, 'easeInOutQuint');
			talenttab = 0;
		}
	});
	

//VENUE ACTIVITY TICKER

var totliHeight = 0;

function getliHeight()
{
	$('#venue-activity ul li').each(function()
	{
		totliHeight += $(this).height();
	});
	
	return totliHeight;
}

function adjustHight() {
	var liFirst = $('#venue-activity li:first').height();
	
	var height = getliHeight();
	
	var left_height = $('#left-feature').height();
	
	$('#left-feature').height(left_height - (height - liFirst));
	
	$('#venue-activity').animate({'height': (liFirst + 40) + 'px'});
	return liFirst;
}

var venueActivity = $('#venue-activity li').height();

if ($('#venue-activity li').length != 0) {
	var activityMarginBott = parseInt($('#venue-activity li').css('margin-bottom').replace('px',''));
}
var venueActivityCount = $('#venue-activity li').size();

adjustHight();
$('#venue-activity li').not(":first").fadeTo(500, 0.0);

var liHeight = 0;
$('#venue-activity li').each(function(){
	liHeight += $(this).height() + activityMarginBott;
});

var ticker = 0;

$('.more-less').click(function(e) {
	e.preventDefault();
	$(this).blur();
	if (ticker == 0) {
		$(this).html("View Less");
		$("#venue-activity li").fadeTo(500, 1.0);
		$('#venue-activity').animate({
			'height': (liHeight + 40) + 'px'
		},1000);
		
		ticker = 1;
		$("div.activity-nav").fadeOut(500);
		
	} else {
		$(this).html("View All");
		$('#venue-activity li').not(":first").fadeTo(500, 0.0);
		$('#venue-activity').animate({
			'height': ($('#venue-activity li:first').height() + 40) + 'px'
		},1000);
		
		ticker = 0;
		$("div.activity-nav").fadeIn(500);
	}
});

$("#next-activity").click(function(e) {
	e.preventDefault();
	$(this).blur();
	$("#venue-activity li").first().fadeTo(500, 0.0, function() {
		$("#venue-activity ul").append($("#venue-activity li").first());
		$("#venue-activity li").first().fadeTo(500, 1.0);
		adjustHight();
	});
});

$("#prev-activity").click(function(e) {
	e.preventDefault();
	$(this).blur();
	$("#venue-activity li").first().fadeTo(500, 0.0, function() {
		$("#venue-activity ul").prepend($("#venue-activity li").last());
		$("#venue-activity li").first().fadeTo(500, 1.0);
		adjustHight();
	});
});


//DRAGGABLE TAB 
	var tagposition = 0;
	$("#tag_drag").draggable({ 
							   
		axis: 'y',
		containment: [0,220,0,290],
		scroll: true,
		stop: function() {
			if (tagposition==0){
				$("#tag_drag").animate({"top": "90px"});
				tagposition=1;
			} else {
				$("#tag_drag").animate({"top": "20px"});
				tagposition=0;
			}
			//when dragged it will fire the href on the tag
			var tagAnchor = $('#tag_drag a').attr('href');
			window.location = tagAnchor;
		}
	});
		
	var tagPaintPosition = 0;
	$("#tag_paint_drag").draggable({ 

		axis: 'y',
		containment: [0,480,0,530],
		scroll: true,
		
		drag: function(event, ui) {
			var height = $('#tag_paint_drag').position().top - 255;
			
			$('#paint-extend').css("height", height);
		},
		
		stop: function() {
			
			if (tagPaintPosition==0){
				$("#tag_paint_drag").animate({
					"top"	: "355px"
				});
				$("#paint-extend").animate({
					"height"	: "100px"
				});
				tagPaintPosition=1;
			} else {
				$("#tag_paint_drag").animate({
					"top"	: "255px"
				});
				$("#paint-extend").animate({
					"height"	: "0px"
				});
				tagPaintPosition=0;
			}
			//when dragged it will fire the href on the tag
			var tagPaintAnchor = $('#tag_paint_drag a').attr('href');
			window.location = tagPaintAnchor;
		}
	});
	
	
if($(".ie7").size() < 0){
	//NAV ANIMATE
	$('#head nav ul li').css({'top' : '-250px'});
	  $.fn.showdelay = function(){
	    var delay = 0;
	    return this.each(function(){
	      $(this).delay(delay).animate({"top" : "+=250px" });
	      delay += 1000;
	    });
	  };
	$('#head nav ul li').showdelay();

	//MENU NAV ANIMATE
	$('#menu-tabs ul li').css({'top' : '110px'});
	  $.fn.showdelay = function(){
	    var delay = 0;
	    return this.each(function(){
	      $(this).delay(delay).animate({"top" : "-=110px" });
	      delay += 1000;
	    });
	  };
	$('#menu-tabs ul li').showdelay();
}


//NAV HOVER ROTATION
  // "Globals" - Will make things compress mo-betta
  //var $random = function(x) { return Math.random() * x; };

	  var availableWidth = 165, availableHeight = 165;
	  // Get the proper CSS prefix
	  if($.browser.webkit) {
	    cssPrefix = "webkit";
	  }
	  else if($.browser.mozilla) {
	    cssPrefix = "moz";
	  }
	  else if($.browser.opera) {
	    cssPrefix = "o";
	  }
	  else if($.browser.msie) {
	    cssPrefix = "msie";
	  }

	  // Apply opacity
	  var zIndex = 1000;
	  
	  // Randomize each link
	  jQuery.each(jQuery("#head nav a"),function(index) {
	    var startDeg = 360;
	    var element = jQuery(this);
	    var resetPlace = function() {
	      element.css("-" + cssPrefix + "-transform","rotate(" + startDeg + "deg)");
	    };
	    element.attr("style","z-index:" + zIndex).hover(function() {
	      element.css("zIndex",++zIndex).css("-" + cssPrefix + "-transform","rotate(0deg)");
	    },resetPlace);
	    resetPlace();
	  });
//BUTTON PULSATOR
	var pulsestate = true;
	$('.pulse').show();
	pulser = setInterval(pulseButton,500);
	function pulseButton() {
		if(pulsestate){
			$('.pulse').animate({
				//right : 2+'px', 
				top : 2 +'px'}, 400
			);
			pulsestate = false;
		}
		
		if(!pulsestate){
			$('.pulse').animate({
				//right : 0+'px', 
				top : 0+'px'}, 400
			);
			pulsestate = true;
		}
		
	}

//FOOTER SOCIAL
$('#social-icons a').live('click', function(e) {
	e.preventDefault()
    
    if ($(this).hasClass('selected')) {
        return;
    }
	
	var socialID = $(this).attr("class");
	$('.social-container').hide();
	$('#'+socialID+'').fadeIn();

	$('#social-icons a').removeClass('selected');
	$('#social-icons a.' + socialID).addClass('selected');	
});

//VENUE TABS
$('#venue-tabs a').click(function(e) {
	e.preventDefault()

	if(!$(this).hasClass("selected")){
		var venueID = $(this).attr("class");
		$('.venue-tab-container').hide();
		$('#'+venueID+'').fadeIn();

		$('#venue-tabs a').removeClass('selected');
		$('#venue-tabs a.' + venueID).addClass('selected');	
	}
});


$('.photo_icon').protip({
	'position': 'top middle',
	'anchor': 'element',
	'offset': [-140,0],
	'onBeforeShow': function() {
		var tip;
		if (tip = this.protip('tip')) {
			var img_href = this.parents('.menu-item').attr('rel');
			tip.find('img').attr('src', img_href);
		}
	},
	'tip': function() {
        var tip = $('#menu-img-tip');
       
		var img_href = $(this).parents('.menu-item').attr('rel');
		tip.find('img').attr('src', img_href);
        
		return tip;
	}
});

$('.drag-info').protip({
	'position': 'top middle',
	'anchor': 'element',
	'offset': [-140,0],
	'tip': function() {
		var tip_content = $(this).children('.drag-content');
		//$(this).attr('title',null);
		var t = $('#drag-img-tip');
		t.empty().append(tip_content.clone().contents());
		return t;

	}
});

//contact page

if($("#contact-page p.successText").size()>0){
	$("#talk-main").css({"background": 0});
}

});//end

