	jQuery.fn.reset = function () {
 	 $(this).each (function() { this.reset(); });
	}
	function formDefaultValue (elemento, defaultValue) {
		if (elemento.value==defaultValue) {
			elemento.value = "";
		}
		return true;
	}
	function formDefaultValueCheck (elemento,defaultValue) {
		if(elemento.value == "") {
			elemento.value = defaultValue;
		}
	}
	function _encode (string) {
			return escape(this._utf8_encode(string));
		}
		function _utf8_encode (string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";
			for (var n = 0; n < string.length; n++) {
				var c = string.charCodeAt(n);
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}
			}
			return utftext;
		}
		function keasearchQuery (f) {
			if (f.searchkea.value=="") {
				f.searchkea.style.background=('#990000');
				f.searchkea.style.color=('#ffffff');
				alert ('¿Que quieres buscar?');
				f.searchkea.focus();
				return false;
			}
			f.action="./keas/resultados/"+_encode(f.searchkea.value)+"/";
			//return true;
		}

	//Menú
	  $(document).ready(function(){
			$("#menu li").hover(
				function(){ $("ul", this).slideDown() },
				function(){ $("ul", this).slideUp() }
			);
	  	if (document.all) {
				$("#menu li").hoverClass ("sfHover");
			}
			$(".inputFile").filestyle({
				image: ROOT_DIR+"imagenes/examinar.gif",
				imageheight:22,
				imagewidth:96,
				width:197
			});
		   	$("#fnac").mask("99/99/9999");
		   	$("#telefono").mask("999-999-999");
	  });
		$.fn.hoverClass = function(c) {
			return this.each(function(){
				$(this).hover(
					function() { $(this).addClass(c);  },
					function() { $(this).removeClass(c); }
				);
			});
		};
	//Mis scripts
		$(function() {
			$('#tabSide').tabs({
				fxSlide: true, fxFade: true, fxSpeed: 'normal' }
			);
			/* Tooltip ayuda */
			$("#icoHelp").mouseover(function(event) {
				$("#capaHelp").slideToggle();
			});
			$("#icoHelp2").mouseover(function(event) {
				$("#capaHelp2").slideToggle();
			});
			$("#icoHelp3").mouseover(function(event) {
				$("#capaHelp3").slideToggle();
			});
			$("#icoHelpUser").mouseover(function(event) {
				$("#capaHelptol1").slideToggle();
			});
			$("#icoHelpUser2").mouseover(function(event) {
				$("#capaHelptol2").slideToggle();
			});
			$("#icoHelpUser3").mouseover(function(event) {
				$("#capaHelptol3").slideToggle();
			});
			$("#icoHelp").mouseout(function(event) {
				$("#capaHelp").slideToggle();
			});
			$("#icoHelp2").mouseout(function(event) {
				$("#capaHelp2").slideToggle();
			});
			$("#icoHelp3").mouseout(function(event) {
				$("#capaHelp3").slideToggle();
			});
			$("#icoHelpUser").mouseout(function(event) {
				$("#capaHelptol1").slideToggle();
			});
			$("#icoHelpUser2").mouseout(function(event) {
				$("#capaHelptol2").slideToggle();
			});
			$("#icoHelpUser3").mouseout(function(event) {
				$("#capaHelptol3").slideToggle();
			});
			/* Añadir IMG */
			$("#anadirImg").click(function(event) {
			    if($("#capIntF").css("display")=="none"){ $("#capIntF").fadeIn(); }
			    else{ $("#capIntF").fadeOut(); }
			});
			$("#anadirImg2").click(function(event) {
			    if($("#capIntF2").css("display")=="none"){ $("#capIntF2").fadeIn(); }
			    else{ $("#capIntF2").fadeOut(); }
			});
			$("#anadirImg3").click(function(event) {
			    if($("#capIntF3").css("display")=="none"){ $("#capIntF3").fadeIn(); }
			    else{ $("#capIntF3").fadeOut(); }
			});
			/* Google MAPS */
			$("#localizar").click(function(event) {
			    if($("#google1").css("display")=="none"){ $("#google1").fadeIn(); }
			    else{ $("#google1").fadeOut(); }
			});
			$("#localizar2").click(function(event) {
			    if($("#google2").css("display")=="none"){ $("#google2").fadeIn(); }
			    else{ $("#google2").fadeOut(); }
			});
			$("#localizar3").click(function(event) {
			    if($("#google3").css("display")=="none"){ $("#google3").fadeIn(); }
			    else{ $("#google3").fadeOut(); }
			});
			/* Añadir texto */
			$("#anadirText").click(function(event) {
				$("#textArKe").fadeIn();
			});
			$("#anadirText2").click(function(event) {
				$("#textArKe2").fadeIn();
			});
			/* Añadir etiquetas */
			$("#etiquetas").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#etiquetas2").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#etiquetas3").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#etiquetas").click(function(event) {
				$("#eti1").slideToggle();
			});
			$("#etiquetas2").click(function(event) {
				$("#eti2").slideToggle();
			});
			$("#etiquetas3").click(function(event) {
				$("#eti3").slideToggle();
			});
			/* Vídeo Youtube */
			$("#grabar_you").click(function(event) {
				$("#desdeYou").slideToggle();
				$("#exisYou").slideToggle();
			});
			$("#video_you").click(function(event) {
				$("#exisYou").slideToggle();
				$("#desdeYou").slideToggle();
			});
			/* Tooltip Small */
			$("#icoHelp4").click(function(event) {
				$("#capaHelp5").slideToggle();
			});
			$(".capaUser .enviar").mouseover(function() {$(this).addClass("newHabiDis");}).mouseout(function() {$(this).removeClass("newHabiDis");});
			$(".capaKea4 .enviar").mouseover(function() {$(this).addClass("enviarHover");}).mouseout(function() {$(this).removeClass("enviarHover");});
			$("#anadirText").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#anadirImg").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#anadirImg2").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#localizar").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#localizar2").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#anadirText2").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#anadirImg3").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#localizar3").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			$("#btnAna").mouseover(function() {$(this).addClass("btnHoverAdd");}).mouseout(function() {$(this).removeClass("btnHoverAdd");});
			$("#btnAna2").mouseover(function() {$(this).addClass("btnHoverAdd2");}).mouseout(function() {$(this).removeClass("btnHoverAdd2");});
			$("#btnAna3").mouseover(function() {$(this).addClass("btnHoverAdd2");}).mouseout(function() {$(this).removeClass("btnHoverAdd2");});		
			$("#marcaGoogle").mouseover(function() {$(this).addClass("btnHover");}).mouseout(function() {$(this).removeClass("btnHover");});
			/* Añadir teléfono */
			$("#pulInpuE").click(function(event) {
			    if($("#eventeosIn").css("display")=="none"){ $("#eventeosIn").fadeIn(); }
			    else{ $("#eventeosIn").fadeOut(); }
			});
			$("#sms").click(function(event){
				if( $("#telefono").css("display")=="none"){$("#telefono").fadeIn();}
				else{ $("#telefono").fadeOut(); }
			});
			
			/* Diferentes plazas */
			$("#btnAna2").click(function(event) {
				$(".textRe ul.hidden").slideToggle();
			});
			$("#dejarnota").click(function(event) {
			    if($(".dejarForm .hidden").css("display")=="none"){ $(".dejarForm .hidden").slideToggle(); }
			    else{ $(".dejarForm .hidden").slideToggle(); }
			});
			$("#anadir_comen").click(function(event) {
				$("#sendtoafriendthanksBox").remove();
			    if($("#sendtofriendBox").css("display")=="block"){ $("#sendtofriendBox").slideToggle(); }
			    $("#commentBox").slideToggle();
			});
			$("#enviar_amigo").click(function(event) {
				$("#sendtoafriendthanksBox").remove();
				$("#sendToaFriend").reset();
			    if($("#commentBox").css("display")=="block"){ $("#commentBox").slideToggle(); }
			    $("#sendtofriendBox").slideToggle();
			});
			$("#hasOlvi").click(function(event) {
			    if($("#rememberPassw").css("display")=="none"){ $("#rememberPassw").slideToggle(); }
			    else{ $("#rememberPassw").slideToggle(); }
			});			
		});
