// JavaScript Document

function getLeaf(url) {
 var splited=url.split('?');// remove all the parameter from url
 url=splited[0];
 // return file name without domain and path
 return url.substring(url.lastIndexOf("/")+1);
 /*
 return url;
 */
} 

jQuery.fn.extend({
 navState: function() {//plugins creation
     return this.each(function() {
       var pth = $(this).find("img")[0];
	   //alert($(this).children().attr("href"));
	    if($(this).children().attr("href")==getLeaf(document.location.href)){// check that the link url and document url is same
           $(pth).attr("src",pth.src.replace(/.gif/g, '-ON.gif'));
		 } else{
               $(this).hover(function(){
                  $(pth).attr("src",pth.src.replace(/.gif/g, '-ON.gif'));// mouse over Image
                  },function(){
                      $(pth).attr("src",pth.src.replace(/-ON.gif/g, '.gif'));// mouse out image
                      });
               }
               });
     }
});


/*
set scripts
*/

$(document).ready(function(){  // Document is ready

	$("#navHolder ul li a").navState();// call the navState

	$('ul.sf-menu').superfish({ 
            delay:       1000,                            // one second delay on mouseout 
            animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
            speed:       'normal',                          // faster animation speed 
            autoArrows:  false,                           // disable generation of arrow mark-up 
            dropShadows: true                            // disable drop shadows 
	});
	
	/*
	$('#navHolder a.mainNav').hover(function() {
        $(this).find('img').attr('src', $(this).find('img').attr('src').split(".").join("-ON."));
	}, function() {
    	$(this).find('img').attr('src', $(this).find('img').attr('src').split("-ON.").join("."));
	});
	*/
		
});

