$(document).ready(function(){
	initMenuTab();	

	if($.browser.safari){
            bodyelem = $("body")
        } else{
            if($.browser.opera){
                bodyelem = $("html")
            } else{
                bodyelem = $("html,body")
            }
        }
        bodyelem.animate({scrollTop: 0});


})

initMenuTab = function(){
	$("#headersplit .top").mouseenter(function(){
		if (!$(this).find("h1").hasClass("active")){
			$("#headersplit .top h1").removeClass("hover");
			$(this).find("h1").addClass("hover");
			$("#headersplit td").removeClass("tdhover");
			$(this).parent().addClass("tdhover");
			
			if($("#headersplit .rightzone").css("background-position-y")){
				if(!$("#headersplit td").hasClass("tdactive")) $("#headersplit td").css("background-position-y", "0px");
				$(this).parent().css("background-position-y","-160px");
			} else {
				if(!$("#headersplit .rightzone").hasClass("tdactive")) $("#headersplit .rightzone").css("background-position",($("#headersplit .rightzone").css("background-position").split(" ")[0]+" 0px"));
				if(!$("#headersplit .centerzone").hasClass("tdactive")) $("#headersplit .centerzone").css("background-position",($("#headersplit .centerzone").css("background-position").split(" ")[0]+" 0px"));
				if(!$("#headersplit .leftzone").hasClass("tdactive")) $("#headersplit .leftzone").css("background-position",($("#headersplit .leftzone").css("background-position").split(" ")[0]+" 0px"));
				$(this).parent().css("background-position",($(this).parent().css("background-position").split(" ")[0]+" -160px"));
			}
		}
	});
	$("#headersplit .top").mouseleave(function(){
		if (!$(this).find("h1").hasClass("active")){
			$(this).find("h1").removeClass("hover");
			$(this).parent().removeClass("tdhover");
			if($(this).parent().css("background-position-y")){
				$(this).parent().css("background-position-y","0px");
			} else {
				$(this).parent().css("background-position",($(this).parent().css("background-position").split(" ")[0]+" 0px"));
			}
		}		
	});
	$("#headersplit .top").click(function(){
		if (!$(this).find("h1").hasClass("active")){
			$("#headersplit .top h1").removeClass("active");
			$(this).find("h1").addClass("active");
			$("#headersplit td").removeClass("tdactive");
			$(this).parent().addClass("tdactive");
			if($("#headersplit .rightzone").css("background-position-y")){
				$("#headersplit td").css("background-position-y", "0px");
				$(this).parent().css("background-position-y","-160px");
			} else {
				$("#headersplit .rightzone").css("background-position",($("#headersplit .rightzone").css("background-position").split(" ")[0]+" 0px"));
				$("#headersplit .centerzone").css("background-position",($("#headersplit .centerzone").css("background-position").split(" ")[0]+" 0px"));
				$("#headersplit .leftzone").css("background-position",($("#headersplit .leftzone").css("background-position").split(" ")[0]+" 0px"));
				$(this).parent().css("background-position",($(this).parent().css("background-position").split(" ")[0]+" -160px"));
			}
			//location.replace("products.html#"+$(this).find("h1").attr("id"));
			try { 
				sendToFlash($(this).find("h1").attr("id")); 
			} 
			catch(e) {
				location.replace("products.html#"+$(this).find("h1").attr("id"));

			};
		}
	});
}


function dataFromFlash(value){
	value = "#headersplit .top #"+value;
	$("#headersplit .top h1").removeClass("active");
	$("#headersplit td").removeClass("tdactive");
	$(value).addClass("active");
	$(value).parent().parent().parent().addClass("tdactive");
	
	if($("#headersplit .rightzone").css("background-position-y")){
		$("#headersplit td").css("background-position-y", "0px");
		$(value).parent().parent().parent().css("background-position-y","-160px");
	} else {
		$("#headersplit .rightzone").css("background-position",($("#headersplit .rightzone").css("background-position").split(" ")[0]+" 0px"));
		$("#headersplit .centerzone").css("background-position",($("#headersplit .centerzone").css("background-position").split(" ")[0]+" 0px"));
		$("#headersplit .leftzone").css("background-position",($("#headersplit .leftzone").css("background-position").split(" ")[0]+" 0px"));
		$(value).parent().parent().parent().css("background-position",($(value).parent().parent().parent().css("background-position").split(" ")[0]+" -160px"));
	}
}
function thisMovie(movieName) {
  	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
   	return document[movieName];
   }
}
function sendToFlash(value) {
  	thisMovie("flashgallery").sendToFlash(value);
}
