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 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();
}

/****************** Funciones menú *************************/
var menu_id=-1;
function muestraSubmenu(id){
  if(menu_id!=-1){
    var submenu_ocultar = document.getElementById("submenu"+menu_id).style;
    //var menu_ocultar = document.getElementById("menu"+menu_id).style;
    //var menu_ocultar_a = document.getElementById("menu"+menu_id+"a").style;
    //menu_ocultar_a.color = "#000";
    //menu_ocultar.background = "#FEBD03";
    submenu_ocultar.display = "none";
  }
  if (id > 0){
    var submenu = document.getElementById("submenu"+id).style;
    var menu = document.getElementById("menu"+id).style;
    //var menu_a = document.getElementById("menu"+id+"a").style;
    //menu_a.color = "#000";
    //menu.background = "url(/img/bt-fiestas-on.gif)";
    submenu.display = "";  
    menu_id=id;
  }
 
}		
/***********************************************************/
function encuesta(idpregunta)
{
  for (i=0;i<document.encuesta.respuesta.length;i++)
  { 
    if (document.encuesta.respuesta[i].checked) 
      break; 
  }
  var respuesta = i+1;  
  llamarasincrono('includes/comun/encuesta_votos.asp?idpregunta='+idpregunta+'&respuesta='+respuesta, 'encuesta');  
}
/*************** Funcion paginar *******************/
function paginar()
{
  document.fpaginacion.INDICE.value = document.fpaginacion.selectpag.value;
  document.fpaginacion.submit();
}

/******** Reproductor *********/
function reproduceAudio(audio)
{
  var reproductor = new SWFObject("/reproductor.swf?audio="+audio, "reproduc", "180", "46", "8", "#ffffff");
  reproductor.write("reproductor_not");	
}

function reproductor(){
	var ventana=window.open("http://www.streaming.telemaco.es/vivirdigital/","reproductor","status=no, location=no, scrollbars=no, resizable=no, width=380, height=79");
	ventana.opener.top.name="opener";
	ventana.focus(); 
}
