/************ GLOBAL *********************/
var NS=(navigator.appName == "Netscape")?true:false;
var navegador_ie = /msi/i.test(navigator.userAgent);
var navegador_op = /opera/i.test(navigator.userAgent);
var navegador_mo = /gecko/i.test(navigator.userAgent);
var navegador_cr = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
var navegador_otro = !(navegador_ie || navegador_mo);
var cal_dia = new Array('','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado','Domingo');
var cal_mes = new Array('','Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');
var fi, bl_cont, contenedor, contenedortab;

function opagenda(accion, id, objeto) {
  ob(objeto +"_on_"+id).style.display = "none";
  ob(objeto +"_off_"+id).style.display = "none";
  ob(objeto +"_cargando_"+id).style.display = "";
  doExecAjax({url: "/secciones/ejercito/addelim.php", metodo: "POST", variables: "accion="+accion+"&id="+id+"&objeto="+objeto});
}
function ob(obj) {
  return document.getElementById(obj);
}
function cambiardiseno(id_dis) {
  ob('css_diseno_pag').href = "/diseno/css/"+id_dis+".css";
}
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 submitenter(myfield,e) {
  ismaxlength(myfield);
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;
  if (keycode == 13) {
    enviar();
    return false;
  } else {
    return true;
  }
}
function muestrausuario(id) {
  abrirpant('/secciones/perfil/tarjeta.php?id=' + id, false);
}
function trimAll(sString) {
  while (sString.substring(0,1) == ' ') {
    sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' ') {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}
function validarmail(s){
  var filter=/^[A-Za-z][A-Za-z0-9_.\-]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
  if (s.length == 0) {
    return true;
  }
  if (filter.test(s)) {
    return true;
  } else {
    return false;
  }
}
function do_innerHTML(objeto, contenido) {
  if (objeto) {
    objeto.innerHTML = contenido;
    return true;
  } else {
    return false;
  }
}
var htmlentities_antes = Array("&quot;","&iexcl;","&aacute;","&eacute;","&iacute;","&oacute;","&uacute;","&atilde;","&otilde;","&acirc;","&ecirc;","&ecirc;","&ocirc;","&ucirc;","&ccedil;","&uuml;","&Aacute;","&Eacute;","&Iacute;","&Oacute;","&Uacute;","&Atilde;","&Otilde;","&Acirc;","&Ecirc;","&Icirc;","&Ocirc;","&Ucirc;","&Ccedil;","&Uuml;","&acute;","&tilde;","&gt;","&lt;","&ntilde;","&Ntilde;","&iquest;");
var htmlentities_despues = Array('"','¡','á','é','í','ó','ú','ã','õ','â','ê','î','ô','û','ç','ü','Á','É','Í','Ó','Ú','Ã','Õ','Â','Ê','Î','Ô','Û','Ç','Ü','"','~','>','<','ñ','Ñ','¿');
function cerrarpant() {
  fi = ob('div_main_spec');
  fi.removeChild(ob('div_info'));
  fi.removeChild(ob('div_bloq'));
  fi.style.display = 'none';
}
function abrirpant(u, nocerrar, scr, exajax) {
  scr = scr ? scr : '';
  if (!ob("div_bloq")) {
    fi = ob('div_main_spec');
    fi.style.display = 'inline';
    contenedor = document.createElement('div');
    contenedor.id = "div_bloq";
    contenedor.className = "bloq";
    fi.appendChild(contenedor);
    contenedortab = document.createElement('div');
    contenedortab.id = "div_info";
    contenedortab.className = "objbloq";
    fi.appendChild(contenedortab);
    bl_cont = "<table border=\"0\" align=\"center\" style=\"width:100%; height:100%\">";
    if (nocerrar != true) {
      bl_cont += "<tr><td align=\"right\" style=\"height: 5%;\">[<b><a href=\"#\" onclick=\"cerrarpant(); return false;\">Cerrar</a></b>]</td></tr>";
    }
    bl_cont += "<tr><td align=\"center\" style=\"height: 95%;\"><div id=\"info_m_g\"></div></td></tr></table>";
    ob("div_info").innerHTML = bl_cont;
    if (u.length > 0) {
      if (exajax == true) {
        doExecAjax(u, 'GET', scr);
        doExecAjax({url: u, metodo: "GET", script: scr});
      } else {
        doAjax(u, 'GET', 'info_m_g', 'Cargando...', '', scr);
      }
    } else {
      eval(scr);
    }
  }
}
function htmlentities(texto) {
  for(var i=0; i<htmlentities_antes.length; i++) {
    var comando = "texto = texto.replace(/" + htmlentities_despues[i] + "/g, \"" + htmlentities_antes[i] + "\")";
    eval(comando);
  }
  return texto;
}
function html_entity_decode(texto) {
  for(var i=0; i<htmlentities_despues.length; i++) {
    var comando = "texto = texto.replace(/" + htmlentities_antes[i] + "/g, '" + htmlentities_despues[i] + "')";
    eval(comando);
  }
  return texto;
}
function validarmail(s){
  var filter=/^[A-Za-z][A-Za-z0-9_.\-]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
  if (s.length == 0) {
    return true;
  }
  if (filter.test(s)) {
    return true;
  } else {
    return false;
  }
}
function is_numeric(n) {
  if ((isNaN(n)) || (n.length == 0)) {
    return false;
  } else {
    return true;
  }
}
function muestraflash(urlflash, ancho, alto, transparencia, base, color, ident, align, valores) {
  document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' WIDTH='" + ancho + "' HEIGHT='" + alto + "' id='" + ident + "' ALIGN='" + align + "'>");
  document.write("<PARAM NAME='wmode' VALUE='" + transparencia + "' />");
  document.write("<PARAM NAME='base' VALUE='" + base + "' />");
  document.write("<PARAM NAME='flashVars' VALUE='" + valores + "' />");
  document.write("<PARAM NAME='quality' VALUE='high' />");
  document.write("<PARAM NAME='bgcolor' VALUE='#" + color + "' />");
  document.write("<PARAM NAME='movie' VALUE='" + urlflash + "' />");
  document.write("<PARAM NAME='allowScriptAccess' VALUE='sameDomain' />");
  document.write("<EMBED flashVars='" + valores + "' base='" + base + "' allowScriptAccess='sameDomain' quality='high' bgcolor='#" + color + "' WIDTH='" + ancho + "' HEIGHT='" + alto + "' NAME='" + ident + "' ALIGN='" + align + "' TYPE='application/x-shockwave-flash' wmode='" + transparencia + "' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' src='" + urlflash + "'></EMBED>");
  document.write("</OBJECT>");
}
function buscausuario(id, objeto) {
  ob(objeto).innerHTML = '';
  if (parseInt(id) > 0) {
    doAjax('/secciones/perfil/buscar_usuario.php?id='+id, 'GET', objeto, 'Buscando...', '', '');
  }
}

function lateral_DoFSCommand(command, args) {
	if (command == "muestrausuario") {
		muestrausuario(args);
	} else if(command == "login") {
    var datoslog = args.split("[|]");
    ob('login_user').value = datoslog[0];
    ob('login_pass').value = datoslog[1];
    ob('form_logsession').submit();
  }
}

/************ AJAX *********************/
var MSGERRORAJAX = "¡Por las barbas de Merlín! Ha ocurrido un error al realizar la operación.";
function creaAjax(){
  var objetoAjax=false;
  try {
    objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      objetoAjax = false;
    }
  }
  if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
    objetoAjax = new XMLHttpRequest();
  }
  return objetoAjax;
}
function doAjax(url, metodo, objeto, msjcargando, valores, script) {
  var resultado = false;
  var ajax = creaAjax();
  var capaContenedora = ob(objeto);
  if (metodo.toUpperCase() == 'POST') {
    ajax.open ('POST', url, true);
    ajax.onreadystatechange = function() {
      if (ajax.readyState == 1) {
        if (msjcargando.length > 0) {
          do_innerHTML(capaContenedora, msjcargando);
        } 
      } else if (ajax.readyState == 4) {
        if (ajax.status == 200) {
          do_innerHTML(capaContenedora, ajax.responseText); 
          if (script) {
            eval(script);
          }
        } else if (ajax.status == 404) {
          //alert(MSGERRORAJAX);
          do_innerHTML(capaContenedora, ''); 
        } else {
          //alert(MSGERRORAJAX + "\n(Error " + ajax.status + ")");
          do_innerHTML(capaContenedora, ''); 
        }
      }
    }
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(valores);
    return;

  } else if (metodo.toUpperCase()=='GET') {
    ajax.open ('GET', url, true);
    ajax.onreadystatechange = function() {
      if (ajax.readyState == 1) {
        if (msjcargando.length > 0) {
          do_innerHTML(capaContenedora, msjcargando);
        } 
      } else if (ajax.readyState == 4) {
        if (ajax.status == 200) { 
          do_innerHTML(capaContenedora, ajax.responseText); 
          if (script) {
            eval(script);
          }
        } else if (ajax.status == 404) {
          //alert(MSGERRORAJAX);
          do_innerHTML(capaContenedora, ''); 
        } else {
          //alert(MSGERRORAJAX + "\n(Error " + ajax.status + ")");
          do_innerHTML(capaContenedora, ''); 
        }
      }
    }
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(null);
    return
  }
}
function doExecAjax(valores) {
  var url = valores.url ? valores.url.length > 0 ? valores.url : '' : '';
  var metodo = valores.metodo ? valores.metodo.toUpperCase() == 'POST' ? 'POST' : 'GET' : 'GET';
  var script = valores.script ? valores.script : '';
  var variables = valores.variables ? valores.variables : '';
  var resultado = false;
  if (url.length > 0) {
    var ajax = creaAjax();
    if (metodo.toUpperCase() == 'POST') {
      ajax.open ('POST', url, true);
      ajax.onreadystatechange = function() {
        if (ajax.readyState == 1) {
          if (script.length > 0) {
            eval(script);
          }
        } else if (ajax.readyState == 4) {
          if (ajax.status == 200) {
            eval(ajax.responseText);
          } else if (ajax.status == 404) {
            //alert(MSGERRORAJAX);
          } else {
            //alert(MSGERRORAJAX + "\n(Error " + ajax.status + ")");
          }
        }
      }
      ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      ajax.send(variables);
      return;
  
    } else if (metodo.toUpperCase()=='GET') {
      ajax.open ('GET', url, true);
      ajax.onreadystatechange = function() {
        if (ajax.readyState == 1) {
          if (script.length > 0) {
            eval(script);
          }
        } else if (ajax.readyState == 4) {
          if (ajax.status == 200) { 
            eval(ajax.responseText); 
          } else if (ajax.status == 404) {
            //alert(MSGERRORAJAX);
          } else {
            //alert(MSGERRORAJAX + "\n(Error " + ajax.status + ")");
          }
        }
      }
      ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      ajax.send(null);
      return
    }
  }
}


/************ CURSOR *********************/
var Xmouse, Ymouse;
function getXYPositioncursor(e) {
  Xmouse = (e||event).clientX;
  Ymouse = (e||event).clientY;
}
document.onmousemove = getXYPositioncursor;

/************ MENÚ *********************/
var _mnuhl_pos = 'off';
var _mnuhl_obj = new Array();
var _mnuhl_obj = new Array();
var _mnuhl_timeout;
var _mnuhl_medida = 0;
function muestramenuHL(ident) {
  _mnuhl_pos = ident;
  _mnuhl_pos = _mnuhl_pos.length == 0 ? 'off' : _mnuhl_pos;
  if (_mnuhl_pos == 'off') {
    _mnuhl_tiempo = 0;
  } else {
    clearInterval(_mnuhl_timeout);
    _mnuhl_timeout = setInterval(muestramenuHL_tiempo, 500)
  }
  if (_mnuhl_obj.length == 0) {
    _mnuhl_medida += parseInt(ob('diseno_area_menu').offsetTop);
    _mnuhl_medida += parseInt(ob('diseno_area_menu').offsetHeight);
    var _mnuhl_cuenta = 0;
    var mnuhl_area_rastreo = ob('diseno_area_logoprincipalmenu').childNodes;
    for(i=0;i<mnuhl_area_rastreo.length;i++){
      var _mnuhl_ele = mnuhl_area_rastreo[i];
      if (/mnuhl_mn_/.test(_mnuhl_ele.id)) {
        _mnuhl_obj[_mnuhl_cuenta] = _mnuhl_ele.id.replace(/mnuhl_mn_/, '');
        _mnuhl_cuenta++;
      }
    }
  }
  for(x=0; x<_mnuhl_obj.length; x++) {
    if (_mnuhl_obj[x] == _mnuhl_pos) {
      if (_mnuhl_obj[x] != 'off') {
        ob('botonmenu_'+_mnuhl_obj[x]).src = '/imagenes/web/header/menu_'+_mnuhl_obj[x]+'_on.jpg';
      }
      $("#mnuhl_mn_"+_mnuhl_obj[x]).fadeIn();
    } else {
      if (_mnuhl_obj[x] != 'off') {
        ob('botonmenu_'+_mnuhl_obj[x]).src = '/imagenes/web/header/menu_'+_mnuhl_obj[x]+'_off.jpg';
      }
      $("#mnuhl_mn_"+_mnuhl_obj[x]).hide();
    }
  }
  ob('diseno_area_logoprincipalmenu').className = 'diseno_area_mnu' + _mnuhl_pos;
}
function muestramenuHL_tiempo(e) {
  if (Ymouse > _mnuhl_medida) {
    muestramenuHL('');
    clearInterval(_mnuhl_timeout);
  }
}

/************ BARRA INFERIOR *********************/
var nuevosmensajes = 0;
var cantmsjnotif = 0;
var nuevaspropuestas = 0;
function mmsjlech() {
  if (nuevosmensajes == 1) {
    ob("areanotiflech").innerHTML = "<a href=\"/lechuceria\">1 mensaje sin leer</a>";
  } else if (nuevosmensajes > 1) {
    ob("areanotiflech").innerHTML = "<a href=\"/lechuceria\">" + nuevosmensajes +" mensajes sin leer</a>";
    } else {
    ob("areanotiflech").innerHTML = "0 mensajes sin leer";
    }
  if (nuevosmensajes > cantmsjnotif) {
    //comBarraHL(true);
  }
  ob("areanotiflech").title = nuevosmensajes + " "+(nuevosmensajes == 1 ? "mensaje" : "mensajes")+" sin leer en tu Lechucería";
  cantmsjnotif = nuevosmensajes;
  //Propuestas de intercambios de cromos
  if (nuevaspropuestas == 1) {
    ob("areanotifcrom").innerHTML = "<a href=\"/album\">1 propuesta de intercambio de cromos</a>";
   } else if (nuevaspropuestas > 1) {
    ob("areanotifcrom").innerHTML = "<a href=\"/album\">" + nuevaspropuestas +" propuestas de intercambio de cromos</a>";
    } else {
    ob("areanotifcrom").innerHTML = "0 propuestas de intercambio de cromos";
  }
  ob("areanotifcrom").title = nuevaspropuestas + " "+(nuevaspropuestas == 1 ? "propuesta" : "propuestas")+" de intercambio en tu Álbum de Cromos";
  mensajestotales = nuevosmensajes + nuevaspropuestas;
  ob("areanotiflechpeq").innerHTML = mensajestotales;
  if(mensajestotales > 0){
  $("#areanotiflechpeq").show();
  } else {
  $("#areanotiflechpeq").hide();
  }
}
function conver_chat(id, nick){
 ob("areanotifcrompeq").innerHTML = " <font color=\"#0066ff\"><b>(" + nick +")</b></font>";
 ob("areanotifcrom").innerHTML += "<span id=\"chat_aviso\"> | <font color=\"#0066ff\"><b>(<a href=\"#\" style=\"color:#0066ff\" onclick=\"open('/secciones/chat/chat.php?con=" + id + "','_blank','status=1,left=20,top=20,width=300,height=450,toolbar=0,scrollbars=no,resizable=1'); ob('chat_aviso').innerHTML = ''; ob('areanotifcrompeq').innerHTML = ''; return false;\">" + nick + " te habla</a>)</b></font></span>";
}
function crearintervlech() {
  setTimeout("buscanuevaslech()",30000);
}
function buscanuevaslech() {
  doExecAjax({url: "/secciones/lechuceria/verificar_barra.php"});
}
function opnl() {
  if (ob("div_main_lech").innerHTML.length > 0) {
    ob("div_main_lech").innerHTML = "";
  } else {
    doExecAjax({url: '/secciones/lechuza/lech_inf.php'});
    comBarraHL();
  }
}
function checkbarra() {
  if (ob("barraHL")) {
    return true;
  } else {
    return false;
  }
}
function comBarraHL(ac) {
  if (checkbarra()) {
    if (ac == true) {
      ob("barraHL").style.display = "";
      ob("barraHL_btn").style.display = "none";
    } else {
      ob("barraHL").style.display = "none";
      ob("barraHL_btn").style.display = "";
    }
    ob("panel_inf_mas").style.display = "none"; 
  }
}
function cerrarpant() {
  fi = ob('div_main_spec');
  fi.removeChild(ob('div_info'));
  fi.removeChild(ob('div_bloq'));
  fi.style.display = 'none';
}

// ESTADO
var actualestado = "";
function dest_txt_est(obje, ac) {
  obje.className = "txt_estado_" + ac;
}
function swpanestado(ac) {
  var nuevot = "";
  if (ac == true) {
    ob('area_txt_estado_1').style.display = "none";
    ob('area_txt_estado_2').style.display = "";
    ob('texto_est').value = html_entity_decode(actualestado);
    ob('texto_est').focus();
    ob('texto_est').select();
  } else {
    ob('area_txt_estado_1').style.display = "";
    ob('area_txt_estado_2').style.display = "none";
    nuevot = htmlentities(trimAll(ob('texto_est').value));
    if (actualestado != nuevot) {
      actualestado = nuevot;
      pontextest();
      doAjax('/secciones/perfil/act_estado.php', 'POST', 'img_txt_estado', '....', 'texto=' + escape(trimAll(ob('texto_est').value)));
    }
  }
}
function selfinal(oj) {
  obj = ob(oj);
  if (obj.createTextRange) {
    var rango = control.createTextRange();
    rango.collapse(false);
    rango.select();
  } else if (obj.setSelectionRange) {
    obj.focus();
    var length = obj.value.length;
    obj.setSelectionRange(length, length);
  }
}
function pontextest() {
  if (actualestado.length == 0) {
    ob('texto_est_span').innerHTML = "<i>[Haz click aqu&iacute; para escribir tu estado...]</i>";
  } else {
    ob('texto_est_span').innerHTML = actualestado;
  }
}
function citar_estado(id) {
  swpanestado(true);
  ob('texto_est').value = "*" + id + " ";
  selfinal('texto_est');
}
function submitenterestado(myfield,e) {
  ismaxlength(myfield);
  var keycode = (NS)?e.which:event.keyCode;
  if (keycode == 13) {
    ob('texto_est').blur();
    return false;
  } else if (keycode == 27) {
    ob('texto_est').value = actualestado;
    ob("texto_est").blur();
  } else {
    return true;
  }
}
/************* AÑADE TEXTO *******************/
// Añade texto
var addtexto_iniciado;
var addtexto__insertor, addtexto__insertar, addtexto__formulario, addtexto__texto, addtexto__lector = "";

function datos_ie() {
	addtexto__texto = document.selection.createRange().text;
	if (addtexto__formulario.createTextRange)
		addtexto__formulario.posi = document.selection.createRange().duplicate();
	return true;
}

function captura_ie()	{
	return addtexto__texto;
}

function captura_mo() {
	with (addtexto__formulario) return value.substring(selectionStart, selectionEnd);
}

function captura_otro()	{
	return "";
}

function poner_mo(f, x)	{//alert(x);
	var addtexto__ini = f.selectionStart;
	var addtexto__fin = f.selectionEnd;
	var inicio = f.value.substr(0, addtexto__ini);
	var fin = f.value.substr(addtexto__fin, f.value.length);

	f.value = inicio + x + fin;
	if (addtexto__ini == addtexto__fin)	{
		f.selectionStart = inicio.length + x.length;
		f.selectionEnd = f.selectionStart;
	}
	else	{
		f.selectionStart = inicio.length;
		f.selectionEnd = inicio.length + x.length;
	}
	f.focus();
}

function poner_otro(f, x)	{// opera u otros navegadores desconocidos
	f.value += x;//alert(x);
	f.focus();
}

function poner_ie(f, x)	{
	f.focus();
	if (f.createTextRange)	{// && f.posi)	{
		if (!f.posi)	datos_ie();
		with(f)	{
			var actuar = (posi.text == "");
			posi.text = x;
			if (!actuar)
				posi.moveStart("character", -x.length);
			posi.select();
		}
	}
}

function ini_editor(formu)	{
	addtexto__formulario = formu;
	addtexto_iniciado = true;
	if (navegador_op || navegador_mo)	{//alert("mozilla u opera");
		addtexto__insertar = function(f, x) {poner_mo(f, x);};
		addtexto__lector = captura_mo;
	}

else	if (navegador_otro)	{//alert("otro");
		addtexto__insertar = function(f, x) {poner_otro(f, x);};
		addtexto__lector = captura_otro;
	}

else	if (navegador_ie)	{
		addtexto__formulario.onchange = datos_ie;
		addtexto__formulario.onclick  = datos_ie;
		addtexto__insertar = function(f, x) {poner_ie(f, x);};
		addtexto__lector = captura_ie;
	}
}

function insertar_texto(cual, editor)	{
  if (!addtexto_iniciado) ini_editor(ob(editor));
  addtexto__insertar(ob(editor), cual);
}


// MENU
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") {
obj.zIndex=90;
obj.visibility=visible;
} else if (e.type=="click") {
obj.visibility=hidden;
}
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
