jQuery.fn.email=function()
{
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($(this).val()))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function validarFormSugerirReceta(){
	var sin_error=true;
	$("textarea").removeClass("form_error");
	$("input").removeClass("form_error");
	
	if ($("#receta_nombre").val()==""){
		$("#receta_nombre").addClass("form_error");
		sin_error=false; 
	}
	
	if ($("#receta_email").val()==""){
		$("#receta_email").addClass("form_error");
		sin_error=false; 
	}
	
	if (!$("#receta_email").email()){
		$("#receta_email").addClass("form_error");
		sin_error=false; 
	}
	
	if ($("#receta").val()==""){
		$("#receta").addClass("form_error");
		sin_error=false; 
	}

	if ($("#ingredientes").val()==""){
		$("#ingredientes").addClass("form_error");
		sin_error=false; 
	}

	if ($("#preparacion").val()==""){
		$("#preparacion").addClass("form_error");
		sin_error=false; 
	}

	if ($("#gd_string_right").val()==""){
		$("#gd_string_right").addClass("form_error");
		sin_error=false; 
	}

	if (!sin_error){
		$("#bloque_error_sugerir_receta").show();
		return false;
	}else {
		 //$("#bloque_error_sugerir_receta").hidden();
		 $("#modulo_ajx_sugRec").load("/_mod_form_receta.php", {receta_nombre: $("#receta_nombre").val(),receta_email: $("#receta_email").val(),receta: $("#receta").val(),ingredientes: $("#ingredientes").val(),preparacion: $("#preparacion").val(),gd_string_right: $("#gd_string_right").val(), enviado_sugRec: "1"});
		 return false;
		 
	}
}

function validarFormSuscribirse(){
	var sin_error=true;
	$("input").removeClass("form_error");
	
	if ($("#email_envio").val()==""){
		$("#email_envio").addClass("form_error");
		sin_error=false; 
	}
	
	if (!$("#email_envio").email()){
		$("#email_envio").addClass("form_error");
		sin_error=false; 
	}
	
	if (!sin_error){
		$("#bloque_error_sugerir_receta").show();
		return false;
	}else {
		 //$("#bloque_error_sugerir_receta").hidden();
		 $("#modulo_ajx_sugRec").load("/_mod_form_receta.php", {receta_nombre: $("#receta_nombre").val(),receta_email: $("#receta_email").val(),receta: $("#receta").val(),ingredientes: $("#ingredientes").val(),preparacion: $("#preparacion").val(),gd_string_right: $("#gd_string_right").val(), enviado_sugRec: "1"});
		 return false;
		 
	}
}

function validarFormTest(){
		var sin_error=true;
		$("textarea").removeClass("form_error");
		$("input").removeClass("form_error");
		
		if ($("#fecha_test").val()==""){
			$("#fecha_test").addClass("form_error");
			sin_error=false; 
		}

		if ($("#gd_string_test").val()==""){
			$("#gd_string_test").addClass("form_error");
			sin_error=false; 
		}
		
		if (!sin_error){
			$("#bloque_error_test").show();
			return false;
		}else {
			// $("#bloque_error_test").hidden();
			 $("#modulo_ajx_test").load("/_mod_testComp.php", {fecha_test: $("#mes_comp").val(), gd_string_test: $("#gd_string_test").val(), sexo_test: $("input[name='sexo']:checked").val(), enviado_test: "1"});
			 return false;
		}

	
}

function validarFormLogin(){
	var sin_error=true;
	$("input").removeClass("form_error");
	
	
	if ($("#login_email").val()==""){
		$("#login_email").addClass("form_error");
		sin_error=false; 
	}	
	
	if (!$("#login_email").email()){
		$("#login_email").addClass("form_error");
		sin_error=false; 
	}
	
	if ($("#login_pass").val()==""){
		$("#login_pass").addClass("form_error");
		sin_error=false; 
	}
	
	if (!sin_error){
		$("#bloque_error_test").show();
		return false;
	}else {
		// $("#bloque_error_test").hidden();
		return true;
	}


}

function validarFormPaparazzi(){
	var sin_error=true;
	$("input").removeClass("form_error");
	
	if ($("#quien").val()==""){
		$("#quien").addClass("form_error");
		sin_error=false; 
	}	
	
	if (!$("#donde").val()){
		$("#donde").addClass("form_error");
		sin_error=false; 
	}
	
	if ($("#cuando").val()==""){
		$("#cuando").addClass("form_error");
		sin_error=false; 
	}
	
	if (document.getElementById("bases").checked == false){
		$("#bases").addClass("form_error");
		sin_error=false; 
	}
	
	if (!sin_error){
		$("#bloque_error_paparazzi").show();
		return false;
	}else {
		return true;
	}


}

function hablilitar_home_votacion(selected_){
	
	for (i=1;i<=4;i++){
		document.getElementById("modulo_home_votacion_"+i).style.display='none';
		document.getElementById("zlp_home_votacion_"+i).className="c"+i;
	}
	
	document.getElementById("zlp_home_votacion_"+selected_).className="c"+selected_+" selected";
	document.getElementById("modulo_home_votacion_"+selected_).style.display='block';
}

function ajx_votar_home_votacion(modulo,id){

	$("#modulo_home_votacion_1").load("/_votar_modulo_home.php?rand="+Math.random()*100, {modulo: modulo,id: id});	
}

function ajx_listado_videos(p,tipo){
	if(tipo==0){var categoria="";}else{var categoria=tipo;}
	$("#lista_videos").load("/_listado_videos_tv.php?rand="+Math.random()*100, {p: p,tipo: categoria});	
}
function ajx_setIdVideo(id_video){
	$("#comentarios_video").load("/_mod_comentarios_videos.php?rand="+Math.random()*100, {id_video: id_video});	
}

function ajx_listado_comentarios(id,p,tabla){
	$("#comentarios_video").load("/_mod_comentarios_videos.php?rand="+Math.random()*100, {id: id,p: p,tabla: tabla});	
}

function setThumbs_home_fd(index){
	$('#_mod_fd_home_img').fadeIn(6000);
	$('#_mod_fd_home_img').attr("src",fotos_home[index].thumbs_grande);
	$('#_mod_fd_home_titulo').text(fotos_home[index].titulo);
	 
					
	//$('#_thmb_fd_'+index).attr("src",fotos_home[select].thumbs);
	//select = index;
	
	
}

function habilitar_multimedia(modulo){

	for (i=1; i<=3; i++){
		document.getElementById("zlp_multimedia_"+i).className="c"+i;
	}

	document.getElementById("zlp_multimedia_"+modulo).className="c"+modulo+" selected";

	if (modulo==1){
		$("#contenedor_multimedia").load("/_multimedia_fotos.php?rand="+Math.random()*100);
	}else if(modulo==2){
		$("#contenedor_multimedia").load("/_multimedia_galerias.php?rand="+Math.random()*100);
	}else if(modulo==3){
		$("#contenedor_multimedia").load("/_multimedia_videos.php?rand="+Math.random()*100);
	}

	
	
}


function votarModa(id,voto){
	jQuery("#moda_votar_gracias_"+id).hide();
	jQuery("#moda_votar_error_"+id).hide();
	jQuery.ajax({
		url: '/moda_votar_ajax.php',
		data: 'id='+id+'&voto='+voto,
		type:"POST",
		success:function(msg){
			rta = msg.split("|");
			if(rta[0] == "OK"){
				jQuery("#p_"+id).html(rta[1]);
				jQuery("#n_"+id).html(rta[2]);
				jQuery("#moda_votar_gracias_"+id).show();
			}else{
				jQuery("#moda_votar_error_"+id).show();
			}
		}

	});
	return false;
}

function hacermeFan(id,voto){
	//jQuery("#moda_votar_gracias_"+id).hide();
	//jQuery("#moda_votar_error_"+id).hide();
	jQuery.ajax({
		url: '/glosario_fans_ajax.php',
		data: 'id='+id+'&voto='+voto,
		type:"POST",
		success:function(msg){
			rta = msg.split("|");
			votos = rta[1] + " fans";
			if(rta[0] == "OK"){
				jQuery("#cantfans").html(votos);
				//jQuery("#moda_votar_gracias_"+id).show();
			}else{
				//jQuery("#moda_votar_error_"+id).show();
			}
		}

	});
	return false;
}
