// JavaScript Document

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

var minHeight = 300;

function GetDocHeight(doc) 
{
  var docHt = 0, sh, oh;
  if (doc.height) 
    docHt = doc.height;
  if (doc.body)
  {
    if (doc.body.scrollHeight) 
      docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) 
      docHt = oh = doc.body.offsetHeight;
    if (sh && oh) 
      docHt = Math.max(sh, oh);
  }
  return docHt;
}

function SetIframeHeight(iframeName) 
{
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById ? document.getElementById(iframeName): document.all ? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) 
  {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = GetDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt)
    {
      var newHeight = docHt + 30;
//      if (minHeight == 0)
//        minHeight = newHeight;
//      else
        if (newHeight < minHeight)
          newHeight = minHeight;
      iframeEl.style.height = newHeight + "px";
    }
  }
}

var viewport = {
  getWinWidth: function () 
  {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () 
  {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () 
  {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () 
  {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
  
}

/*************************************************************************
  End of code from Dynamic Web Coding at http://www.dyn-web.com/
*************************************************************************/

function SetSiteWidth(width) 
{
  var siteDiv = document.getElementById? document.getElementById('site'): document.all? document.all['site']: null;
  if (siteDiv) 
  {
    viewport.getWinWidth();
    var newWidth = Math.floor( ( viewport.width - width ) / 2 );
    siteDiv.style.left = (newWidth > 0 ? newWidth : 0) + "px";
    siteDiv.style.visibility = "visible";
  }
}

function SelectMenuOption(newPage)
{
  document.getElementById("main_frame").src = newPage;
  document.getElementById("right_frame").src = "noticias.php";
}

function GoHome()
{
  document.getElementById("main_frame").src = "main.php";
  document.getElementById("right_frame").src = "noticias.php";
}

function Init()
{
  SetSiteWidth(900);
}

/********************************************************************
  Drop down menus
********************************************************************/
var n;
var ie;

if (document.layers) 
{
	visible = 'show';
	hidden = 'hide';n=1;ie=0;
} 
else 
  if (document.all) 
  {
    visible = 'visible';
    hidden = 'hidden';n=0;ie=1;
  }
  else 
    if (document.getElementById && !document.all) 
    {
      visible = 'visible';
      hidden = 'hidden';n=0;ie=1;
    }

var ver = parseFloat (navigator.appVersion);
if ((navigator.appName.indexOf ("Netscape") == 0) && (ver >= 4))
{
} 
else
  if ((navigator.appName.indexOf ("Mozilla") == 0) && (ver >= 5))
  {
  }
  else
    if ((navigator.appName.indexOf ("Microsoft") == 0) && (ver >= 4))
    {
    }
    else
    {
      location="old_browser.html";
    }
    
function showDivs (divName,divNumber)
{
	var divsUsed = 2;    // this is the number of divs we have in the document for each element(topmenu, submenu, contentArea, contentImage)
	if (navigator.appName.indexOf ("Microsoft") == 0 || navigator.appName.indexOf ("Netscape") == 0)
  {
		if (parseInt (navigator.appVersion) >= 4)
    {
			var cnt = 0;
			for (cnt = 1; cnt <= divsUsed; cnt++)
      {
				var divCheck = divName + cnt;
				var divShow = divName + divNumber;
				if (ie)
        {
					if (divCheck == divShow) 
						document.all(divShow).style.visibility = visible;
					else 
						document.all(divCheck).style.visibility = hidden;
				}
				if (n)
        {
					if (divCheck == divShow) 
						document.layers[divShow].visibility = visible;
					else 
						document.layers[divCheck].visibility = hidden;
				}					
			}
		}
	}
}

function hideDivs (divName,divNumber)
{
	var divsUsed = 2;    // this is the number of divs we have in the document for each element(topmenu, submenu, contentArea, contentImage)
	if (navigator.appName.indexOf ("Microsoft") == 0 || navigator.appName.indexOf ("Netscape") == 0)
  {
		if (parseInt (navigator.appVersion) >= 4)
    {
			var cnt = 0;
			for (cnt = 1; cnt <= divsUsed; cnt++)
      {
				var divCheck = divName + cnt;
				var divShow = divName + divNumber;
				if (ie)
        {
					if (divCheck == divShow) 
						document.all(divShow).style.visibility = hidden;
				}
				if (n)
        {
					if (divCheck == divShow) 
						document.layers[divShow].visibility = hidden;
				}					
			}
		}
	}
}

/********************************************************************
  End of Drop Down Menus
********************************************************************/

