function AjustaYear(txtVal)
{
    if (txtVal.value.length == 2)
        if (txtVal.value > "30")
            txtVal.value = "19" + txtVal.value
        else
            txtVal.value = "20" + txtVal.value
}

function Abre(sURL, sNombre)
{
    if (sNombre == undefined) sNombre = "";

	if (sURL.indexOf("l.asp") != -1 || sURL.indexOf("b.asp") != -1 || sURL.indexOf("j.asp") != -1 || sURL.indexOf("c.asp") != -1)
	{
		var ancho = screen.availWidth * 0.70;
		var alto = screen.availHeight * 0.70;
		var str = "height=" + alto + ",innerHeight=" + alto;
		str += ",width=" + ancho + ",innerWidth=" + ancho;
		if (top.window.screen) {
			str += ",left=0,screenX=" + ancho;
			str += ",top=0,screenY=" + alto;
		}
		return top.window.open(sURL, sNombre, "width="+ancho+",height="+alto+",resizable=yes,menubar=yes,scrollbars=yes,location=yes,toolbar=no,status=no,"+str);
	}
	else
	    return top.window.open(sURL);
}

function Abre2(sURL, sNombre)
{
    if (sNombre == undefined) sNombre = "";

	if (sURL.indexOf("l.asp") != -1 || sURL.indexOf("b.asp") != -1 || sURL.indexOf("j.asp") != -1 || sURL.indexOf("c.asp") != -1)
	{
		var ancho = screen.availWidth;
		var alto = screen.availHeight;
		var str = "height=" + alto + ",innerHeight=" + alto;
		str += ",width=" + ancho + ",innerWidth=" + ancho;
		if (top.window.screen) {
			str += ",left=0,screenX=" + ancho;
			str += ",top=0,screenY=" + alto;
		}
		return top.window.open(sURL, sNombre, "width="+ancho+",height="+alto+",resizable=yes,menubar=yes,scrollbars=yes,location=yes,toolbar=no,status=no,"+str);
		}
	else
	    return top.window.open(sURL);
}

var downStrokeField;
function autojump(fieldName,nextFieldName,iMaxLength)
{
var myForm=document.forms[document.forms.length - 1];
var myField=myForm.elements[fieldName];
myField.nextField=myForm.elements[nextFieldName];

if (myField.maxLength == null)
   myField.maxLength=iMaxLength;

myField.onkeydown=autojump_keyDown;
myField.onkeyup=autojump_keyUp;
}

function autojump_keyDown()
{
this.beforeLength=this.value.length;
downStrokeField=this;
}

function autojump_keyUp()
{
if (
   (this == downStrokeField) && 
   (this.value.length > this.beforeLength) && 
   (this.value.length >= this.maxLength)
   )
	{
	   this.nextField.focus();
	   this.nextField.select();
	}
downStrokeField=null;
}

var tamtexto = 2;
var divcontenido;


function retrieveCookie( cookieName ) {
	var cookieJar = document.cookie.split( "; " );
	for( var x = 0; x < cookieJar.length; x++ ) {
		var oneCookie = cookieJar[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
	}
	return null;
}

function setCookie( cookieName, cookieValue, lifeTime, path, domain, isSecure ) {
	if( !cookieName ) { return false; }
	if( lifeTime == "delete" ) { lifeTime = -10; } //this is in the past. Expires immediately.

	document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
		( lifeTime ? ";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() : "" ) +
		( path ? ";path=" + path : "") + ( domain ? ";domain=" + domain : "") + 
		( isSecure ? ";secure" : "");

	if( lifeTime < 0 ) { if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return false; } return true; }
	if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return true; } return false;
}
function imprimir()
{
	window.print();
}
var _or;
var _h;
var _hr;

function Operadores(txtVal)
{
	overlib('<a href="javascript:AddTexto(' + txtVal + ',\' AND \');" title=\'' +  CFG_MENSAJE258 + '\'>' +  CFG_MENSAJE259 + '</a><br/><a href="javascript:AddTexto(' + txtVal + ',\' OR \');" title=\'' +  CFG_MENSAJE260 + '\'>' +  CFG_MENSAJE261 + '</a><br/><a href="javascript:AddTexto(' + txtVal + ',\' AND NOT \');" title=\'' +  CFG_MENSAJE267 + '\'>' +  CFG_MENSAJE268 + '</a><br/><a href="javascript:AddTexto(' + txtVal + ',\' NEAR \');" title=\'' +  CFG_MENSAJE262 + '\'>' +  CFG_MENSAJE263 + '</a><br><a href="javascript:EntreComillas(' + txtVal + ');" title=\'' +  CFG_MENSAJE264 + '\'>' +  CFG_MENSAJE264 + '</a><br><a href="javascript:AddTexto(' + txtVal + ', \'*\');EntreComillas(' + txtVal + ');" title=\'' +  CFG_MENSAJE265 + '\'>' +  CFG_MENSAJE266 + '</a>', ABOVE, LEFT, BGCOLOR, '91a9bd', CLOSETEXT, '', CLOSETITLE, '', CAPTION, 'Seleccione', WRAP, STICKY, MOUSEOFF);
}
function OperadoresAbrev(txtVal)
{
	overlib('<a href="javascript:AddTexto(' + txtVal + ',\'ABREVIATURA:\');" title=\'Abreviatura de la norma\'>Abreviatura</a><br/><a href="javascript:AddTexto(' + txtVal + ',\' AND \');" title=\'' +  CFG_MENSAJE258 + '\'>' +  CFG_MENSAJE259 + '</a><br/><a href="javascript:AddTexto(' + txtVal + ',\' OR \');" title=\'' +  CFG_MENSAJE260 + '\'>' +  CFG_MENSAJE261 + '</a><br/><a href="javascript:AddTexto(' + txtVal + ',\' AND NOT \');" title=\'' +  CFG_MENSAJE267 + '\'>' +  CFG_MENSAJE268 + '</a><br/><a href="javascript:AddTexto(' + txtVal + ',\' NEAR \');" title=\'' +  CFG_MENSAJE262 + '\'>' +  CFG_MENSAJE263 + '</a><br><a href="javascript:EntreComillas(' + txtVal + ');" title=\'' +  CFG_MENSAJE264 + '\'>' +  CFG_MENSAJE264 + '</a><br><a href="javascript:AddTexto(' + txtVal + ', \'*\');EntreComillas(' + txtVal + ');" title=\'' +  CFG_MENSAJE265 + '\'>' +  CFG_MENSAJE266 + '</a>', ABOVE, LEFT, BGCOLOR, '91a9bd', CLOSETEXT, '', CLOSETITLE, '', CAPTION, 'Seleccione', WRAP, STICKY, MOUSEOFF);
}
function AddTexto(oControl, sTexto)
{
	oControl.focus();
	oControl.value = oControl.value + sTexto;
	overlib('', ''); nd();
}
function EntreComillas(oControl)
{
	oControl.focus();
	oControl.value = '"' + oControl.value + '"';
	overlib('', ''); nd();
}
function add_busqueda(sTabla, sTipo, sId, sElemento)
{
    if (window.parent.frames['fraBuscador'].document.getElementById(sTipo + sId) != null) return

    var x = window.parent.frames['fraBuscador'].document.getElementById(sTabla).insertRow(-1);
    var y = x.insertCell(0);
    var z = x.insertCell(1);

    x.id = sTipo + sId;
    y.innerHTML = sElemento + "&nbsp;";

    z.innerHTML = "<a title=' +  CFG_MENSAJE270 + ' href='javascript:BorraBusqueda(\""+ sTipo + sId + "\");'><img src='papelera.gif' border='0'/></a>"
    z.noWrap = true;
    z.vAlign = "top";

	CheckBusquedas();
	ResizeFrames();
}
function ToggleBuscador()
{
	if (window.parent.frames['fraBuscador'].document.getElementById('tblBuscador').style.visibility == "hidden")
	{
		window.parent.frames['fraBuscador'].document.getElementById('tblBuscador').style.visibility = "visible";
	}
	else
	{
		window.parent.frames['fraBuscador'].document.getElementById('tblBuscador').style.visibility = "hidden";
	}

	ResizeFrames();
}

var tamanos_array = new Array('0.65em','0.70em','0.75em','0.80em','0.85em','0.90em','0.95em','1.00em','1.10em');
// Tamaņo inicial, recordar que el array empieza en 0


function tamano_texto_ventana(ventana, incremento)
{
	tamtexto = retrieveCookie("TAMTEXTO")
	tamtexto = parseInt(tamtexto)
	if (isNaN(tamtexto)) tamtexto = 2

	if (tamtexto<=0)
		tamtexto=0;
	else if (tamtexto>tamanos_array.length-1)
		tamtexto=tamanos_array.length-1;

	tamano_texto_(ventana, tamtexto)
}

function tamano_texto(incremento)
{
	var tamtexto

	tamtexto = retrieveCookie("TAMTEXTO")
	tamtexto = parseInt(tamtexto)
	if (isNaN(tamtexto)) tamtexto = 2

	tamtexto += incremento;
	if (tamtexto<=0)
		tamtexto=0;
	else if (tamtexto>tamanos_array.length-1)
		tamtexto=tamanos_array.length-1;

	setCookie("TAMTEXTO", tamtexto, 2*30*24*60*60, "/")

	if (top.window.frames.length > 1)
    {
		for (var k=0;k<top.window.frames.length;k++)
//			if (top.window.frames[k].name != 'fraOrganos' && top.window.frames[k].location.href.indexOf("rfr.asp") == -1)
				tamano_texto_(top.window.frames[k], tamtexto)
    }
	else
		tamano_texto_(top.window, tamtexto)

	if (incremento != 0)
	{
		try
		{
			if (top.window.document.getElementById('fstMain').rows != '100%,0%')
			{
				ResizeFrames()
			}
		}
		catch (er)
		{
		}
	}
	
}

function tamano_texto_(ventana, tamano)
{
	try
	{
		ventana.document.getElementsByTagName('body')[0].style.fontSize = tamanos_array[tamano];
	}
	catch (er)
	{
	}
}

function Bg(o,c)
{
    o.style.backgroundColor = c;
}
