// JavaScript Document
dia=new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
mes=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
contador=0
function fecha() { 
fechaactual=new Date();
if((fechaactual.getHours()>=1) && (fechaactual.getHours()<=12))
{
	saludo="Buenos días";
}else{saludo="Buenas tardes";
	}
	
	dia1=dia[fechaactual.getDay()]+" "+fechaactual.getDate();
	mes1=mes[fechaactual.getMonth()];
    hora=fechaactual.getHours()
	ano=fechaactual.getYear() 
    minutos=fechaactual.getMinutes();
	segundos=fechaactual.getSeconds();
    estado=saludo+", Bienvenido a  ETRASACAP, Certificado de Aptitud Profesional"+" , hoy es "+ dia1+ " del "+ mes1+ " de "+ ano+ " , y son las " +hora +":"+minutos+":"+segundos+"                        ";
    window.status =estado
	setTimeout("fecha()",1*1000);
	window.status=estado.substring(contador,estado.length) + estado.substring(0,contador-1);
	if (contador<estado.length){
		contador++}
	else {contador=0}	
}
function cambiarImagen(){ 
    if (((screen.width == 800) && (screen.height == 600))||
	   ((screen.width == 1280) && (screen.height == 600 || screen.height == 720 ||screen.height == 768 || screen.height == 960))){ 
		moverFondo('');
	}
    if ((screen.width == 1024) && (screen.height == 768)){ 
		moverFondo('img/bordeweb1024.gif');
		moverCabecera(124);
	}
	if ((screen.width == 1152) && (screen.height == 864)){ 
		moverFondo('img/bordeweb1152.gif');
		moverCabecera(187);
	} 
	if ((screen.width == 1280) && (screen.height == 1024)){
		moverFondo('img/bordeweb1280.gif');
		moverCabecera(252.9);
	}
} 
function travesia(){
window.open("http://www.revistatravesia.es/pdf/portada.pdf",'','');
}

function borrardescarga(id,img,archivo,estado) { 
if(confirm('Va a proceder a borrar una descarga, ¿Está seguro?'))
	window.open("gestiondescargasok.php?id="+ id +"&img="+ img + "&archivo="+ archivo +"&estado="+ estado,"mainFrame");
else
return false;
}
function borrarnoticia(id,img,estado) { 
if(confirm('Va a proceder a borrar una noticia, ¿Está seguro?'))
	window.open("gestionnoticiasok.php?id="+ id +"&img="+ img +"&estado="+ estado,"mainFrame");
else
return false;
}
function borrarfaq(id,estado) { 
if(confirm('Va a proceder a borrar una pregunta, ¿Está seguro?'))
	window.open("gestionfaqok.php?id="+ id +"&estado="+ estado,"mainFrame");
else
return false;
}
function borrarinfo(id,estado) { 
if(confirm('Va a proceder a borrar una oficina, ¿Está seguro?'))
	window.open("gestioninfook.php?id="+ id +"&estado="+ estado,"mainFrame");
else
return false;
}
function borraranuncio(id,img,estado) { 
if(confirm('Va a proceder a borrar un anuncio, ¿Está seguro?'))
	window.open("gestionanunciosok.php?id="+ id +"&img="+ img +"&estado="+ estado,"mainFrame");
else
return false;
}
function confirmardescarga(estado){
if (estado=="MODIFICAR")
	if(confirm('Va a proceder a modificar una descarga, ¿Está seguro?'))this.form1.submit();
	else
	return false;

if (estado=="NUEVO")
	if(confirm('Va a proceder a dar de alta una descarga, ¿Está seguro?'))this.form1.submit();
	else
	return false;
ver();
}
function confirmarfaq(estado){
if (estado=="MODIFICAR")
	if(confirm('Va a proceder a modificar una pregunta, ¿Está seguro?'))this.form1.submit();
	else
	return false;
if (estado=="NUEVO")
	if(confirm('Va a proceder a dar de alta una pregunta, ¿Está seguro?'))this.form1.submit();
	else
	return false;
}
function confirmarnoticia(estado){
if (estado=="MODIFICAR")
	if(confirm('Va a proceder a modificar una noticia, ¿Está seguro?'))this.form1.submit();
	else
	return false;
if (estado=="NUEVO")
	if(confirm('Va a proceder a dar de alta una noticia, ¿Está seguro?'))this.form1.submit();
	else
	return false;
ver();
}
function confirmarinfo(estado){
if (estado=="MODIFICAR")
	if(confirm('Va a proceder a modificar una oficina, ¿Está seguro?'))this.form1.submit();
	else
	return false;
if (estado=="NUEVO")
	if(confirm('Va a proceder a dar de alta una oficina, ¿Está seguro?'))this.form1.submit();
	else
	return false;
}
function confirmaranuncio(estado){
if (estado=="MODIFICAR")
	if(confirm('Va a proceder a modificar un anuncio, ¿Está seguro?'))this.form1.submit();
	else
	return false;
if (estado=="NUEVO")
	if(confirm('Va a proceder a dar de alta un anuncio, ¿Está seguro?'))this.form1.submit();
	else
	return false;
ver();
}
function abriroficina(id,zona){
	window.open("oficinas.php?id="+ id +"&zona="+ zona,"_blank","'toolbar=1,scrollbars=no,left=270,top=240,width=510,height=420'");
}
function ocultar(){
var navegador = navigator.appName
//if internet
if (navegador == "Microsoft Internet Explorer") 
	if(document.getElementById){
	   document.getElementById("layer1").style.visibility = 'hidden'
	}
//if firefox
if (navegador == "Netscape") 
	var miPopup=document.getElementById("Layer1");
	miPopup.style.display = 'none';
}

function cerrarpreload(){
if(document.getElementById){
   document.getElementById("preload").style.visibility = 'hidden'
   }
}
function ver(){
var navegador = navigator.appName
if (navegador == "Microsoft Internet Explorer") 
	if(document.getElementById){
	   document.getElementById("layer1").style.visibility = 'visible'
	}

if (navegador == "Netscape") 
	var miPopup=document.getElementById("Layer1");
	miPopup.style.display = 'inline';

}

function enviar_correo()
{
        envio=0;
		if ((envio==0) && (document.formu.tipoinfo.value=="Selecciona..."))
        {
                alert("Debe escoger el tipo de información que desea recibir","Tipo de Información");
                envio=1;
                document.formu.tipoinfo.focus();
        }
		
		if ((envio==0) && (document.formu.nombre.value.length==0))
        {
                alert("El campo Nombre esta vacío y es necesario para el envío de su mensaje. Por favor, rellénelo");
                envio=1;
                document.formu.nombre.focus();
        }
        if ((envio==0) && (!checkEspacios("document.formu.nombre")))
        {
                alert("El campo Nombre solamente contiene un espacio en blanco o comienza por él. Por favor, corríjalo");
                envio=1;
                document.formu.nombre.focus();
        }
		if ((envio==0) && (document.formu.poblacion.value.length==0))
        {
                alert("El campo Población esta vacío y es necesario para el envío de su mensaje. Por favor, rellénelo");
                envio=1;
                document.formu.poblacion.focus();
        }
        if ((envio==0) && (!checkEspacios("document.formu.poblacion")))
        {
                alert("El campo Población solamente contiene un espacio en blanco o comienza por él. Por favor, corríjalo");
                envio=1;
                document.formu.poblacion.focus();
        }
        if ((envio==0) && (document.formu.asunto.value.length==0))
        {
                alert("El campo Asunto esta vacío y es necesario para el envío de su mensaje. Por favor, rellénelo");
                envio=1;
                document.formu.asunto.focus();
        }
        if ((envio==0) && (!checkEspacios("document.formu.asunto")))
        {
                alert("El campo Asunto solamente contiene un espacio en blanco o comienza por él. Por favor, corríjalo");
                envio=1;
                document.formu.asunto.focus();
        }
        if ((envio==0) && (document.formu.email.value.length==0))
        {
                alert("El campo Email de contacto esta vacío y es necesario para el envío de su mensaje. Por favor, rellénelo");
                envio=1;
                document.formu.email.focus();
        }

        if ((envio==0) && (!checkEspacios("document.formu.email")))
        {
                alert("El campo Email solamente contiene un espacio en blanco o comienza por él. Por favor, corríjalo");
                envio=1;
                document.formu.email.focus();
        }
        if ((envio==0) && (document.formu.email.value.indexOf("@")==-1))
        {
                alert("El Email que suministra no es una dirección de correo válida. Por favor, corríjalo");
                envio=1;
                document.formu.email.focus();
        }
        if ((envio==0) && (document.formu.contenido.value.length==0))
        {
                alert("El campo Contenido del mensaje esta vacío y es necesario para su envío. Por favor, rellénelo");
                envio=1;
                document.formu.contenido.focus();
        }
        if ((envio==0) && (!checkEspacios("document.formu.contenido")))
        {
                alert("El campo Contenido solamente contiene un espacio en blanco o comienza por él. Por favor, corríjalo");
                envio=1;
                document.formu.contenido.focus();
        }
        if (envio==0)
        {
                document.formu.submit();
        }
}
function ActualizarConFiltroUsuario(pass){
var indice =usuariofiltro.selectedIndex;
var textoEscogido = usuariofiltro.options[indice].text;
if (pass=="Nogales2008"){
window.location="index1.php?usuariofiltro="+textoEscogido;}
else{window.location="index3.php?usuariofiltro="+textoEscogido;}
}
function closePopup() {//se pone así para que sea compatible con firefox
	var miPopup=document.getElementById("Layer2");
	miPopup.style.display = 'none';
}
function moverCabecera(coordenada){//se pone así para que sea compatible con firefox
	var miObjeto = document.getElementById("Layer1");
	x = parseInt(miObjeto.style.left);
	x = coordenada;
	miObjeto.style.left = x + "px";
}
function moverFondo(coordenada1){//se pone así para que sea compatible con firefox
	var obj = document.getElementById('miBody');
  	obj.setAttribute('background', coordenada1);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function sI() { //v3.0
  var i,j=0,x,a=sI.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function checkEspacios(dato) {
        var c=eval(dato+".value.charAt(0)");
        if (c==" ") return false
        else return true;
}
