//******** LAYER MENU ********
var activeSub=0;
var SubNum=0;
var last_header=0;

function reDo(){ window.location.reload() }

var timerID = null;
var timerIDHeader = 0;
var timerOn = false;
var timerOnHeader = false;
var timecount = 300;
var what = null;
var newbrowser = true;
var check = false;

function init(){
if (document.layers) {
      //  alert ("Running Netscape 4");
	layerRef="document.layers";
	styleSwitch="";
	visibleVar="show";
	screenSize = window.innerWidth;
	what ="ns4";

}else if(document.all){
      //  alert ("Running IE");
	layerRef="document.all";
	styleSwitch=".style";
	visibleVar="visible";
	screenSize = document.body.clientWidth + 18;
	what ="ie";

  }else if(document.getElementById){
      //  alert ("Running Netscape 6");
	layerRef="document.getElementByID";
	styleSwitch=".style";
	visibleVar="visible";
	what="moz";

  }else{
	//alert("Older than 4.0 browser.");
	what="none";
	newbrowser = false;
  }
check = true;
}
function showLayer(layerName){
if(check){
	if (what =="none"){
		return;
		}
	else if (what == "moz"){
		document.getElementById(layerName).style.visibility="visible";
		}
	else{
  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
}
}
else {// alert ("Please wait for the page to finish loading.");
	return;}
}
function hideLayer(layerName){
if(check){
	if (what =="none"){
		return;
		}
	else if (what == "moz"){
		document.getElementById(layerName).style.visibility="hidden";
		}
	else{
  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
		}
}
else {// alert ("Please wait for the page to finish loading.");
	return;}
}
function hideAll(){
	hideLayer('layer1');
	hideLayer('layer2');
	hideLayer('layer3');
	hideLayer('layer4');
	hideLayer('layer5');
	hideLayer('layer6');
	Rest_Headers();
}
function startTime() {
if (timerOn == false) {
timerID=setTimeout( "hideAll()" , timecount);
timerOn = true;
}
}
function Rest_Headers() {
	if (last_header!=0) {
		ColorHeaderMenu(last_header,defaultColor);
		last_header=0;
	}
}
function stopTime() {
if (timerOn) {
clearTimeout(timerID);
timerID = null;
timerOn = false;
}
}
function onLoad(){
	init();
}
function ColorHeaderMenu(ind_menu,color) {
	var headmenu=getObj('menuheader'+ind_menu);
	if (headmenu!=null) {
		if (last_header==0) {last_header=ind_menu};
		headmenu.bgColor = color;
	}
}
function getObj(id) {
	if (document.getElementById) {return document.getElementById(id)}
	else if (document.all) {return document.all[id]}
	else {return document.all[id]}
}

function init_td(td_name) {

	var show_menu=GetCookie("show_menu");

	if (show_menu=="0") {
		hide_unhide_td(td_name,false);
	}

}

function hide_unhide_td(td_name,status) {
	if (status) {
		document.getElementById(td_name).style.visibility="visible";
		document.getElementById(td_name).style.position="relative";
	} else {
		document.getElementById(td_name).style.visibility="hidden";
		document.getElementById(td_name).style.position="absolute";
	}
}

function hide_td(td_name) {

	var show_menu=GetCookie("show_menu");
	var show_td;

	if (show_menu=="") {
		show_td=false;
	} else {
		show_td=(show_menu=="0");
	}

	hide_unhide_td(td_name,show_td);

	if (show_menu=="0") {
		SetCookie("show_menu","1")
	} else {
		SetCookie("show_menu","0")
	}

}

function init_table_esp(table_name) {

	var show_menu=GetCookie(table_name);

	if (show_menu=="1") {
		hide_unhide_busq_especial(table_name,true);
	}

}


function hide_unhide_busq_especial(table_name,status) {
	tabla=getObj(table_name);
	if (status) {
		tabla.style.visibility="visible";
		tabla.style.position="relative";
		tabla.style.zIndex=0;
	} else {
		tabla.style.visibility="hidden";
		tabla.style.position="absolute";
		tabla.style.zIndex=-1;
	}

}

function hide_table(table_name) {

	var show_menu=GetCookie(table_name);
	var show_table;

	if (show_menu=="") {
		show_table=true;
		show_menu="0";
	} else {
		show_table=(show_menu=="0");
	}

	hide_unhide_busq_especial(table_name,show_table);

	if (show_menu=="0") {
		SetCookie(table_name,"1")
	} else {
		SetCookie(table_name,"0")
	}

}
