// Begin Custom Aisles Detection

pubArray = new Array()
pubArray[1] = "/default.aspx"
pubArray[2] = "/default.aspx"
pubArray[3] = "/default.aspx"
pubArray[4] = "/default.aspx"
pubArray[5] = "empty"
pubArray[6] = "/default.aspx"
pubArray[7] = "/default.aspx"
pubArray[8] = "/default.aspx"

function autoRedirect() {
	if (hasCACookie() && location.search.length <= 0) {
		redirectIndex = 0
		for (x=1;x<=8;x++) { //Get location
			if (location.pathname == pubArray[x]) {
				redirectIndex = x
				break
			}
		}
		if (redirectIndex >= 1) {
			location = 'default.aspx?screen=' + redirectIndex
		}
	}
}

function hasCACookie() {
	cookieContents = document.cookie
	cookieIndex = cookieContents.indexOf('nolCustomAisleToken')
	if (cookieIndex >= 0) { // && document.cookie.slice(cookieIndex+20,cookieIndex+20+2) != "ps"
		return true
	} else {
		return false
	}
}

function sourceRedirect(z) {
	if (hasCACookie()) {
		location = '/default.aspx?screen=' + z
	} else {
		location = pubArray[z]
	}
}

// End Custom Aisles Detection




//BEGIN DYNAMIC MENUS

imageArray = new Array('Inicio','noticias','servicio','Padres','Alumnos','Profesores');
imagePath = "";
function preloadImages() {
	for(x=0;x<imageArray.length;x++) {
		eval(imageArray[x] + 'off = new Image();');
		eval(imageArray[x] + 'off.src = "' + imagePath + imageArray[x] + '_off.gif";');
		eval(imageArray[x] + 'over = new Image();');
		eval(imageArray[x] + 'over.src = "' + imagePath + imageArray[x] + '_off.gif";');
	}
}
preloadImages();

function turnon(i) {
	document[i].src = eval(i + "off.src")
}
function turnoff(i) {
	if (i != currentSection) {
		document[i].src = eval(i + "over.src")
	}
}
//-----------------------------
// LISTA DE PAGINAS --- A ---
//-----------------------------
Inicio = new Array (
  ["Inicio", "default.aspx"]
)
//-----------------------------
// LISTA DE PAGINAS --- B ---
//-----------------------------
noticias = new Array (
  ["Solicitar Información", "default.aspx"],
  //["Lista de correo", "default.aspx"],
  ["Periódico", "default.aspx"]

)
//-----------------------------
// LISTA DE PAGINAS --- C ---
//-----------------------------
servicio = new Array (
  ["Solicitar Información", "C001.aspx"],
 // ["Comentarios", "C002.aspx"],
  ["Biblioteca", "C003.aspx"],
  //["Lista de correo", "C004.aspx"],
  ["Periódico del Colegio", "na.aspx"]
)
//-----------------------------
// LISTA DE PAGINAS --- D ---
//-----------------------------
Padres = new Array (
  ["Sistema de Notas", "http://www.gcnewhorizons.net/Colegio/estudiantespadres/notasstgo/default.asp"],
  //["Current Balance", "https://myaccount.gcnewhorizons.net/servlet/ecare?inf_action=login&action=accountInfo"],
  ["Sistema Médico", "na.aspx"],
  ["Sistema Reserva Cupo", "d003.aspx"],
  ["Sistema Cálculo Tarifa", "http://www.gcnewhorizons.net/Colegio/estudiantespadres/easyratestgo/"],
  ["Camaras en Línea", "http://www.gcnewhorizons.net/Colegio/estudiantespadres/camstgo/"],
//  ["GSU", "default.aspx"],
  
  ["Otros Documentos", "D001.aspx"]
)
//-----------------------------
// LISTA DE PAGINAS --- E ---
//-----------------------------
Alumnos = new Array (
  ["Directorio Clases y Apuntes", "e001.aspx"],
  //["E-Learning Login", "na.aspx"],
  ["Horario & Calendarios", "E003.aspx"]
)
//-----------------------------
// LISTA DE PAGINAS --- F ---
//-----------------------------
Profesores = new Array (
  ["Manuales y Documentos", "F001.aspx"]
  //["E-Learning Login", "na.aspx"]
 // ["Sistema de Horarios", "http://www.gcnewhorizons.net/horarios/default.asp"]
 // ["IT Help Desk", "Default.aspx"],
  //["Clases y Apuntes", "Default.aspx"]
)

navArrow = '<img src="white_arrow.gif" border=0>';
menuWidth = 175
menuHeight = 17
menuColor = "#8c8a8c"
menuHighlight = "#525552"
menuborderColor = "#292829"
borderStyle1 = ' border-top-width: 1px; border-left-width: 1px; border-bottom-width: 0px; border-right-width: 1px; border-color: ' + menuborderColor + '; border-style: solid; '
borderStyle2 = ' border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px; border-color: ' + menuborderColor + '; border-style: solid;  width:' + menuWidth + 'px; height:' + menuHeight + 'px; '

menuVposition = new Array (75,75,75,75,75,75,75)
menuHposition = new Array (0,137,209,337,437,537)
menuArray = new Array ('Inicio','noticias','servicio','Padres','Alumnos','Profesores')

URLpath = new String( window.location.pathname );
currentSection = ""
appSection = new Array(['NASApp/care','Padres'],['NASApp/onlinestore','Inicio'],['NASApp/registration','Padres'])
cgiSection = new Array(['getSvcLocations','servicio'],['getSalesLocations','Inicio'],['localMarketMap','servicio'])

function getSection() {
	if (window.thisSection) {
		currentSection = thisSection
		turnon(currentSection)
	} else {
		for ( var i=0; i < menuArray.length; i++ ) {
			if( URLpath.indexOf( menuArray[i] ) >= 0 ) {
				currentSection = menuArray[i];
				turnon(menuArray[i])
				break
			}
		}
		if (currentSection == "") {
			for (i=0;i<appSection.length; i++) {
				if( URLpath.indexOf( appSection[i][0] ) >= 0 ) {
					currentSection = appSection[i][1];
					turnon(currentSection)
					break
				}
			}
		}
		if (currentSection == "") {
			for (i=0;i<cgiSection.length; i++) {
				if( URLpath.indexOf( cgiSection[i][0] ) >= 0 ) {
					currentSection = cgiSection[i][1];
					turnon(currentSection)
					break
				}
			}
		}
	}
}

active=false
menusReady = false
currentMenu = ""

var NS4 = false
var IE4 = false
var DOM = false
var IE = false
var NS6 = false

oldIE = ( navigator.appName.indexOf('Microsoft') >= 0 && navigator.appVersion.indexOf('MSIE 4.') >= 0) ? true:false
if (document.getElementById) { DOM = true; browser="DOM"; }
if (document.layers && !DOM) { NS4 = true; browser="NS4"; }
if (document.all && !DOM) IE4 = true
if (navigator.appName.indexOf("Microsoft Internet Explorer") > -1) IE = true
if (DOM && !IE) NS6 = true

function initLayers() {

if (IE || DOM) {
	for (x=0; x<menuArray.length; x++) {
		layerName = menuArray[x] + 'Layer'
		useArray = eval(menuArray[x])
		menu = '<div id="' + layerName + '" style="position: absolute; width: ' + menuWidth + 'px; z-index: 20; background-color: ' + menuHighlight + '; visibility: hidden;" onmouseout="unLock(\'' + menuArray[x] + 'Lyr\')" onmouseover="lock(\'' + menuArray[x] + 'Lyr\')">';
		for (v=0;v<useArray.length;v++) {
			menu += '<div id="' + layerName + v + '" style="position: relative; background-color: ' + menuColor + '; z-index: ' + x + 30 + '; height:' + menuHeight + 'px; ' + borderStyle1
			menu += (NS6) ? 'width:' + (menuWidth - 1) + 'px; ' : 'width:' + menuWidth + 'px; '
			menu += (v == useArray.length - 1) ?  " border-bottom-width: 1px;" : " border-bottom-width: 0px;"
			menu += '" onmouseover="highlight(\'' + menuArray[x] + v + 'Lyr\')" onmouseout="unhighlight(\'' + menuArray[x] + v + 'Lyr\')" onclick="linkto(\'' + useArray[v][1] + '\')"><table cellspacing=2><tr><td>' + navArrow + '<a href="' + useArray[v][1] + '" class=menuLink>' + useArray[v][0] + '<\/a><\/td><\/tr><\/table><\/div>';
		}
		menu += '<\/div>\n';
		document.write(menu);
	}
}

if (NS4) {
	document.write('<style type="text/css">\n')
	document.write('all.menuItem1 {' + borderStyle1 + ' width:' + menuWidth + 'px; }\n')
	document.write('all.menuItem2 {' + borderStyle2 + '}\n')
	document.write('all.menuLink { padding-left: 2px; padding-top: 0px;}</style>')
	for (x=0; x<menuArray.length; x++) {
		layerName = menuArray[x] + 'Layer'
		useArray = eval(menuArray[x])
		menu = '<layer id="' + layerName + '" width=' + menuWidth + ' z-index=20 visibility=hide onmouseout="unLock(\'' + menuArray[x] + 'Lyr\')" onmouseover="lock(\'' + menuArray[x] + 'Lyr\')">';
		for (v=0;v<useArray.length;v++) {
			menu += '<ilayer id="' + layerName + v + '" bgcolor=' + menuColor + '><layer class='
			menu += (v == useArray.length - 1) ?  'menuItem2' : 'menuItem1'
			menu += ' z-index=' + (x + 30 - v) + ' onmouseover="highlight(\'' + menuArray[x] + v + 'Lyr\')"'
			menu += ' onmouseout="unhighlight(\'' + menuArray[x] + v + 'Lyr\')"><a href="' + useArray[v][1] + '" class=menuLink>' + navArrow + useArray[v][0] + '<\/a><\/layer></ilayer><br>';
		}
		menu += '<\/layer>\n';
		document.write(menu);
	}

}

for (x=0; x<menuArray.length; x++) {
	layerName = menuArray[x] + 'Layer'
	useArray = eval(menuArray[x])
	eval(menuArray[x] + 'Lyr = new domObject(\'' + layerName + '\')');
	for (v=0;v<useArray.length;v++) {
		eval(menuArray[x] + v + 'Lyr = new domObject(\'' + layerName + v + '\',\'' + layerName + '\')')
	}
	eval(menuArray[x] + 'Lyr.sty.left = ' + menuHposition[x])
	eval(menuArray[x] + 'Lyr.sty.top = ' + menuVposition[x])
}
menusReady = true;
}

if (!oldIE) initLayers()

function domObject(theName,nestedLayer,frame) {
	if (DOM || NS4) {
		if (DOM) {
			this.sty = document.getElementById(theName).style
		}
		 if (NS4) {
			if (nestedLayer) {
				this.sty = eval('document.' + nestedLayer + '.document.' + theName)
			} else {
				this.sty = document.layers[theName]
			}
		}
	}
	if (IE4) {
		this.sty = this.frame.document.all[theName].style
	}
	this.theName = theName
	this.active = false
	this.locked = false
}


function showMenu(theMenu) {
	theName = theMenu.replace(/Lyr/, "")
	if (menusReady && !oldIE) {
		if (currentMenu != theName && currentMenu != "") {
			dropit(theMenu);
		}
		currentMenu = theName;
		argMenu = theMenu
		eval(theMenu + ".active = true")
		show = setTimeout("showIt(argMenu)", 100)
	}
}

function dropMenu(theMenu) {
	eval(theMenu + ".active = false")
	whichMenu = theMenu
	wait = setTimeout("dropit(whichMenu)", 0)
	//dropit(theMenu)
}

function showIt(theMenu) {
	if (eval(theMenu + ".active") == true) {
		eval(theMenu + '.sty.visibility = (NS4)? "show" : "visible"')
		theName = theMenu.replace(/Lyr/, "")
		turnon(theName)
	}
}

function dropit(theMenu) {
	if (!oldIE && eval(theMenu + ".locked") == false) {
		eval(theMenu + '.sty.visibility = (NS4)? "hide" : "hidden"')
		currentMenu = ""
		theName = theMenu.replace(/Lyr/, "")
		turnoff(theName)
	}
}

function highlight(theMenu) {
	if (IE || DOM) {
		eval(theMenu + '.sty.backgroundColor = "' + menuHighlight + '"')
		eval(theMenu + '.sty.cursor = "hand"')
	}
	if (NS4) {
		eval(theMenu + '.sty.bgColor = "' + menuHighlight + '"')
	}
}

function unhighlight(theMenu) {
	if (IE || DOM) {
		eval(theMenu + '.sty.backgroundColor = "' + menuColor + '"')
		eval(theMenu + '.sty.cursor = "auto"')
	}
	if (NS4) {
		eval(theMenu + '.sty.bgColor = "' + menuColor + '"')
	}
}

function lock(theMenu) {
	eval(theMenu + ".locked = true")
}

function unLock(theMenu) {
	eval(theMenu + ".locked = false")
	dropMenu(theMenu)
}

function linkto(loc) {
	jsLink = loc.indexOf("javascript:")
	if (jsLink >= 0) {
		eval(loc)
	} else {
		location = loc
	}
}
