/* [nodename, id, name, navigationtext, href, isnavigation, childs[], templatename] */

if (typeof(decodeURIComponent) == 'undefined') {
  decodeURIComponent = function(s) {
    return unescape(s);
  }
}

function jdecode(s) {
    s = s.replace(/\+/g, "%20")
    return decodeURIComponent(s);
}

var POS_NODENAME=0;
var POS_ID=1;
var POS_NAME=2;
var POS_NAVIGATIONTEXT=3;
var POS_HREF=4;
var POS_ISNAVIGATION=5;
var POS_CHILDS=6;
var POS_TEMPLATENAME=7;
var POS_TARGET=8;
var theSitetree=[ 
	['PAGE','501',jdecode('Home'),jdecode(''), jdecode('%2F501.html'), 'true',[],'',''],
	['PAGE','552',jdecode('Ingl%C3%AAs'),jdecode(''), jdecode('%2F552.html'), 'true',[],'',''],
	['PAGE','14701',jdecode('Programa+Kids'),jdecode(''), jdecode('%2F14701.html'), 'true',[],'',''],
	['PAGE','14722',jdecode('Programa+Teens'),jdecode(''), jdecode('%2F14722.html'), 'true',[],'',''],
	['PAGE','14743',jdecode('Programa+Adults'),jdecode(''), jdecode('%2F14743.html'), 'true',[],'',''],
	['PAGE','72412',jdecode('Inscri%C3%A7%C3%B5es+Online'),jdecode(''), jdecode('%2F72412.html'), 'true',[],'',''],
	['PAGE','573',jdecode('Inform%C3%A1tica'),jdecode(''), jdecode('%2F573.html'), 'true',[],'',''],
	['PAGE','11601',jdecode('Cursos+Inform%C3%A1tica'),jdecode(''), jdecode('%2F11601.html'), 'true',[],'',''],
	['PAGE','6001',jdecode('Galeria+de+Fotos'),jdecode(''), jdecode('%2F6001.html'), 'true',[],'',''],
	['PAGE','6022',jdecode('Games'),jdecode(''), jdecode('%2F6022.html'), 'true',[],'',''],
	['PAGE','72512',jdecode('Notas+Online'),jdecode(''), jdecode('%2F72512.html'), 'true',[ 
		['ITEM','72533',jdecode('Notas+Alunos'),jdecode(''), jdecode('http%3A%2F%2Fwww.notasonline.com.br%2Fspnotas%2FDefault.aspx%3Fcid%3D50%26tid%3D0'), 'true',[],'',''],
		['ITEM','72534',jdecode('Notas+Professores'),jdecode(''), jdecode('http%3A%2F%2Fwww.notasonline.com.br%2Fspnotas%2FDefault.aspx%3Fcid%3D50%26tid%3D1'), 'true',[],'',''],
		['ITEM','72535',jdecode('Notas+Respons%C3%A1vel'),jdecode(''), jdecode('http%3A%2F%2Fwww.notasonline.com.br%2Fspnotas%2FDefault.aspx%3Fcid%3D50%26tid%3D2'), 'true',[],'','']
	],'','']];
var siteelementCount=14;
theSitetree.topTemplateName='Porthole';
theSitetree.paletteFamily='920707';
theSitetree.keyvisualId='6711';
theSitetree.keyvisualName='kv_6711.jpg';
theSitetree.fontsetId='11200';
theSitetree.graphicsetId='12017';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FAEEEE';
var localeDef={
  language: 'pt',
  country: 'BR'
};
var prodDef={
  wl_name: 'brazilprod',
  product: 'WSCSYSSSSLY0X9A9'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Porthole',
				paletteFamily: 	'920707',
				keyvisualId: 	'6711',
				keyvisualName: 	'kv_6711.jpg',
				fontsetId: 		'11200',
				graphicsetId: 	'12017',
				contentColor: 	'000000',
				contentBGColor: 'FAEEEE',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20120111-142322'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '552',
internalId:  '',
customField: '20101105-060601'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14701',
internalId:  '',
customField: '20090521-094119'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14722',
internalId:  '',
customField: '20090521-145920'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14743',
internalId:  '',
customField: '20120111-131608'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '573',
internalId:  '',
customField: '20110505-081240'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11601',
internalId:  '',
customField: '20110209-115943'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6001',
internalId:  '',
customField: '20101105-060413'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6022',
internalId:  '',
customField: '20090618-094610'
};
webappMappings['1501']=webappMappings['1501-16096571']={
webappId:    '1501',
documentId:  '501',
internalId:  '16096571',
customField: '1501'
};
webappMappings['7060']=webappMappings['7060-0ff60da1bd282a2c125fe1d33160085c']={
webappId:    '7060',
documentId:  '6001',
internalId:  '0ff60da1bd282a2c125fe1d33160085c',
customField: 'language:pt;country:BR;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '72412',
internalId:  '',
customField: '20101105-074359'
};
webappMappings['7008']=webappMappings['7008-20905']={
webappId:    '7008',
documentId:  '72412',
internalId:  '20905',
customField: 'language:pt;country:BR;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '72512',
internalId:  '',
customField: '20101105-061834'
};
var webAppHostname = 'diycgi.cluster.stngva01.us.diy-servers.net:80';
var canonHostname = 'diywk00.verio.stngva01.us.diy-servers.net';
var accountId     = 'AVEC10INELRW';
var companyName   = 'Advance+English+Center';
var htmlTitle	  = 'ADVANCE+ENGLISH+CENTER';
var metaKeywords  = '';
var metaContents  = '';
theSitetree.getById = function(id, ar) {
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		if (ar[i][POS_ID] == id){
			return ar[i];
		}
		if (ar[i][POS_CHILDS].length > 0) {
			var result=this.getById(id, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getParentById = function(id, ar) {
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		for (var j = 0; j < ar[i][POS_CHILDS].length; j++) {
			if (ar[i][POS_CHILDS][j][POS_ID] == id) {
				// child found
				return ar[i];
			}
			var result=this.getParentById(id, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getName = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_NAME];
	}
	return null;
};

theSitetree.getNavigationText = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_NAVIGATIONTEXT];
	}
	return null;
};

theSitetree.getHREF = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_HREF];
	}
	return null;
};

theSitetree.getIsNavigation = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_ISNAVIGATION];
	}
	return null;
};

theSitetree.getTemplateName = function(id, lastTemplateName, ar) {
	if (typeof(lastTemplateName) == 'undefined'){
		lastTemplateName = this.topTemplateName;
	}
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		var actTemplateName = ar[i][POS_TEMPLATENAME];
		if (actTemplateName == ''){
			actTemplateName = lastTemplateName;
		}
		if (ar[i][POS_ID] == id) {
			return actTemplateName;
		}
		if (ar[i][POS_CHILDS].length > 0) {
			var result=this.getTemplateName(id, actTemplateName, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getByXx = function(lookup, xx, ar) {
    if (typeof(ar) == 'undefined'){
    	ar = this;
    }
    for (var i=0; i < ar.length; i++) {
        if (ar[i][xx] == lookup){
        	return ar[i];
        }
        if (ar[i][POS_CHILDS].length > 0) {
        	var result=this.getByXx(lookup, xx, ar[i][POS_CHILDS]);
            if (result != null){
                return result;
               }
        }
    }
    return null;
};

function gotoPage(lookup) {
	if(__path_prefix__ == "/servlet/CMServeRES" && typeof (changePage) == 'function'){
		changePage(lookup);
		return;
	}
	var page = theSitetree.getHREF(lookup);
	if (!page) {
		var testFor = [ POS_NAME, POS_NAVIGATIONTEXT ];
		for (var i=0 ; i < testFor.length ; i++) {
			var p = theSitetree.getByXx(lookup, testFor[i]);
			if (p != null) {
				page = p[POS_HREF];
				break;
			}
		}
	}
	document.location.href = (new URL(__path_prefix__ + page, true, true)).toString();
};

