
document.contents = new Array ();

document.queue   = new Array ();
document.qpos    = 0;
document.offsetX = 0;
document.offsetY = 0;




function switchContent (id)
  {
  if ((typeof (document.contents [id]) == 'undefined') || (document.contents [id] == false))
    {
    var contentElement = document.getElementById (id);
    if (id.indexOf ('info') != -1)
      {
      var iconId = id.toString ().replace ('info', 'icon');
      var iconElement = document.getElementById (iconId); 
      if ((iconElement != null) && (typeof iconElement != 'undefined'))
        iconElement.src = iconElement.src.replace ('expand', 'collapse');
      }  // if
    contentElement.innerHTML = '<small><b>Cargando, espere por favor</b>&nbsp;</small><img src="/img/loading.gif" border="0" alt="" width="64" height="3">';

    return true;
    }  // if
  else
    {
    unloadContent (id);
    if (id.indexOf ('info') != -1)
      {
      var iconId = id.toString ().replace ('info', 'icon');
      var iconElement = document.getElementById (iconId); 
      if ((iconElement != null) && (typeof iconElement != 'undefined'))
        iconElement.src = iconElement.src.replace ('collapse', 'expand');
      }  // if


    return false;
    }  // else
  return true;
  }






function callbackContent ()
  {
  if (((navigator.family == 'ie4') && (navigator.version < 5.5)) || (navigator.family == 'opera'))
    {
    if (typeof window.parent.loadContent != 'undefined')
      window.parent.loadContent ();
    }  // if

  //alert ('callbackContent: ' + window.name + ' ' + document.title + ' ' + document.queue.length + ' ' + document.qpos);
  if (document.qpos < document.queue.length)
    dequeueContent ();

  return;
  }


function loadContent ()
  {
//  alert ('loadContent: ' + window.name + ' ' + document.title + ' ' + document.queue.length + ' ' + document.qpos);
  var proxy = window.frames ['proxy'];
  if ((typeof proxy == 'undefined') || (typeof proxy.getProxyElementId == 'undefined'))
    return;

  var id = proxy.getProxyElementId ();

  if ((typeof id == 'undefined') || (id == ''))
    return;

  var element = proxy.document.getElementById ('contentId');
  if (typeof element == 'undefined')
    return;
    
  if ((dotIndex = id.indexOf ('.')) != -1)
    {
    frame = id.substr (0, dotIndex);
    id    = id.substr (dotIndex + 1);

    targetElement = top.frames [frame].document.getElementById (id);
    if ((typeof targetElement == 'undefined') || (targetElement == null))
      return;

    targetElement.innerHTML = element.innerHTML;
    top.frames [frame].document.contents [id] = true;
    return;
    }  // if

  document.getElementById (id).innerHTML = element.innerHTML;

  document.contents [id] = true;
  document.lastElementId = id;

  var anchorName = id.toString ().replace ('Id', 'Name');

  var anchorElement;
  if (navigator.family == 'ie4')
    anchorElement = document.anchors (anchorName);
  else
    anchorElement = document.anchors [anchorName];

  if ((document.queue.length > 0) && (document.qpos == 0))
    document.offsetX = document.offsetY = 0;

  document.offsetX += document.getElementById (id).offsetLeft;
  document.offsetY += document.getElementById (id).offsetTop;
  if ((typeof anchorElement != 'undefined') && (document.qpos < document.queue.length))
    window.scrollTo (document.offsetX, document.offsetY);

  if (document.qpos < document.queue.length)
    dequeueContent ();
  return;
  }  // function






function reloadContent (w, id)
  {
//  alert ('reloadContent: ' + window.name + ' ' + document.title + ' ' + document.queue.length + ' ' + document.qpos);
  if ((typeof id == 'undefined') || (id == ''))
    return;

  var proxy = w.frames ['proxy'];
  if (typeof proxy == 'undefined')
    return;

  var anchorName = id.toString ().replace ('Id', 'Name');
  var anchorElement;
  if (navigator.family == 'ie4')
    anchorElement = w.document.anchors (anchorName);
  else
    anchorElement = w.document.anchors [anchorName];

  if ((typeof anchorElement == 'undefined') || (anchorElement == null))
    return;
  
  proxy.location.href = anchorElement.href;
  return;
  }  // function





function unloadContent (id)
  {
//  alert ('unloadContent: ' + window.name + ' ' + document.title + ' ' + document.queue.length + ' ' + document.qpos);
  var element = document.getElementById (id);
  document.contents [id] = false;
  element.innerHTML = '';

  return;
  }  // function






function enqueueContent (id)
  {
//  alert ('enqueueContent: ' + window.name + ' ' + document.title + ' ' + document.queue.length + ' ' + document.qpos);
  document.queue [document.queue.length] = id;

  return;
  }  // function



function dequeueContent ()
  {
  var id = document.queue [document.qpos++]; 
//  alert ('dequeueContent: ' + window.name + ' ' + document.title + ' ' + document.queue.length + ' ' + document.qpos);

  var proxy = window.frames ['proxy'];
  if (typeof proxy == 'undefined')
    return;

  if (id.indexOf ('info') != -1)
    {
    var anchorName = id.toString ().replace ('Id', 'Name');
    var anchorElement = null;
    if (navigator.family == 'ie4')
      anchorElement = document.anchors (anchorName);
    else 
      anchorElement = document.anchors [anchorName];
    if ((anchorElement != null) && (typeof anchorElement != 'undefined'))
      {
      if (switchContent (id))
        {
        proxy.location.href = anchorElement.href;
        }  // if
      }  // if 
    }  // if

  return;
  }  // function
















function showLayer (layerId, doc)
  {
//  alert ('showLayer (' + layerId + ', ' + doc + ')');

  if (typeof doc == 'undefined')
    doc = document;

  var layer = doc.getElementById (layerId);

  if ((layer == null) || (typeof layer == 'undefined'))
    return;


  if (navigator.family == 'ie4')
    layer.style.display  = 'block';
  else if (layer.tagName == 'TBODY')
    layer.style.display = 'table-row-group';
  else
    layer.style.display  = 'block';


  layer.style.visibility = 'visible';

  return;
  }  // function




function hideLayer (layerId, doc)
  {
//  alert ('hideLayer (' + layerId + ', ' + doc + ')');

  if (typeof doc == 'undefined')
    doc = document;

  var layer = doc.getElementById (layerId);

  if ((layer == null) || (typeof layer == 'undefined'))
    return;

  layer.style.display    = 'none';
  layer.style.visibility = 'hidden';


  return;
  }  // function








function switchLayer (layerId, doc)
  {
  if (typeof doc == 'undefined')
    doc = document;

  var layer = doc.getElementById (layerId);
  if ((layer == null) || (typeof layer == 'undefined'))
    return;

  if (layer.style.visibility == 'visible')
    hideLayer (layerId, doc);
  else
    showLayer (layerId, doc);

  return;
  }  // function








function moveLayer (id, event, x, y)
  {
  var layer;
  
  layer = document.getElementById (id);
  if (layer == null)
    return;

  if (typeof event != 'undefined')
    {
    var scroll = new Object ();

    if (document.all && typeof document.body.scrollTop != "undefined")
      {     // IE model
      var ieBox = document.compatMode != "CSS1Compat";
      var cont = ieBox ? document.body : document.documentElement;
      scroll.left   = cont.scrollLeft;
      scroll.top    = cont.scrollTop;
      scroll.width  = cont.clientWidth;
      scroll.height = cont.clientHeight;
      }  // if
    else 
      {
      scroll.left   = window.pageXOffset;
      scroll.top    = window.pageYOffset;
      scroll.width  = window.innerWidth;
      scroll.height = window.innerHeight;
      }  // else
                  
    // width:
    if (layer.offsetWidth >= scroll.width)
      layer.style.width = scroll.width - 10 + "px";
    else
      layer.style.width = "";
                  
    // left:
    if (event.clientX > scroll.width - layer.offsetWidth)
      x = scroll.width - layer.offsetWidth + scroll.left;
    else
      x = event.clientX - 2 + scroll.left;
      
  
    // top:
    if (event.clientY + layer.offsetHeight + 18 < scroll.height)
      y = event.clientY + 18 + scroll.top;
    else if (event.clientY - layer.offsetHeight > 0)
      y = event.clientY + scroll.top - layer.offsetHeight;
    else
      y = scroll.top + 5;
    }  // if

  layer.style.left = x + "px";              
  layer.style.top =  y + "px";
                  
  return;
  }  // function










function addClassName (element, className)
{
	var s = element.className;
	var p = s.split (' ');

	if ((p.length == 1) && (p [0] == ''))
		p = [];

	var l = p.length;

	for (var i = 0; i < l; i++)
	{
		if (p [i] == className)
			return;
	}  // for

	p [p.length] = className;
	element.className = p.join (' ');
	
	return;
}  // function [addClassName]



function removeClassName (element, className)
{
	var s = element.className;
	var p = s.split (" ");
	var np = [];
	var l = p.length;
	var j = 0;
	for (var i = 0; i < l; i++)
	{
		if (p [i] != className)
			np [j++] = p [i];
	}  // for
	element.className = np.join (" ");
	
	return;
}  // function [removeClassName]




function hasClassName (element, className)
{
	var s = element.className;
	if (s.indexOf (' ') == -1)
	  return (s == className);
	
	var p = s.split (" ");
	if ((p.length == 1) && (p [0] == ''))
		p = [];

	var l = p.length;

	for (var i = 0; i < l; i++)
	{
		if (p [i] == className)
			return true;
	}  // for
	
	return false;
}

