
	function abreVentana (cual,alto, ancho) {

		var anchod=((screen.width)/2)-(ancho/2);
		
		var altod=((screen.height-16)/2)-(alto/2);
		
		window.open(cual,'','resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,width='+ancho+',height='+alto+',screenX='+anchod+',screenY='+altod+',left='+anchod+',top='+altod+'');
			
	}
	
	function abreVentanaW (alto, ancho, texto) {

		var anchod=((screen.width)/2)-(ancho/2);
		
		var altod=((screen.height-16)/2)-(alto/2);
		
		var win=window.open("about:blank",'','resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,width='+ancho+',height='+alto+',screenX='+anchod+',screenY='+altod+',left='+anchod+',top='+altod+'');
		win.document.writeln("<html><head><title>Ayuda</title><LINK rel='stylesheet' href='/xlibs/infoayudas.css' type='text/css' /></head><body>");
		win.document.writeln("<p align='right'><img src='/ximg/email_logo2.jpg' width='150' height='31' /></p>");
		win.document.writeln("<span class='texto3'>");
		win.document.writeln(texto);
		win.document.writeln("<br><br><a href='javascript:self.close()'>cerrar</a></span></body></html>");
		
		
	}

	function calculaDigito(banco, sucursal,cuenta){

		var numero, total,total1,total2,subtotal,subtotal2;
		var digitos;
		numero = 0;
		total = 0;
		subtotal = 0;
		
		numero = banco
		numero = numero + sucursal;
		total = parseInt(total + (numero%10)*6);
		numero = parseInt(numero/10);
		total = parseInt(total + (numero%10)*3);
		numero = parseInt(numero/10);
		total = parseInt(total + (numero%10)*7);
		numero = parseInt(numero/10);
		total = parseInt(total + (numero%10)*9);
		numero = parseInt(numero/10);
		total = parseInt(total + (numero%10)*10);
		numero = parseInt(numero/10);
		total = parseInt(total + (numero%10)*5);
		numero = parseInt(numero/10);
		total = parseInt(total + (numero%10)*8);
		numero = parseInt(numero/10);
		total = parseInt(total + (numero%10)*4);
		numero = parseInt(numero/10);
		total = total%11;
		subtotal = 11-(total%11)
		
		if(subtotal==11) {
		 subtotal=0;
		 }
		 else if(subtotal==10){ 
		  subtotal=1;
		}  
		total1 = 0;
		total2=0;
		total = cuenta;
		total1 = total.charAt(9);
		total2 = total1*6;
		total1 = 0
		total1= total.charAt(8);
		total2= total2 + (total1*3);
		total1=0;
		total1= total.charAt(7);
		total2= total2 + (total1*7);
		total1=0
		total1= total.charAt(6);
		total2= total2 + (total1*9);
		total1=0
		total1= total.charAt(5);
		total2= total2 + (total1*10);
		total1=0
		total1= total.charAt(4);
		total2= total2 + (total1*5);
		total1=0
		total1= total.charAt(3);
		total2= total2 + (total1*8);
		total1=0
		total1= total.charAt(2);
		total2= total2 + (total1*4);
		total1=0
		total1= total.charAt(1);
		total2= total2 + (total1*2);
		total1=0
		total1= total.charAt(0);
		total2= total2 + (total1*1);
		total = total2;
	total = total %11;
	subtotal2 = 11 - (total%11);
	if (subtotal2 == 11) {
	 subtotal2=0;
	}
	else if (subtotal2==10) {
	 subtotal2=1;
	}
	
	return(subtotal+""+subtotal2);

}
	function tstCif (cif) {
		
		cif2=cif.value;
		
		if (cif2.length<9) {
			alert ("CIF/NIF incorrecto");
			return false;
		}
		
		if (cif2.substr(0,1)=='P') return true;
		
		// Identificamos la letra
		
		var rcif=cif2.substr(0,8);
		var letra=cif2.substr(8,1);
		
		if (!isNaN(parseInt(letra))) {
		
			rcif=cif2.substr(1,8);
			letra=cif2.substr(0,1);
			
			var filter=/^\d{8}$/
			if (!filter.test(rcif)) {
				alert ("NIF incorrecto");
				  return false;
			}
			if (!filter.test(rcif)) {
				alert ("NIF incorrecto");
				  return false;
			}						
		}
		else {
	
			var filter=/^\d{8}$/
			if (!validaNIF(rcif+letra)) {
			  alert ("NIF incorrecto");
			  return false;
			}
		}
		
		if (isNaN(parseInt(rcif)) || !isNaN(parseInt(letra))) {
			alert ("CIF/NIF incorrecto");
			return false;
		}
		
		if (letra!=letra.toUpperCase()) {
			alert ("CIF/NIF incorrecto, la letra debe ir en mayúsculas");
			return false;
		}
				
		return true;
	}
	
	function checkEmail(obj) {
	
		var str=obj.value;
		var testresults=true
	
		var filter=/^.+@.+\..{2,4}$/
		if (!filter.test(str)){
			alert("E-mail inválido");
			obj.focus();
			testresults=false
		}
		return (testresults)
	}
	
	function validaNIF(nif) {
		
		var letras = 'TRWAGMYFPDXBNJZSQVHLCKE';

		if (nif.charAt(nif.length-1)!=letras.charAt(nif.substr(0,8)%23)) return false;
		return true;
	}

function cambiaImagen(sImg,sName){
 eval("document['"+sName+"'].src='"+sImg+"'");
} 

function OpenWIN(sWin,sPage,nWidth,nHeight,nLeft,nTop,bScroll,bToolbar,bLocation,bMenu,bResize,bStatus){
	sScrollbars="yes"
	if(!bToolbar)  bToolbar=0;
	if(!bLocation) bLocation=0;
	if(!bMenu)	   bMenu=0;
	if(!bResize)   bResizable=0;
	if(!bStatus)   bStatus=0;
	if(!nLeft)	   nLeft=0;
	if(!nTop)	   nTop=0;
	var sPropiedades="width="+nWidth+",height="+nHeight+",scrollbars="+sScrollbars+",toolbar="+bToolbar+",location="+bLocation+",menu="+bMenu+",resizable="+bResizable+",status="+bStatus+",hotkeys=no,fullscreen=no,left="+nLeft+",top="+nTop+"";
	eval(sWin+"=window.open(sPage,sWin,'"+sPropiedades+"')");
}



function MenuSecciones(sNombres,sLinks,nIlumina){
    
//    alert(sNombres)
//    alert(sLinks)
//    alert(nIlumina)

    if (nIlumina==null || nIlumina==0){
        nIlumina=1;        
    }
    
    var sSkinOn  = "skinpestana1";
    var sSkinOff = "skinpestana2";
    
    var sHTML = '';
    
         sHTML += '<TABLE border="0" cellpadding="0" cellspacing="0">';
         sHTML += '<TR>';

             for (n=1;n<sNombres.length;n++){
                
                if (n!=nIlumina){
                    if (n!=1){
                        sHTML += '<TD><IMG src="/pix/pestana_ralla1_01.gif" width="1" height="21" border="0" /></TD>';
                    }
                    sHTML += '<TD class="'+ sSkinOff +'"><IMG src="/pix/pestana_pri1_01.gif" width="11" height="22" border="0" /></TD>';
                    sHTML += '<TD class="'+ sSkinOff +'" background="/pix/pestana_pat1_01.gif" align="center"><A ';
                    sHTML += ' class="enlacepestana" href="'+sLinks[n]+'">'+sNombres[n]+'</A></TD>';
                    sHTML += '<TD class="'+ sSkinOff +'"><IMG src="/pix/pestana_fin1_01.gif" width="13" height="22" border="0" /></TD>';
                }
                else {
                    if (n!=1){
                        sHTML += '<TD><IMG src="/pix/pestana_ralla1_01.gif" width="1" height="21" border="0" /></TD>';
                    }
                    sHTML += '<TD class="'+ sSkinOn +'"><IMG src="/pix/pestana_pri2_01.gif" width="11" height="22" border="0" /></TD>';
                    sHTML += '<TD class="'+ sSkinOn +'" background="/pix/pestana_pat2_01.gif" align="center"><A ';
                    sHTML += ' class="enlacepestana" href="'+sLinks[nIlumina]+'">'+sNombres[nIlumina]+'</A></TD>';
                    sHTML += '<TD class="'+ sSkinOn +'"><IMG src="/pix/pestana_fin2_01.gif" width="13" height="22" border="0" /></TD>';
                }
             }

             sHTML += '<TD><IMG src="/pix/pestana_ralla2_01.gif" width="1" height="21" border="0" /></TD>';
             
         sHTML += '</TR>';
         sHTML += '</TABLE>';

    return sHTML;
}
	
	var cLateral="";
	var W3CDOM = document.getElementById;
	var navActual=getCookie("navLateral2");
	
	function chgLateral() {
		
		if (!W3CDOM) return;
				
		if (getCookie("navLateral2")==0 || navActual==1) {
			
			cLateral=document.getElementById('celdaLateral').innerHTML;
			document.getElementById('celdaLateral').innerHTML='';
			document.getElementById('celdaLateral').style.width=21;				
			document.getElementById('imgChgLateral').src="/pix/ntb/mini_mostrar.gif";
			setMyCookie(1);
			navActual=0;
		
		}
		else  {
			
			if (cLateral) {
				document.getElementById('celdaLateral').style.width='180px';
				document.getElementById('celdaLateral').innerHTML=cLateral;				
				document.getElementById('imgChgLateral').src="/pix/ntb/mini_ocultar.gif";
			}
			setMyCookie(0);
		}
	}
	
	function chgLateral2() {
		
		if (!W3CDOM) return;
				
		cLateral=document.getElementById('celdaLateral').innerHTML;
		document.getElementById('celdaLateral').innerHTML='';
		document.getElementById('celdaLateral').style.width=21;				
		document.getElementById('imgChgLateral').src="/pix/ntb/mini_mostrar.gif";

		navActual=0;
	
	}

	function setMyCookie(tipo) {
	
		var now = new Date();
		now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
		setCookie("navLateral2", tipo, now);
	
	}
	
	function setCookie(name, value, expires, path, domain, secure) {
	  var curCookie = name + "=" + escape(value) +
	      ((expires) ? "; expires=" + expires.toGMTString() : "") +
	      ((path) ? "; path=" + path : "") +
	      ((domain) ? "; domain=" + domain : "") +
	      ((secure) ? "; secure" : "");
	  document.cookie = curCookie;
	}

	function getCookie(name) {
	  var dc = document.cookie;
	  var prefix = name + "=";
	  var begin = dc.indexOf("; " + prefix);
	  if (begin == -1) {
	    begin = dc.indexOf(prefix);
	    if (begin != 0) return null;
	  } else
	    begin += 2;
	  var end = document.cookie.indexOf(";", begin);
	  if (end == -1)
	    end = dc.length;
	  return unescape(dc.substring(begin + prefix.length, end));
	}

	var _esperaFormVar=0;
	var _iniForm=0;
	
	function esperaFormInit() {
		
		if (_esperaFormVar==0) {
			_esperaFormVar=new Date();
			_esperaFormVar=_esperaFormVar.getTime()/1000;
			_iniForm=1;
		}
			
	}

	function esperaForm () {
		
		if (_iniForm==1) {
					
			_iniForm=2;	
			
			return true;		
					
		}
		else if (_iniForm==2) {
			
			var _esperaTMP=new Date();
			_esperaTMP=_esperaTMP.getTime()/1000;
			
			if (_esperaFormVar+15>_esperaTMP) {
			
				alert ("Por favor, espere, se está enviando el formulario. Si en "+(15-Math.round(_esperaTMP-_esperaFormVar))+" segundos no obtiene respuesta, vuelva a pinchar en el botón");
			
			}
			else {
				_esperaFormVar=0;
				_iniForm=0;
				esperaFormInit();
				esperaForm();
			}
		
		}
		
		return false;
			
	}