jQuery(function() {
	function hideItem(){
		$("#active").css({ background:"#fff" });
        urlImg = $("#active img").attr("src");
        nameImg = urlImg.substring(urlImg.lastIndexOf("/")+1, urlImg.lastIndexOf("_."));
        $("#active img").attr({"src": path + nameImg + ".gif"});
        $("#active").attr({"id": ""});  
    }
    $(".navigation").hover(
        function () {},
        function () {
            if(document.getElementById('active')){
                hideItem();
                $(".secondLevel[name='on']").css({display:"none"}).attr({"name": ""});
				$(".currentItem").css({ background:"#206a33" });
			}
			$(".curIt").css({ background:"#206a33" });
			$(".mrpropper").css({display:"block"}).attr({"name": "on"});
			var mmaaiinn = $(".curIt");
			if(document.getElementById("currentItem") || mmaaiinn.length > 0){
				curImg = $(".curIt img").attr("src");
				if(curImg.lastIndexOf("_.")<0){
					nameCurImg = curImg.substring(curImg.lastIndexOf("/")+1, curImg.lastIndexOf("."));
					$(".curIt img").attr({"src": path + nameCurImg + "_.gif"});
					$(".curIt").attr({ "id":"currentItem" });
				}
			}
        }
    );
    $(".firstLevel a:not(.curIt)").hover(
		function () {
            //hide
            if(document.getElementById('active')){
                hideItem();
                $(".secondLevel[name='on']").css({display:"none"}).attr({"name": ""});
            }
			$(".mrpropper").css({display:"none"}).attr({"name": ""});
			target = $(this).attr("name");
            //light
            $(this).css({ background:"#206a33" });
            $(this).attr({"id": "active"});
            urlImg = $("#active img").attr("src");
			nameImg = urlImg.substring(urlImg.lastIndexOf("/")+1, urlImg.lastIndexOf("."));
            $("#active img").attr({"src": path + nameImg + "_.gif"});
            $("#" + target).attr({"name": "on"}).css({display:"block"});
			if(document.getElementById('currentItem')){
				$("#currentItem").css({ background:"#fff" });
				curImg = $("#currentItem img").attr("src");
				nameCurImg = curImg.substring(curImg.lastIndexOf("/")+1, curImg.lastIndexOf("_."));
				$("#currentItem img").attr({"src": path + nameCurImg + ".gif"});
				$("#currentItem").attr({"id": ""});
			}
        }, 
     	function () {
            target = $(this).attr("name");
            if(target == "null"){
                hideItem();
				$(this).css({ background:"#F8E7C0" });
            }
        }	
	);
	$(".firstLevel a.curIt").hover(
		function(){
			if(document.getElementById('active')){
                hideItem();
                $(".secondLevel[name='on']").css({display:"none"}).attr({"name": ""});
            }
			target = $(this).attr("name");
			$(this).css({ background:"#206a33" });
            urlImg = $("a.curIt img").attr("src");
			if(urlImg.lastIndexOf("_.")<0){
				nameCurImg = urlImg.substring(urlImg.lastIndexOf("/")+1, urlImg.lastIndexOf("."));
				$(".curIt img").attr({"src": path + nameCurImg + "_.gif"});
				$(".curIt").attr({ "id":"currentItem" });
				$("#" + target).attr({"name": "on"}).css({display:"block"});
			}
		},
		function(){}
	);
    $(".secondLevel span a img").hover(
     	function () {
            urlImg = $(this).attr("src");
            nameImg = urlImg.substring(urlImg.lastIndexOf("/")+1, urlImg.lastIndexOf("_."));
            $(this).attr({"src": path + nameImg + ".gif"});
        },
		function () {
            urlImg = $(this).attr("src");
            nameImg = urlImg.substring(urlImg.lastIndexOf("/")+1, urlImg.lastIndexOf("."));
            $(this).attr({"src": path + nameImg + "_.gif"});
        }
	);
});

