function isEmail(str)
{
  var supported = 0;
  if (window.RegExp)
  {
  var tempStr = "a";
  var tempReg = new RegExp(tempStr);
  if (tempReg.test(tempStr))
   	supported = 1;
  }
  if (!supported)
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
		
  return (!r1.test(str) && r2.test(str));
}

function chequeo()
{
  vari = isEmail(document.envio.MAILFROM.value);
  nombre = document.envio.NOMBRE.value;  
  
  if (!vari)
	alert('Su correo electrónico no parece válido.\nIntrodúzcalo en el campo indicado.');
  else if(!nombre)
    alert('Introduzca su nombre.');
  else if(!document.envio.acepta.checked)
	alert('Tiene que aceptar la política de privacidad');    
  else
	document.envio.submit();
}

function privacidad()
{
  var vari = isEmail(document.envio.email.value);
  var login = document.envio.login.value;  
  var dni = document.envio.nif.value;    
  
  if (!vari)
	alert('Su correo electrónico no parece válido.\nIntrodúzcalo en el campo indicado.');
  else if(!login)
    alert('Introduzca un usuario.');
  else if(!dni)
    alert('Introduzca su dni.');    
  else if(!document.envio.acepta.checked)
	alert('Tiene que aceptar la política de privacidad');    
  else
	document.envio.submit();
}


function popup(id)
{
  var ventana=window.open("/includes/otras/popimg.asp?idfoto="+id,"pop","status='no',location=0,0, scrollbars=no, resizable=no,width=640,height=480");
  ventana.opener.top.name="opener";
  ventana.focus();
}
function popup2(id)
{
  var ventana=window.open("/includes/otras/popimg2.asp?idfoto="+id,"pop","status='no',location=0,0, scrollbars=no, resizable=no,width=640,height=auto");
  ventana.opener.top.name="opener";
  ventana.focus();
}
			
function js_Ventana(www,ancho,alto,titulo,target)
{
  var destino=www+'#'+target;
  var ventana=window.open(destino,titulo,'status=no,location=0,0, scrollbars=yes, resizable=no,width='+ancho+',height='+alto);
  ventana.opener.top.name="opener";
  ventana.focus();
}

/*********** banner google ***********/
  google_ad_client = "pub-6219438110321009";
  //728x90, creado 11/12/07
  //google_ad_slot = "7142802501";
  //google_ad_width = 728;
  //google_ad_height = 90;
  
  // 468x60, creado 22/09/09 
  google_ad_slot = "3155406332";
  google_ad_width = 468;
  google_ad_height = 60;
  
/**************************************/  

/*Reproductor RadioExpres*/
function abreReproductor(){
  var url = "http://www.infoexpres.es/player_radio.asp?idseccion=5920";
  var caracteristicas = "height=615,width=820,scrollTo,resizable=0,scrollbars=0,location=0";
  nueva = window.open(url, 'RadioExpres', caracteristicas);
  nueva.opener.top.name="opener";
  nueva.focus();
}

/**************** Funcion tablas resultados deportes / parrilla tv ***************/
function tabla_resultado(id, pag)
{ 
  var cache = Math.round(Math.random()*1000);
  llamarasincrono("includes/deportes/"+pag+"?idequipo="+id+"&cache="+cache, 'tablas_deportes');	
}

function tv_parrilla(id1,id2,id3)
{
  document.getElementById(id1).style.display = "";
  document.getElementById(id2).style.display = "none";
  document.getElementById(id3).style.display = "none";    
}
/***************************************/

//Añadir bookmark al del.icio.us
function dbt_bookmark() {
	//URL of this document
	var loc=location.href;
	//Strip out any anchors
	var apos=loc.indexOf('#');
	loc=(apos>0?loc.substring(0,apos):loc);
	//Redirect to del.icio.us
	location.href='http://del.icio.us/post?v=2&url='
	+ encodeURIComponent(loc)
	+'&title='
	+encodeURIComponent(document.title);
	//Return false so the link won't be activated. 
	return false;
}

//Añadir bookmark al meneame.net
function meneame() {
	//URL of this document
	var loc=location.href;
	//Strip out any anchors
	var apos=loc.indexOf('#');
	loc=(apos>0?loc.substring(0,apos):loc);
	//Redirect to meneame
	location.href='http://meneame.net/submit.php?url='
	+ encodeURIComponent(loc);
	//	alert(encodeURIComponent(loc));
	//Return false so the link won't be activated. 
	return false;
}

/********* Funciones Radio Expres en Directo **********/
function radio_endirecto()
{ 
  var cache = Math.round(Math.random()*1000);
  llamarasincrono("datos/partido/ajax.txt?cache="+cache,'ajax_caratula'); // ajax.asp?funcion=radio_endirecto
  timer = setTimeout("radio_endirecto()", 60000);
}
function radio_endirectoPartido()
{ 
  var cache = Math.round(Math.random()*1000);
  llamarasincrono("datos/partido/ajax.txt?cache="+cache,'ajax_caratula'); // ajax.asp?funcion=radio_endirecto
}
/***************************************/

function loadTiempo(sitio){
  document.getElementById('ico_load_tiempo').style.display='';  
  ajax('load','includes/eltiempo/carga_tiempo.asp?sitio='+sitio,'carga_tiempo',tiempo_ok);
}
function tiempo_ok(){	
  document.getElementById('ico_load_tiempo').style.display='none';	
}

function selecciona(playa){
  var playas=new Array("elche","marina","arenales","tamarit","varadero");
  for (var i=0; i<playas.length; i++){
  	document.getElementById(playas[i]).className = "btn_tiempo";
  }
  document.getElementById(playa).className = "btn_tiempo playa_sel";
  
}

/************************************ Funciones el partido **************************************/
function carga_elpartido()
{ 
  //alert("Me llaman");
  var cache = Math.round(Math.random()*1000);
  llamarasincrono("datos/partido/ultima_hora.txt?cache="+cache, 'elpartido'); // includes/ultima_hora_elchecf.asp
  llamarasincrono("datos/partido/foto_partido.txt?cache="+cache, 'imagen_partido'); // includes/foto_partido_ajax.asp
  llamarasincrono("datos/partido/comentarios_oyentes.txt?cache="+cache, 'elpartidoOyentes'); //includes/player_radio/comentarios_oyentes_ajax.asp
  
  timer = setTimeout("carga_elpartido()", 60000);
}
function carga_partido(id)
{ 
  var cache = Math.round(Math.random()*1000);
  llamarasincrono("includes/elpartido_cen.asp?idnoticia="+id+"&cache="+cache, 'partido');	
  timer = setTimeout("carga_partido("+id+")", 60000);
}
/*******************************/
/******** Reproductor *********/
function reproduceAudio(audio)
{ 
  var reproductor = new SWFObject("/reproductor.swf?audio="+audio, "reproduc", "363", "60", "9", "#ffffff");
  reproductor.write("reproductor_not");	
}

function lanzaAudio(idnot,fich_audio,selpag)
{ 
  ajax('load','/includes/noticia/noticia_multimedia.asp?idnoticia='+idnot+'&posvideo='+selpag+'&v=0&au=1','galeria',audio_ok);
  
  function audio_ok(){
    var reproductor = new SWFObject("/reproductor.swf?audio="+fich_audio, "reproduc", "363", "60", "9", "#ffffff");
    reproductor.write("reproductor_not");
  }
}

function cargaVideo(){ //Para los videos de las noticias al ser ajax
    flowplayer("player_new", "flowplayer/flowplayer-3.1.5.swf", {
         
    plugins:  { 
        controls: { 
        
        	// setup auto hide 
	        autoHide: 'always',    
             
            // tooltips configuration 
            tooltips: { 
                 
                // enable english tooltips on all buttons 
                buttons: true, 
                 
                // customized texts for buttons 
                play: 'Reproducir', 
                pause: 'Parar', 
                fullscreen: 'Pantalla Completa',
                fullscreenExit: 'Salir de pantalla completa'
            }, 
             
            // background color for all tooltips 
            tooltipColor: '#112233', 
             
            // text color 
            tooltipTextColor: '#FFFFFF'  
        } 
    },
    
    // pause on first frame of the video 
    clip: { 
        autoPlay: false, 
        autoBuffering: true 
    } 
     
});}

function antispam(){
  var anonimo = document.getElementById('anonimo');
  var usureg= document.getElementById('usureg');
  if(anonimo.value=='anonimo' && anonimo.checked){
    //alert('anonimo sel');
    document.forms.opinar.submit()
  }else  if(usureg.value=='usureg' && usureg.checked){
    //alert('registrado sel');
    document.forms.opinar.submit()
  }else{
    alert('Debe seleccionar la casilla');
  }
}
