// JavaScript Document

$(document).ready(function(){

	$("#imagess a").click(function(){

		var title = "aplication/webroot/imgs/catalogo/"+ $(this).attr("title");

		var len = title.length;

		var text = title.substr(0,33);

		var newtitle = text + title.substr(39,len);

		$("#imgp").hide();

		$("#imgp").attr("src",title).fadeIn('slow'); 

		$("#imgp").attr("alt",title); 

		$("#grande").attr("href",newtitle); 

	

	});	 		

	

	$('#menus li').each(function(index){ 

		$(this).click(function(){			                

			$("#subcat"+index).toggle("fast"); 			   

		}); 	  

	});	

});

function busqueda(url,texto){

	

	document.fbuscar.action = url+'&q=' + texto.value;

	document.fbuscar.submit();

}



function checkTheKey(keyCode){

	if(event.keyCode==13){	

		valida();

		return true ;

	}

	return false ;

}

function validnum(e) { 

	tecla = (document.all) ? e.keyCode : e.which; 

	//alert(tecla)

    if (tecla==8 || tecla==46) return true; //Tecla de retroceso (para poder borrar) 

    // dejar la línea de patron que se necesite y borrar el resto 

    //patron =/[A-Za-z]/; // Solo acepta letras 

    patron = /\d/; // Solo acepta números

    //patron = /\w/; // Acepta números y letras 

    //patron = /\D/; // No acepta números 

    // patron = /[\d.-]/; numeros el punto y el signo -

    te = String.fromCharCode(tecla); 

    return patron.test(te);  

	// uso  onKeyPress="return validnum(event)"

}





function ver_compromiso(){

  $('#nosotros').hide('slow');

  $('#compromiso').show('slow');

}

function ver_nosotros(){

  $('#compromiso').hide('slow');

  $('#nosotros').show('slow');

}



/*$(document).ready( function(){						   

	$('#menu li').each(function(index){ 

		$(this).click(function(){			                

			$("#subcat"+index).toggle("fast"); 			   

		}); 	  

	});					   



	$("#imagenes a").click( function(){

		var title = $(this).attr("title");

		$("#imgp").hide();

		$("#imgp").attr("src",title).fadeIn('slow'); 

	});	 	

});*/





function validar(){

	if(document.f1.nombre.value==""){

		alert("ERROR: Por favor ingrese su Nombre");

		document.f1.nombre.focus();

		return false;

	}else if(document.f1.apellidos.value==""){

		alert("ERROR: Por favor ingrese sus Apellidos");

		document.f1.apellidos.focus();

		return false;

	}else if(document.f1.email.value==""){

		alert("ERROR: Por favor ingrese su Email");

		document.f1.email.focus();

		return false;

	}else if(document.f1.telefono.value==""){

		alert("ERROR: Por favor ingrese su Telefono");

		document.f1.telefono.focus();

		return false;

	}else if(document.f1.mensaje.value==""){

		alert("ERROR: Por favor dejenos su comentario");

		document.f1.mensaje.focus();

		return false;

	}else{

		document.f1.action="enviar.php";

		document.f1.submit();

		

	}

	

}



function estado_paginador(k){

	

	$("#p"+k).css({background: "#E4E4E4",color: "#333"});

}



	




