// JavaScript Document

jQuery(document).ready(function($) {	
	//Implement this in wp-includes/bigclock.php
	//$('#hero').css({ display: 'none'}).fadeIn(1000).addClass('hero_bg');
	
	$(".home_text_box").hover(
		function () {
		$('span.home_text_link', this).css('color','#003468');
		},
		function () {
		$('span.home_text_link', this).css('color','#00A2F1');
		}
	);
	
	
	$('.btn_social_wrapper').hover(function(){
		$('.social_icons , .social_icons_bg', this).css('display', 'block');
	},
	function(){
		$('.social_icons , .social_icons_bg', this).css('display', 'none');
	});

	
	$('.video_thumb_list li img').hover(
		function(){
			$(this).fadeTo("fast", 1);
	},
		function(){
			$(this).fadeTo("fast", 0.5);
	});
	
	
	$('.jclock').jclock();
	
	/*
	$("input[type=file]").filestyle({ 
     image: "/wp-content/themes/default/images/btn_browse.gif",
     imageheight : 18,
     imagewidth : 70,
     width : 196
 	});
	*/
	
	// Nav Dropdown
	$('li.navlink').hover(
      function(){
          $('ul.dropdown , div.nav_top', this).fadeIn('fast').css('display', 'block');
      },
      function(){
          $('ul.dropdown , div.nav_top', this).fadeOut('fast').css('display', 'none');
      });
	
    $('li.footer_nav').hover(
      function(){
          $('ul.footer_dropdown', this).fadeIn('fast').css('display', 'block');
          
      },
      function(){
          $('ul.footer_dropdown', this).fadeOut('fast').css('display', 'none');
      });
      
    //Print Page
	$("a.print-page").click(function() {
		window.print();
		return false;
	});
	
	
	//Home Page Resize
	resizeHomePic();
	$(window).resize(resizeHomePic);
	
	function resizeHomePic() {
		var window_height = $(window).height();
		var page_height = $("div#page").height();
		var hero_height = $("div#hero").height();
		
		if (window_height >= page_height) {
			var height_diff = window_height - page_height;
			var new_height = hero_height + height_diff -14;
			$("div#hero").css({height:new_height});
			
			if (window_height >= 980) {
				$("div#hero").css({height:"715px"});
			}
		}
		
		if (window_height <= page_height) {
			var height_diff = page_height - window_height;
			var new_height = hero_height - height_diff;
			$("div#hero").css({height:new_height});
		}
	}
	
	
	//Content centering in narrow browser
	centerContent();
	$(window).resize(centerContent);
	function centerContent() {
		var window_width = $(window).width();
		var page_width = $("div#page").width();
		var targetOffset = page_width - window_width;
		if (window_width <= 1130) {
			$('html, body').animate({ scrollLeft: targetOffset / 2 }, 50);
		}
	}
	
	


	//Catering
	$("ul.catering-subnav a").click(function() {
		var curr_a = $(this).attr("class");
		$("div.catering-wrap div.box").css("display","none");
		$("div.catering-wrap div." + curr_a).css("display","block");
		$("ul.catering-subnav a.our-chef").css("backgroundPosition","0 0");
		$("ul.catering-subnav a.our-menus").css("backgroundPosition","-135px 0");
		$("ul.catering-subnav a.our-coffee").css("backgroundPosition","-270px 0");
		$("ul.catering-subnav a.weddings").css("backgroundPosition","-405px 0");
		if (curr_a == "our-chef") {
			$("ul.catering-subnav a.our-chef").css("backgroundPosition","0 bottom");
		} else if (curr_a == "our-menus") {
			$("ul.catering-subnav a.our-menus").css("backgroundPosition","-135px bottom");
		} else if (curr_a == "our-coffee") {
			$("ul.catering-subnav a.our-coffee").css("backgroundPosition","-270px bottom");
		} else if (curr_a == "weddings") {
			$("ul.catering-subnav a.weddings").css("backgroundPosition","-405px bottom");
		}
	});
	
	//Technical
	$("ul.technical-subnav a").click(function() {
		var curr_a = $(this).attr("class");
		$("div.technical-wrap div.box").css("display","none");
		$("div.entry , div.technical-wrap div." + curr_a).css("display","block");
		$("ul.technical-subnav a.internet-telecom").css("backgroundPosition","0 0");
		$("ul.technical-subnav a.audio-visual").css("backgroundPosition","-154px 0");
		$("ul.technical-subnav a.electrical-plumbing").css("backgroundPosition","-262px 0");
		$("ul.technical-subnav a.rigging-lighting").css("backgroundPosition","-445px 0");
		if (curr_a == "internet-telecom") {
			$("ul.technical-subnav a.internet-telecom").css("backgroundPosition","0 bottom");
		} else if (curr_a == "audio-visual") {
			$("ul.technical-subnav a.audio-visual").css("backgroundPosition","-154px bottom");
		} else if (curr_a == "electrical-plumbing") {
			$("ul.technical-subnav a.electrical-plumbing").css("backgroundPosition","-262px bottom");
		} else if (curr_a == "rigging-lighting") {
			$("ul.technical-subnav a.rigging-lighting").css("backgroundPosition","-445px bottom");
		}
	});
	
	//Book An Event
	$("ul.bookanevent-subnav a").click(function() {
		var curr_a = $(this).attr("class");
		$("div.bookanevent-wrap div.box").css("display","none");
		$("div.entry , div.bookanevent-wrap div." + curr_a).css("display","block");
		$("ul.bookanevent-subnav a.general-inquiries").css("backgroundPosition","0 0");
		$("ul.bookanevent-subnav a.weddings").css("backgroundPosition","-141px 0");
		$("ul.bookanevent-subnav a.jack-poole-plaza").css("backgroundPosition","-240px 0");
		$("ul.bookanevent-subnav a.filming").css("backgroundPosition","-380px 0");
		$("ul.bookanevent-subnav a.sports").css("backgroundPosition","-465px 0");
		$("ul.bookanevent-subnav a.corporate").css("backgroundPosition","-542px 0");
		if (curr_a == "general-inquiries") {
			$("ul.bookanevent-subnav a.general-inquiries").css("backgroundPosition","0 bottom");
		} else if (curr_a == "weddings") {
			$("ul.bookanevent-subnav a.weddings").css("backgroundPosition","-141px bottom");
		} else if (curr_a == "jack-poole-plaza") {
			$("ul.bookanevent-subnav a.jack-poole-plaza").css("backgroundPosition","-240px bottom");
		} else if (curr_a == "filming") {
			$("ul.bookanevent-subnav a.filming").css("backgroundPosition","-380px bottom");
		} else if (curr_a == "sports") {
			$("ul.bookanevent-subnav a.sports").css("backgroundPosition","-465px bottom");
		} else if (curr_a == "corporate") {
			$("ul.bookanevent-subnav a.corporate").css("backgroundPosition","-542px bottom");
		}
	});
	
	// Clear form text
	$("#q").attr({ value: 'Search Site' }).focus(function(){
            if($(this).val()=="Search Site"){
               $(this).val("").css({ color: "#333" });
;
            }
       }).blur(function(){
            if($(this).val()==""){
               $(this).val("Search Site").css({ color: "#c8c8c8" });
            }
       });
	
	
	// Clear news box on homepage
	$("a.btn_x").click(function() {
		$('#news_flash').fadeOut("normal");
	});
	
	
	
	// Equal height columns for Attractions and Accommodation
	function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

    equalHeight($(".attraction_list li"));

	$(".video-preview").click(function(){
		$.post("/wp-content/themes/default/video-embed.php", {url: $(this).attr('title')}, function(data){
			$(".video-gal").html(data);
		});
	});
	
	
});

