//valida un email
function validarEmail(valor) { 
	valor = trim(valor);

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
		return true
	} 
	else {
    	return false;
	}
}

//saco blancos al principio y al final
function trim(cadena) {
   cadena = cadena.replace(/^\s+/, '');
   cadena = cadena.replace(/\s+$/, '');
	return cadena;
}

//---------------------------------------------------------------------//
/*function incrementarClicks(id_c){
	var iframe = document.createElement("iframe");
	iframe.src = 'incrementarClicks.php?id_camp=' + id_c;
	iframe.style.zIndex = 10;
	iframe.height = '0px';
	iframe.id = "iframetemp";
	document.getElementsByTagName("BODY").item(0).appendChild(iframe);
	iframe.onLoad = closeIfr();
	
	return;
}*/
//---------------------------------------------------------------------//
function marqueeStop(){
	document.getElementById("marq").stop();
	document.getElementById("marqueeplay").style.display = "block";
	document.getElementById("marqueestop").style.display = "none";
}
function marqueePlay(){
	document.getElementById("marq").start();
	document.getElementById("marqueeplay").style.display = "none";
	document.getElementById("marqueestop").style.display = "block";
}
//---------------------------------------------------------------------//
function closeIfr(){
	setTimeout("document.getElementsByTagName('BODY').item(0).removeChild(document.getElementById('iframetemp'));",1000);
}
//---------------------------------------------------------------------//
function validarContacto(){
	var oCad = "";
	var bool = true;	
	var oMsjCto = document.getElementById("msjContacto");
	var oNombre = document.getElementById("nombre");
	var oEmail = document.getElementById("email");
	var oComentario = document.getElementById("comentario");
	
	
	if(trim(oNombre.value) == ""){
		oCad += "Por favor complete su nombre<br>";
		bool = false;
	}
	
	if(!validarEmail(oEmail.value) || trim(oEmail.value) == ""){
		oCad += "El e-mail está vac&iacute;o o su formato es incorrecto<br>";
		bool = false;
	}
	
	if(trim(oComentario.value) == ""){
		oCad += "Por favor ingrese un comentario<br>";
		bool = false;
	}
	
	if(bool){
		return true;
	}
	else{
		oMsjCto.style.display = "block";
		oMsjCto.innerHTML = oCad;
		return false;
	}
}

//---------------------------------------------------------------------//
function validarLogin(){
	var oUsr = document.getElementById("usr");
	var oPsw = document.getElementById("psw");
	var oMsjLogin = document.getElementById("msjLogin");
	
	if(trim(oUsr.value) == "" || trim(oPsw.value) == ""){
		oMsjLogin.style.display = "block";
		oMsjLogin.innerHTML = "Por favor, ingrese su usuario y password.";
		
		return false;
	}else	return true;
}



//---------------------------------------------------------------------//

function validarConcurso(){
	var oCad = "";
	var bool = true;	
	var oMsjCto = document.getElementById("msjContacto");
	var oNombre = document.getElementById("nombre");
	var oEmail = document.getElementById("email");
	var oDestino = document.getElementById("destino");
	
	
	if(trim(oNombre.value) == ""){
		oCad += "Por favor complete su nombre<br>";
		bool = false;
	}
	
	if(!validarEmail(oEmail.value) || trim(oEmail.value) == ""){
		oCad += "El e-mail está vac&iacute;o o su formato es incorrecto<br>";
		bool = false;
	}
	
	if(trim(oDestino.value) == ""){
		oCad += "Por favor ingrese un destino<br>";
		bool = false;
	}
	
	if(bool){
		return true;
	}
	else{
		oMsjCto.style.display = "block";
		oMsjCto.innerHTML = oCad;
		return false;
	}
}

function ciudades()
{	
	var oDivRetorno = document.getElementById("ciudades");
	
	
	oXML = crearObjetoAjax();
	oXML.open("GET","/tiempo/personalizar.php");
	
	oXML.onreadystatechange = function(){
		//alert (oXML.readyState);
		if (oXML.readyState == 4 ){			
			var resp = oXML.responseText;
			document.getElementById("ciudades").innerHTML=resp;
			
		}						
	}
	
	oXML.send(null);
	
	
}
//--------------------------------------------------
function showResponse(originalRequest){	

	document.getElementById("ciudades").innerHTML=originalRequest.responseText;
	//$('logoAjaxLoad').hide();
	
}

//--------------------------------------------------
//--------------Home turismo---------------
//--------------------------------------------------
function mostrar_solapa(id){	
ocultar_solapa();	
objt=document.getElementById(id);
if(objt){

	objt.style.display = 'block';
}
}
function ocultar_solapa(){	
document.getElementById("solapa_encuesta").style.display = 'none';
document.getElementById("solapa_editorial").style.display = 'none';
document.getElementById("solapa_correo").style.display = 'none';

}

function agrandarTexto()
{
	if (titulo < 48) { titulo=titulo+1;
	                    autor=autor+1;
	                    volanta=volanta+1;
						copete=copete+1;
						desarrollo=desarrollo+1; }
						
	document.getElementById('titulo').className=titulo_class + titulo;
	//document.getElementById('autor').className= autor_class + autor;
	document.getElementById('copete').className=copete_class + copete;
	document.getElementById('volanta').className=volanta_class + volanta;
	document.getElementById('desarrollo').className=desarrollo_class + desarrollo;
}

function achicarTexto()
{
	if (autor > 9) {  titulo=titulo-1;
	                  autor=autor-1;
	                  copete=copete-1;
				      volanta=volanta-1;
					  desarrollo=desarrollo-1; }
						
	document.getElementById('titulo').className=titulo_class + titulo;
	//document.getElementById('autor').className=autor_class + autor;
	document.getElementById('copete').className=copete_class + copete;
	document.getElementById('volanta').className=volanta_class + volanta;
	document.getElementById('desarrollo').className=desarrollo_class + desarrollo;
}

function eval_lectores(){
	
	var oEmail = document.getElementById("email");
	var oNombre = document.getElementById("nombre");
	//var oAsunto = document.getElementById("asunto");
	var oDesarrollo = document.getElementById("desarrollo");
	
	var oCad="";
	var bool=true;
	
	if(trim(oNombre.value) == ""){
		oCad += "Por favor complete su nombre.\n";
		bool = false;
	}
	
	/*if(trim(oAsunto.value) == ""){
		oCad += "Por favor complete el Asunto.\n";
		bool = false;
	}*/
	
	if(trim(oDesarrollo.value) == ""){
		oCad += "Por favor complete el Contenido.\n";
		bool = false;
	}
	
	
	if(!validarEmail(oEmail.value) || trim(oEmail.value) == ""){
		oCad += "El e-mail está vacío o su formato es incorrecto.\n";
		bool = false;
	}
	
	
	if(bool){
		return true;
	}
	else{
		alert(oCad);
		return false;
	}
	
}

function abrir_audio(id){	
objt=document.getElementById(id);
if(objt){

	objt.style.display = 'block';
}
}
