// 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"); 			   
		}); 	  
	});	
	
	hs.showCredits = false;
	hs.graphicsDir = 'aplication/webroot/imgs/graphics/';
	hs.outlineType = 'rounded-white';
	
});
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({color: "#626200"});
}

$(document).ready(function(){
	$('#resultado').empty();
	$('#resultado').hide();
		
	$('#resultado').ajaxStart(function(){
	$('#resultado').html('<br><br><br><center><img src="aplication/webroot/imgs/icons/ajax-loader.gif"><br><br><span style="color:#B13838"> Cargando Resultados...</span> </center>');		
		}).fadeIn('slow').load("detalle.php"); 
	
/*listado de recursos*/	
	
	
	$("#listado_recursos li a").each(function(index){
		$("#recurso"+index).click(function(){
			var title = 	$(this).attr("title");

		$('#recursos').empty();
		$('#recursos').hide();
			
		$('#recursos').ajaxStart(function(){
		$('#recursos').html('<br><br><br><center><img src="aplication/webroot/imgs/icons/ajax-loader.gif"><br><br><span style="color:#B13838"> Cargando Resultados...</span> </center>');		
		}).fadeIn('slow').load("recursos_listados.php?r="+title); 
		});								 
	});
});

function pagina(x,pag){
		$('#resultado').empty();
		$('#resultado').hide();
		
		$('#resultado').ajaxStart(function(){
		$('#resultado').html('<br><br><br><center><img src="aplication/webroot/imgs/icons/ajax-loader.gif"><br><br><span style="color:#B13838"> Cargando Resultados...</span> </center>');		
		}).fadeIn('slow').load("detalle.php?pag="+x); 
		
}
function detalle(id){
		$('#resultado').empty();
		$('#resultado').hide();
		
		$('#resultado').ajaxStart(function(){
		$('#resultado').html('<br><br><br><center><img src="aplication/webroot/imgs/icons/ajax-loader.gif"><br><br><span style="color:#B13838"> Cargando Resultados...</span> </center>');		
		}).fadeIn('slow').load("detalle.php?id="+id); 
		
}

function ventana(){
	
	window.open("acerca.php","","width=650,height=700,left=400,top=300,scrollbars=yes,location=no");
	}
function ventana2(){	
	window.open("todogastronomia.php","","width=950,height=700,left=400,top=300,scrollbars=yes,location=no,location=yes");
}


	

