function str_replace(search, replace, subject) {
	return subject.split(search).join(replace);
}


$(document).ready(function() {
	
	
    $("#menu").find("img.current").each(function(i,e) {
	  	   $(this).css("z-index","3");
	  	   
		     var imgname = $(this).attr("src");
		     var newimg = str_replace('_normal','_hover',imgname);
		     $(this).attr("src",newimg);
		     
		     
	     });	
	
	// Men�animation
   $(".menubtn").mouseover(function() {
	     
	   
	    $("#menu").find("img.current").each(function(i,e) {

		     var imgname = $(this).attr("src");
		     var newimg = str_replace('_hover','_normal',imgname);
		     $(this).attr("src",newimg);
			     
		     });
	    
	    
	     var imgname = $(this).attr("src");
	     var newimg = str_replace('_normal','_hover',imgname);
	     $(this).attr("src",newimg);
	     
	     $("#menu").find("img").each(function(i,e) {
	  	   $(this).css("z-index","2");
	     });	
	     
	     $(this).css("z-index","6");
	});
   $(".menubtn").mouseout(function() {
	     
	     var imgname = $(this).attr("src");
	     var newimg = str_replace('_hover','_normal',imgname);
	     $(this).attr("src",newimg);
	     
	     
	     $("#menu").find("img").each(function(i,e) {
		  	   $(this).css("z-index","2");
		     });	
		     
	    $("#menu").find("img.current").each(function(i,e) {

		     var imgname = $(this).attr("src");
		     var newimg = str_replace('_normal','_hover',imgname);
		     
		     $(this).attr("src",newimg);
		     $(this).css("z-index","3");
		     });	     
	     
	});
   
   
   
   
	   // Header slideshow

	   $("ul#header_home_slideshow").cycle({
			fx: 'fade',
			pause: 1,
			timeout: 15000,
			prev: '#prev',
			next: '#next'
		});
	   
   
   
   $("#headerhome").hover(function() {
		$("ul#nav").fadeIn();
		},
			function() {
		$("ul#nav").fadeOut();
		});
   
   	 $("#next a").mouseover(function() {
	     $(this).css("background-image", "url('img/slider_next_g.png')");
	 });
	 $("#next a").mouseout(function() {
		   $(this).css("background-image", "url('img/slider_next_w.png')");  	    
	 });
	 
	 $("#prev a").mouseover(function() {
		     $(this).css("background-image", "url('img/slider_prev_g.png')");
	 });
	 $("#prev a").mouseout(function() {
		   $(this).css("background-image", "url('img/slider_prev_w.png')");  	    
	 });
	 
	 
});	 
