function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function AbrirCentrado(theURL,winName,features,ancho,alto)
{
	neu=window.open(theURL,winName,features);
	neu.focus()
	neu.moveTo(Math.round((screen.availWidth-ancho)/2),Math.round((screen.availHeight-alto)/2))  
}

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_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_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_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 IsDigit()
{
	return (((event.keyCode >= 48) && (event.keyCode <= 57)) ||  (event.keyCode == 37))
}

function AbrirVentanaMantener(theURL,winName,features)
{
   
	neu=window.open(theURL,winName,features);
	neu.focus()
	neu.moveTo(Math.round((screen.availWidth-952)/2),Math.round((screen.availHeight-240)/2))  
}

function AbrirVentana(theURL,winName,features)
{
	var camb = features;
	if (camb.indexOf('top',0) < 0) {
		camb = camb + ',top=216';
	} 
	if (camb.indexOf('left',0) < 0) {
		camb = camb + ',left=159';
	} 
	if (camb.indexOf('width',0) < 0) {
		camb = camb + ',width=500';
	} 
	if (camb.indexOf('height',0) < 0) {
		camb = camb + ',height=350';
	} 
	
	neu=window.open(theURL,winName,camb);
	neu.focus()
	
}

function Arroba(sString)
{
	var str = sString.value
	if (str != ''){
		// Return false if e-mail field does not contain a '@' and '.' .   
		if (str.indexOf ('@',0) == -1 || str.indexOf ('.',0) == -1)
		{
			alert('Introduzca correctamente el E-mail')
			sString.focus()
			return false;     
		}else{
			return true;      
		}
	}else{
		return true;
	}
}

function Arroba_Formulario(sString)
{
	var str = sString
	if (str != ''){
		// Return false if e-mail field does not contain a '@' and '.' .   
		if (str.indexOf ('@',0) == -1 || str.indexOf ('.',0) == -1)
		{
			return false;     
		}else{
			return true;      
		}
	}else{
		return true;
	}
}

function VentanaCentrada(URL,ancho, alto, estilo, titulo)
{
  var width=ancho; height=alto;
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  
  var styleStr = '';
  
  if (estilo == '') {
	   styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  } else {
	  styleStr = estilo + ',width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  }

  
   var msgWindow = window.open(URL, titulo, styleStr);
  msgWindow.focus();
 //	msgWindow.document.title = titulo;
}


function validaEnter(e, nombre_form){
	if(e.keyCode==13){
		obj_temp = eval("document."+nombre_form);
		if(obj_temp){
			obj_temp.usuario_acceso.blur();
			obj_temp.pwd_acceso.blur();
			validaAcceso();
		}
	}
}

function IsDigitFF(e)
{
var key = window.event ? e.keyCode : e.which;
var keychar = String.fromCharCode(key);
reg = /[0-9]/;
return (reg.test(keychar) || e.keyCode == 8)
}

function IsDigitComaFF(e)
{
var key = window.event ? e.keyCode : e.which;
var keychar = String.fromCharCode(key);
reg = /[0-9,]/;
return (reg.test(keychar) || e.keyCode == 8)
}

function AbrirVentanaAL(theURL,winName,features)
{
	var camb = features;
	if (camb.indexOf('top',0) < 0) {
		camb = camb + ',top=216';
	} 
	if (camb.indexOf('left',0) < 0) {
		camb = camb + ',left=159';
	} 
	if (camb.indexOf('width',0) < 0) {
		camb = camb + ',width=500';
	} 
	if (camb.indexOf('height',0) < 0) {
		camb = camb + ',height=350';
	} 
	
	neu=window.open(theURL,winName,camb);
	neu.focus()
	
}

function NuevoAjax(){
		
	var xmlhttp=false; 
		try { 
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
		} 
		catch (e) { 
			try { 
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			} 
			catch (E) { 
				xmlhttp = false; 
			} 
		}
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
	
	function aleatorio(inferior,superior){ 
		numPosibilidades = superior - inferior 
		aleat = Math.random() * numPosibilidades 
		aleat = Math.round(aleat) 
		return parseInt(inferior) + aleat 
	} 
	
	function posicionaCapa(nombre_capa){
	
	if (window.pageYOffset)
	{
		scrollTop = window.pageYOffset;
	}
	else
	{
		scrollTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
	}
	obj_capa = eval("document.getElementById(\""+nombre_capa+"\")");
	var ancho_array = obj_capa.style.width.split("p");
	var left_temp = 0;
	obj_capa.style.top = scrollTop+'px';
	obj_capa.style.left = left_temp + 'px';
	}