
//
// Copyright NETYDEA - 2002
// http://www.netydea.com
// E-mail: info@netydea.com
// Telefono: (34) 93 238 71 79
//
// declaraci&oacute;n de variables	

var esie = false;
var esns = false;
var esns6=false;
var version = 0;
var elnav9= "";
if (document.all) {
  esie=true;
}
else if (document.layers) {
  esns=true;
}
else if (document.getElementById) {
  esns6=true;
}



// reload con netscape

function MM_reloadPage(init) {
  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);


// FUNCIONES

function subire(capa){
param = eval ("'" + capa + "'");
if (abajo < limite) {
arriba = arriba + valcam;
abajo = abajo + valcam;

if (esie){
	var rectstring = "rect(" + arriba + ",auto," + abajo + ",auto)";
	lacapie =	eval("document.all." + param + ".style")
	lacapie.clip = rectstring;
}
if (esns){
document [capa].clip.top = arriba;
document [capa].clip.bottom = abajo;
}
moveby (param,0,-valcam);

}
}

function bajare(capa){

param = eval ("'" + capa + "'");

if (arriba > 0) {
arriba = arriba - valcam;
abajo = abajo - valcam;

if (esie){
var rectstring = "rect(" + arriba + ",auto," + abajo + ",auto)";
	lacapie =	eval("document.all." + param + ".style");

	lacapie.clip = rectstring;
}
if (esns){
document [capa].clip.top = arriba;
document [capa].clip.bottom = abajo;
}
moveby (capa,0,valcam);


}
}

function subire2(){
if (carga2) {
mover = setInterval ('subire(\'contetxt\');',tiempo);
}
}
function bajare2(){
if (carga2) {
mover = setInterval ('bajare(\'contetxt\');',tiempo);
}
}

function parar(){
if (carga2) {
clearInterval (mover);
}
}

function moveby (capa2,diX,diY){
if (esns) {
capa = eval("document.layers['" + capa2 + "']");
capa.left = capa.left + diX;
capa.top = capa.top + diY;
}
if (esie) {
capa = eval("document.all." + capa2 );
capa.style.left = capa.style.pixelLeft + diX;
capa.style.top = capa.style.pixelTop + diY;
}
return true;
}


// inicio de la operación de arrastre
function begin_event(capa,e) {
          current_object = capa;
		if (esns){objectX = e.pageX;objectY = e.pageY;window.captureEvents(Event.MOUSEMOVE);}
		if (esie) {e = window.event;objectX = event.x;objectY = event.y;}
}

// movimiento real del ratón, reubicación del elemento



// fin de operación de arrastre
function end_event() {
	if (esns){window.releaseEvents(Event.MOUSEMOVE);}
	current_object = null;
	return true;
}

function nueva_opc (opci) {
if (laopci!=opci) {

	img_act ("tituimg",30+opci,0,"titulo","0");
	img_act ("cuaimg",50+opci,0,"cuadro","0");
}
laopci = opci
}

// cambio de imagenes

function img_act(imgName,numecamb,onoff,capac1,capac2) {
if (cargado==1){
if (numecamb!=imgactiv) {
	if (esie) document [imgName].src = preImg[numecamb + onoff].src;
	
	if (esns) {
		frase = docu + capac1;
			if (capac2!= "0"){frase = (frase + "." + docu + capac2)}
		frase = (frase + ".document.images[imgName]");
		frase = eval (frase);
		frase.src = preImg[numecamb + onoff].src;
		frase = "";
	}
}
}
}


//
// cambio de imagenes - nombre, numecambio, 1 si on, capa
//
function img_act2(imgName,numecamb,onoff,capac1,fr) {
if (cargado==1){
	if (esie) document [imgName].src = preImg[numecamb + onoff].src;
	
	if (esns) {
		frase = docu + capac1;
		
		frase = (frase + ".document.images['"+ imgName + "']");

frase2 = eval(frase);

		frase2.src = preImg[numecamb + onoff].src;
		frase = "";
	}
}
}


// mostrar capas

function mostrar (capac1) {
if (esie) {document.all.item(capac1).style.visibility = "inherit";}
if (esns) {
	frase = docu + capac1;
	frase = eval (frase);
	frase.visibility = "show";
	frase = "";
		}
}

// esconder capas
function esconder (capac1) {
if (esie) {document.all.item(capac1).style.visibility = "hidden";}
if (esns) {
	frase = docu + capac1;
	frase = eval (frase);
	frase.visibility = "hidden";
	frase = "";
	}
}




// mover arriba y abajo

function mover(e) {
	
	}
	
function recolocar(capamov,diX,diY) {
if (esns) {
capa = eval ("document."+capamov);
capa.left = diX;
capa.top = diY;
}
if (esie) {
capa = eval ("document.all."+capamov);
capa.style.left = diX;
capa.style.top = diY;
}
return true;
}


function escribir(valor)
{
lafra = txtnavini + txtnav[valor] + txtnavfin;

    if (esie) {document.all.txtnav.innerHTML=lafra;}
	if (esns) {document.txtnav.document.open();document.txtnav.document.write (lafra);document.txtnav.document.close();}
}

// parametros: pagina, width, height, top, left,scrolls
function abven2 (pag,w,h,t,l,s) 
{
  ventana=window.open(pag,'sundisa1','scrollbars='+ s +',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,top='+ t + ',left='+ l + ',width='+ w + ',height=' + h);
}

function abven3 (pag,w,h,t,l,s) 
{
  ventana=window.open(pag,'sundisa2','scrollbars='+ s +',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,top='+ t + ',left='+ l + ',width='+ w + ',height=' + h);
}

// parametros: pagina, width, height, top, left
function abven (pag,w,h,t,l) {
posicion = "";
if (t!=null) {posicion = ',top=' + t + ',left=' + l};

strF = "window.open('"+ pag + "','himel','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,width=" + w + ",height=" + h + posicion + "')";
strV = "window.open('','himel','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,width=0,height=0')";

 if (elnav9 == "NT4" && window.whimel22){
      if (whimel22.name == "himel") whimel22.close();
 }
if (elnav9 == "IE"){
   if (window.whimel22){
     whimel22 = eval(strV);
     whimel22.close();
     setTimeout("whimel22 = eval(strF)",500);
   } 
   else whimel22 = eval(strF);
 }
 if(elnav9 != "IE") whimel22 = eval(strF);

}

function cerrarven () {
  
strV = "window.open('','himel','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,width=0,height=0')";

 if (elnav9 == "NT4" && window.whimel22){
      if (whimel22.name == "himel") whimel22.close();
 }
  if (elnav9 == "IE"){
   if (window.whimel22){
     whimel22 = eval(strV);
     whimel22.close();
  	} 
 }
}

//vaciar inputs de espacios en blanco
//vaciar('form.campo','texto alert',1 obligatorio/0 no obligatorio)
function vaciar(caja,texto,fijo) {
obj = eval("document."+caja);

  valor="";
  for (i=0;i<obj.value.length;i++)
    if (obj.value.charAt(i)!=" ")
	  valor = valor + obj.value.charAt(i);
  obj.value = valor;

  if (obj.value=="" && fijo) {
    alert("No se ha introducido " + texto);
    obj.focus();
	return false; }

  return true;    	
}

//vaciar inputs de espacios en blanco al principio
//vaciarini('form.campo','texto alert',1 obligatorio/0 no obligatorio)
function vaciarini(caja,texto,fijo) {
obj=eval("document."+caja);
  
i=0;
while(obj.value.charAt(i)==' ')
	i++;
obj.value=obj.value.substring(i,obj.value.length);

if (obj.value=="" && fijo) {
  alert("No se ha introducido " + texto);
  obj.focus();
  return false; }

return true;    	
}

//Verifica si el campo NIF es correcto
function vnif(obj)
{ var clave = "TRWAGMYFPDXBNJZSQVHLCKE";
docum = "document."+obj;
docum = eval(docum);

if (!vaciar(obj,'el NIF',1)) return false;

dni = docum.value.substring(0,docum.value.length-1);
letra = (docum.value.substring(docum.value.length-1,docum.value.length)).toUpperCase();

fin = clave.substring(dni % 23,1+(dni % 23));

if (letra!=fin) {
  alert("El NIF es incorrecto");
  docum.select();
  docum.focus();
  return false; }
else {
  docum.value = dni + letra;
  return true; }

}

//verifica el campo email
//vmail('form.campo',1 obligatorio/0 no obligatorio)
function vmail(caja,fijo){
obj = eval("document." + caja);

if (!vaciar(caja,'el e-mail',fijo)) return false;

tiene=false;
texto=obj.value;
for (i=0;i<texto.length;i++)
  if (texto.charAt(i)=="@")
     tiene=true;
if (!tiene && fijo) {
  alert("El e-mail es incorrecto");
  obj.select();
  obj.focus();
  return false; }

return true;
}

//verifica q sean números enteros
//vnum ('form.campo','texto alert')
function vnum (caja,texto) {
var nstr="0123456789";
obj = eval("document." + caja);

if (!vaciar(caja,texto,1)) return false;

for (i=0;i<obj.value.length;i++) {
  chr=obj.value.charAt(i);
  if (nstr.indexOf(chr,0)==-1) {
    alert(texto + ' es incorrecto');
    obj.select();
    obj.focus();
    return false; }
  }

return true;
}

//función para comprobar si se ha realizado el voto de la encuesta
function comprueba() {
if (eval(pgm + '.elements[0].status') == eval(pgm + '.elements[1].status')) { alert('Por favor, indique su voto'); return false;}
return true;}

function fer_buscar() {
	if (document.all) {
		document.all.formbuscar.submit();
	}
	else {
		document.menu1.document.formbuscar.submit();
	}

}