var activeSub=0;
var SubNum=0;

//Define global variables

var timerID = null;
var timerOn = false;
var timecount = 500;
var what = null;
var newbrowser = true;
var check = false;
var nombreLayers = new Array("menu1","menu2","menu3");
var distanciaLayers = new Array(300,400,500);
var screenSize = null;
var diferencia = null;
var nuevaPos1 = null;
var nuevaPos2 = null;
var nuevaPos3 = null;
		
function init(){
	// alert ("Running 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";
		screenSize = document.body.Width;
	}else{
		// alert("Older than 4.0 browser.");
		what="none";
		newbrowser = false;
	}
	check = true;
}
		


// Turns the layers on and off
        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('menu1');
	hideLayer('menu2');
	hideLayer('menu3');
}


function startTime() {
	if (timerOn == false) {
		timerID=setTimeout( "hideAll()" , timecount);
		timerOn = true;
	}
}


function stopTime() {
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}
		
		
// Funcion para posicionar los Layers		
		
		
function posicionarLayers() {
	if(check){
		if (what =="none"){
			return;
		} else if (what == "moz"){
			screenSize = document.body.Width;
			if (screenSize <= 760) {
				document.getElementById('menu1').style.left="203px";
				document.getElementById('menu2').style.left="316px";
				document.getElementById('menu3').style.left="550px";
			} else {
				diferencia = parseInt(((screenSize - 760)/2)+4);
				monto1 = parseInt(203 + diferencia);
				monto2 = parseInt(316 + diferencia);
				monto3 = parseInt(550 + diferencia);
				document.getElementById("menu1").style.left=monto1+"px";
				document.getElementById("menu2").style.left=monto2+"px";
				document.getElementById("menu3").style.left=monto3+"px";
			}
		} else if (what == "ns4"){
			screenSize = window.innerWidth;
			if (screenSize <= 760) {
				eval(layerRef+'["menu1"]'+styleSwitch+'.left=203px');
				eval(layerRef+'["menu2"]'+styleSwitch+'.left=316px');
				eval(layerRef+'["menu3"]'+styleSwitch+'.left=550px');
			} else {
				diferencia = parseInt(((screenSize - 760)/2)+4);
				eval(layerRef+'["menu1"]'+styleSwitch+'.left=203 + diferencia');
				eval(layerRef+'["menu2"]'+styleSwitch+'.left=316 + diferencia');
				eval(layerRef+'["menu3"]'+styleSwitch+'.left=550 + diferencia');
			}
		} else {
			screenSize = document.body.clientWidth - 8;
			if (screenSize <= 760) {
				eval(layerRef+'["menu1"]'+styleSwitch+'.left=203px');
				eval(layerRef+'["menu2"]'+styleSwitch+'.left=316px');
				eval(layerRef+'["menu3"]'+styleSwitch+'.left=550px');
			} else {
				diferencia = parseInt(((screenSize - 760)/2)+4);
				eval(layerRef+'["menu1"]'+styleSwitch+'.left=203 + diferencia');
				eval(layerRef+'["menu2"]'+styleSwitch+'.left=316 + diferencia');
				eval(layerRef+'["menu3"]'+styleSwitch+'.left=550 + diferencia');
			}					
		}
	} else {// alert ("Please wait for the page to finish loading.");
		return;
	}
}

function onLoad(){
	init();
}