// JavaScript Document

//var cur = parseInt($(.zindex).css('z-index'));
$(document).ready(function(){
	 var cur;  // to create a global variable
	
   // *** img ***Change the image of hoverable images   add class=.imgHoverable in img tag
   $(".imgHoverable").hover( function() {
       var hoverImg = HoverImgOf($(this).attr("src"));
       $(this).attr("src", hoverImg);
     }, function() {
       var normalImg = NormalImgOf($(this).attr("src"));
       $(this).attr("src", normalImg);
     },
	 
	 
	//*** z-index **** to change the css z index on  hover and add the class=".zindex" in div or other tag used for absolute	 
	 $(".zindex").hover(function() {
		  cur = parseInt($(this).css('z-index'));  // assign a value to a global variable
	$(this).css({'z-index' : '999'}); /*Add a higher z-index value so this image stays on top*/ 
	//$(this).find('ul').eq(0).css('display', 'block');  //for accessing ul tag of current class
	 $(this).find('ul').eq(0).slideDown('fast');    //for accessing ul tag by predefined function slideup  and slidedown

	} , function() {
	$(this).css({'z-index' : cur}); /* Set z-index back to default value  using global variable  */	
	// $(this).find('ul').eq(0).css('display', 'none'); //for accessing ul tag of current classs
	$(this).find('ul').eq(0).slideUp('fast');   //for accessing ul tag by predefined function slideup  and slidedown
	},
	
	$(".submenu").hover( function() {
       $(this).attr("src", hoverImg);
     }, function() {
       var normalImg = NormalImgOf($(this).attr("src"));
       $(this).attr("src", normalImg);
     })
	 
   ));
});


//** img file name change  ***function to change image file name
function HoverImgOf(filename)
{
   var re = new RegExp("(.+)\\.(gif|png|jpg)", "g");
   return filename.replace(re, "$1-hover.$2");
}
function NormalImgOf(filename)
{
   var re = new RegExp("(.+)-hover\\.(gif|png|jpg)", "g");
   return filename.replace(re, "$1.$2");
}

