function oculta (menu) {
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('tr');
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].title==menu)
			{
			   tables[i].style.display='none'; 	
			}
		}
	}
}   

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
var stylePath;

function removeHash(target,oldTerm,newTerm,caseSens,wordOnly) {
  var work = target;
  var ind = 0;
  var next = 0;
  if (!caseSens) {
    oldTerm = oldTerm.toLowerCase();
    work = target.toLowerCase();
  }
  while ((ind = work.indexOf(oldTerm,next)) >= 0) {
    if (wordOnly) {
      var before = ind - 1;
      var after = ind + oldTerm.length;
      if (!(space(work.charAt(before)) && space(work.charAt(after)))) {
        next = ind + oldTerm.length;
        continue;
      }
    }
    target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length);
    work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length);
    next = ind + newTerm.length;
    if (next >= work.length) { break; }
  }
  return target;
}  

function selectStyle (vCookieName, vSelection) 
{
  if (confirm("This feature requires a cookie to be set, press OK to continue.")) {
   //WRITE COOKIE
   makeCookie(vCookieName, vSelection, 90, '/');
   //RELOAD THE CURRENT PAGE
   //self.location = self.location;
   window.location.reload();
  }
}

function writeHeadStyle (vDefaultPath)
{
  stylePath = vDefaultPath;

  if (document.cookie.indexOf('agdformatstyle=')!=-1) {
    css = readCookie('agdformatstyle');
    //IMPORT SELECTED STYLE SHEET
    document.write('<style type="text/css" media="screen">@import "' + stylePath + css + '";</' + 'style>\n');
  } else {
    document.write('<style type="text/css" media="screen">@import "' + stylePath + 'format-enhanced.css";</' + 'style>\n');
  }

  if (document.cookie.indexOf('agdfontstyle=')!=-1) {
    fcss = readCookie('agdfontstyle');
    //IMPORT SELECTED STYLE SHEET
    document.write('<style type="text/css" media="screen">@import "' + stylePath + fcss + '";</' + 'style>\n');
  } else {
    document.write('<style type="text/css" media="screen">@import "' + stylePath + 'font-medium.css";</' + 'style>\n');
  }

}





var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


    
