ie = false;
ie7 = false;
ie8 = false;
ie9 = false;

$(document).ready(function() {
// OPEN READY -----------------------------------------------------------		
//apply "last" class to all ul li:last-child
	$("ul").each(function() {
		$("li:last", this).addClass('last')
	});
	$(".results").each(function() {
		$(".result:last", this).addClass('last')
	});

	$(".nav ul").each(function() {
		$("li:first", this).addClass('eclub')
	});
//apply expand effect on info_url links
	$(".info_url.active").toggle(function(){
		var displayId = "#"+$(this).attr('rel');
		$(this).addClass("expanded");
		$(displayId).removeClass("hidden");
	},function(){
		var displayId = "#"+$(this).attr('rel');
		$(this).removeClass("expanded");
		$(displayId).addClass("hidden");
	});
	
//apply hover class/animation to #content_nav navigation
	$("#content_nav li").hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
	});
	
//hide the social icons
	$("#social_holder .social_icons").hide().addClass("closed");

//add the click event to social icons
	$("#social_holder .get_social").click(function(){socialClicked($(this));});
	
//activating order online fancybox
	$("#header .order_online a, .notfoundpage .callout .order_online a").fancybox({
		'type'	  :	'iframe',
		'onStart' :	function(){
			$("#fancybox-wrap").addClass("online_overlay");
			$("#fancybox-overlay").addClass("loading");
		},
		'onComplete' : function(){
			$("#fancybox-overlay").removeAttr("class");
		}
	});	
	
// Set up scrolling elements and the links which scrollTo elements within it
	var pane = $('.scroll-pane');
	var setPane = $('.category .scroll-pane, .menu .scroll-pane, .locations .scroll-pane, .location .scroll-pane')	
	if($(pane).length){
		var panetop = parseInt(pane.offset().top);
		setPane.jScrollPane({animateTo:true});
		$('a.scroll-to-element').bind('click',function(){
			$('a.scroll-to-element').removeClass('current');
			$(this).addClass('current');
			var targetElementSelectorString = $(this).attr('rel');
			pane[0].scrollTo(targetElementSelectorString);
			return false;
		});
	}
	else {return false;}		

//hiding slides. Delayed to wait for scrolling element to calculate height/width
	$('li.content_slide').addClass('hidden').delay(800);	
	
//TEMP hiding of certain region for online ordering
	if ($(".order_online .region").length) {
		$(".order_online .region:first").hide();
	}	
	if (ie7) {
		$('.page #content').height($(window).height());
		$(window).resize(function(){
			$('.page #content').height($(window).height());
		});
	}	
	$('.dynamic_form input, .dynamic_form textarea').each(function(){
		var input_val = $(this).val();
		$(this).focus(function(){
			if($(this).val() == input_val) {
				$(this).val('');
			}
		});
		$(this).blur(function(){
			if($(this).val() == '') {
				$(this).val(input_val);
			}
		});
	});			
	
	if (ie9){
		$(window).bind('load',function(){
			$('#supersized img').width($(document).width());
			$('#supersized img').css({height:'auto'});
		});
	}
	if (ie7 || ie8) {
		$(window).bind('load',function(){
			$('#supersized').addClass('important');
		});
	}
	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	if (isiPad) {
		$('#supersized').addClass('ipad');
		 window.onorientationchange = detectIPadOrientation;  
		 function detectIPadOrientation () {  	
			$('#supersized').removeClass('horz').removeClass('vert');	  
			if ( orientation == 0 || orientation == 180 ) {    
				$('#supersized').addClass('vert');
			}  
			else if ( orientation == 90 || orientation == -90 ) { 
				$('#supersized').addClass('horz'); 
			}  
		 }  
		detectIPadOrientation();
	}
	
	if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {
		$('body').addClass('mobile');
		$('#footer').css({top: $(document).height()-53})
	}
// CLOSE READY -----------------------------------------------------------
});
$(window).bind("load", function(){
    $('body.page .scroll-pane').jScrollPaneRemove();
    $('.menu .scroll-pane, body.page .scroll-pane').setScrollableArea(30).jScrollPane({
        scrollbarWidth: 20,
        scrollbarMargin: 10,
        animateTo: true
    });
});
$(window).resize(function(){
    $('body.page .scroll-pane').jScrollPaneRemove();
    $('body.page .scroll-pane').setScrollableArea(30).jScrollPane({
        scrollbarWidth: 20,
        scrollbarMargin: 10,
        animateTo: true
    });

}); 
