﻿ $(document).ready(function(){
    var cimg=''; 
    cimg =$(".navi_left").children("img").attr("src");
    var tmpcimg =  $("#nav li.current").children("a").css("background-image");
	if (tmpcimg!="none" && tmpcimg !=undefined )
	{
		cimg=tmpcimg;
	} else 
	{
      tmpcimg =  $(".top_navi li a#home").css("background-image");
      cimg=tmpcimg;
	}
   if (cimg !=undefined)
   {
    var current = cimg.substring(cimg.indexOf("_")+1,cimg.lastIndexOf("."));
    cimg = cimg.substring(cimg.indexOf("/resources"),cimg.indexOf("_")+1);
    
	$("#nav li.current").children("a").css({background:"url("+cimg+current+"_cnt.gif) no-repeat bottom left"});
   
    $(" #nav ul ").css({display: "none"}); // Opera Fix
    
	$(" #nav li").hover(function(){
		  
           var aid = $(this).children("a").attr("id");
			 if (aid.length > 0) {
           	$(this).children("a#"+aid).css({backgroundImage:"url("+cimg+aid+"_sel.gif)", repeat:"repeat-x"});
          }
		   $(this).find('ul:first').css({visibility: "visible",display: "none"}).show(50);
		
		
		},function(){

           var aid = $(this).children("a").attr("id"); 
		   $(this).find('ul:first').css({visibility: "hidden"});
		  
		   var iscurrent=$(this).attr("class");
		    var oimg=cimg+aid;
		   if(iscurrent=="current")
			   oimg=oimg+"_cnt";
		  if (aid.length > 0) {
        $(this).parent().find("#"+aid).css({backgroundImage:"url("+oimg+".gif)", repeat:"repeat-x"});
      }
       }
    );
}
 
 })

