// JavaScript Document
var panel_peek = false;
var panel_open = false;
$(document).ready(function(){
						   
	$('#product_tabs_nav li a').click(changeProductTabContent);
	$("#product_tabs > div > div:not(:first-child)").hide();					   
	
	
	/* TOP DROPDOWN */
	$("#mainMenuContainer").css({"margin-top" : "-192px"});
	$("#mainMenuContainer").hide();

	$("#mainMenuTab a").hover(function(){
		if (panel_peek == false && panel_open == false) {
			peekSiteMenu();
		}
	},function(){
		if (panel_peek == true && panel_open == false ) {
			closeSiteMenu();
		}
	});
	
	$("#mainMenuTab a").click(openSiteMenu);
	$("#closeContainer a").click(closeSiteMenu);
	$("#mainMenuContainer").mouseleave(closeSiteMenu);	
	
$('div#content ul.product-list li div h3').each(function(i){
		if($(this).is(':empty')){
			$(this).parent().parent().hide();
		}
	});
	
$('div#content ul.product-list li div.content-holder p').each(function(i){
		if($(this).is(':empty')){
			$(this).parent().parent().hide();
		}
	});


$('#products-menu > ul > li > img + a').each(function(){

$(this).prev().click(function () {
					var link = $(this).next();
					var href = link.attr('href');
					if (link.attr('rel') == 'external')
						window.open(href);
					else
						location.href = href;

	});

});


});

$(function () {

	$('ul.product-list li')

	.click(function () {
					var link = $(this).find("a").eq(0);
					var href = link.attr('href');
					if (link.attr('rel') == 'external')
						window.open(href);
					else
						location.href = href;

	})

	.mouseover(function () {

					$(this).css("cursor", "pointer");
					$(this).toggleClass("linkpanel_hover", true);

	})

	.mouseout(function () {

					$(this).css("cursor", "default");
					$(this).toggleClass("linkpanel_hover", false);

	});

	$('select.styled').hover(function(){
					   
		$(this).prev().addClass('hover');
	
	},function(){
		
		$(this).prev().removeClass('hover');
									
	}).change(function(){
		var v = $(this).attr('value');
                if (v != '0')
		    window.location.href = v;	
		
	});

});


function peekSiteMenu() {
	var m = $("#mainMenuContainer").css('margin-top');
	$("#mainMenuContainer").animate({ "margin-top": "-182px" });
	$("#mainMenuContainer").show();	
	panel_peek = true;
}

function openCloseSiteMenu() {
	if($("#mainMenuContainer").is(':visible')){
		openSiteMenu();
	}else{;
		closeSiteMenu();
	}		
}

function openSiteMenu() {
		panel_peek = false;
		panel_open = true;
		$("#mainMenuContainer").animate({ "margin-top": "0px" }, "slow",'linear',function(){panel_open = true});	
		$("#mainMenuContainer").show();
		$("#mainMenuTab a").addClass("selected");
		$("#mainMenuTab a").text("Explore Seven Seas -");	
}

function closeSiteMenu() {
	$("#mainMenuContainer").animate({ "margin-top": "-192px" }, "slow", function (){
		$("#mainMenuContainer").hide();	
		$("#mainMenuTab a").text("Explore Seven Seas +");	
		panel_open = false;
		panel_peek = false;
	});			
}

function changeProductTabContent()
{
	var selected = $(this).attr('rel');
	$('#product_tabs_nav a').removeClass('active');
	$(this).addClass('active');
	$('.tab_content').hide(0,function(){
		$('#'+selected).show(0);
	});
    return false;
}
