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

jQuery.fn.extend({
 enter: 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

alert("CAMBIO DE IMAGEN POR LA PRIMERA VÍA");

           $(pth).attr("src",pth.src.replace(/.jpg/g, '_design.jpg'));
		 } else{
               $(this).hover(function(){

//alert("Ruta: " + pth.src);
//alert("Cambia por: " + pth.src.replace(/-(\d+)-home.jpg/g, "-$1+1-home.jpg"));
//alert(RegExp.$1-1+2);

$num=pth.src.match(/-(\d+)-home/g);
$num=RegExp.$1;
//alert("Numero: " + $num);
$num=parseInt($num)+1;
//alert("Numero nuevo: " + $num);

                  $(pth).attr("src",pth.src.replace(/-(\d+)-home.jpg/g, '-'+$num+'-home.jpg'));// mouse over Image
//alert("Nueva ruta: " + pth.src);

                  },function(){

//alert("Ruta: " + pth.src);
$num=pth.src.match(/-(\d+)-home/g);
$num=RegExp.$1;
$num = parseInt($num)-1;

                      $(pth).attr("src",pth.src.replace(/-(\d+)-home.jpg/g, '-'+$num+'-home.jpg'));// mouse out image
                      });
               }
               });
     }
});
$(function(){  // Document is ready
 $(".nav p").enter();// call the function
});







function mainmenu(){
$(" .eTalla ul ").css({display: "none"}); // Opera Fix
$(" .eTalla li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}
$(document).ready(function(){					
	mainmenu();
});





$(document).ready(function() {
	
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		
		
});


