n4 = (document.layers)? true:false;
ie = (document.all)? true:false;
n6 = (document.getElementById)? true:false;

function getElementById(id)
{
    if (ie)
		return document.all[id];
	else if (n6)
		return document.getElementById(id);
}

function selectMenu(menu_id){

	var link_id=menu_id+"_lnk";
	var menu = document.getElementById(menu_id);
	var link = document.getElementById(link_id);
	if (menu.className=='tabSelected'){
		menu.className = 'tabUnSelected';
		link.className = 'tabUnSelectedLnk';
	}
	else{      
		menu.className = 'tabSelected';
		link.className = 'tabSelectedLnk';
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function addOption( valor, etiqueta, combo ) {
    if (valor != ''){
        if (etiqueta == ''){
            etiqueta = valor;
        }
        //verifica que no exista
        for( j=0; j < combo.options.length; j++) {
            l_valor = combo.options[j].value;
            if (l_valor == valor){
                return true;
            }
        }
        var oOption = new Option(etiqueta, valor, false,false);
        combo.options[combo.options.length]=oOption;
    }
    return(true);
}

function eraseAllOptions (combo){
    for( j=combo.options.length; j >= 0; j--) {
        combo.options[j] = null;
    }
}

function goToPage(formName, pageNumber, action, formField) {
    if(action != ''){
        document.forms[formName].action = action;
    }
    if(formField != null) document.forms[formName].elements[formField].value = pageNumber;
    else document.forms[formName].fPageNumber.value = pageNumber;

    document.forms[formName].submit();
}

function selectOption(valor, combo){
    var i;
    if(combo != null){
        for (i=0; i<combo.length; i++){
            if (combo.options[i].value == valor){
                combo.options[i].selected = true;
            }
        }
    }
}

function deselectAll(combo){
    var i;
    if(combo != null){
        for (i=0; i<combo.length; i++){
            combo.options[i].selected = false;
        }
    }
}

function openPopup(url, width, height, scrollbars, posX, posY){
    var winl = (screen.width - width) / 2;
    if(posX != null) winl = posX;
    var wint = (screen.height - height) / 2;
    if(posY != null) wint = posY;

    var settings ='height=' + height +',';
    settings += 'width=' + width + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    if(scrollbars != null && scrollbars == false){
        settings += 'scrollbars=no,';
    }else{
        settings += 'scrollbars=yes,';
    }
    settings += 'resizable=yes';

    win = window.open(url,'',settings);
}

function showFlash (url, width, height){
    document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="' + width + '" height="' + height + '" id="flash" align="middle" SWLIVECONNECT="true">');
    document.write ('<param name="allowScriptAccess" value="sameDomain" />');
    document.write ('<param name="movie" value="' + url + '" />');
    document.write ('<param name="quality" value="high" />');
    document.write ('<param name="bgcolor" value="#FFFFFF" />');
    document.write ('<param name="wmode" value="transparent" />');    
    document.write ('<embed src="' + url + '" wmode="transparent" quality="high" width="' + width + '" height="' + height + '" bgcolor="#FFFFFF" name="SOredirect" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" SWLIVECONNECT=true pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write ('</object>');
} 