/* [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','1901',jdecode('Home'),jdecode(''),'/1901/index.html','true',[ 
		['PAGE','60527',jdecode('Ligon+Home'),jdecode(''),'/1901/60527.html','false',[],'',''],
		['PAGE','98238',jdecode('Math+Camp'),jdecode(''),'/1901/98238.html','false',[],'',''],
		['PAGE','240590',jdecode('Math+Circle'),jdecode(''),'/1901/240590.html','false',[],'',''],
		['PAGE','210174',jdecode('NCCTM+Presentation'),jdecode(''),'/1901/210174.html','false',[],'','']
	],'',''],
	['PAGE','152763',jdecode('Bookstore'),jdecode(''),'/152763.html','true',[],'',''],
	['PAGE','1952',jdecode('Algebra'),jdecode(''),'/1952/index.html','true',[ 
		['PAGE','184874',jdecode('Math+8'),jdecode(''),'/1952/184874.html','true',[],'','']
	],'',''],
	['PAGE','1973',jdecode('Geometry'),jdecode(''),'/1973.html','true',[],'',''],
	['PAGE','57427',jdecode('MATHCOUNTS'),jdecode(''),'/57427/index.html','true',[ 
		['PAGE','167463',jdecode('Ligon+MATHCOUNTS'),jdecode(''),'/57427/167463.html','false',[],'',''],
		['PAGE','191274',jdecode('Carnage+MATHCOUNTS'),jdecode(''),'/57427/191274.html','false',[],'',''],
		['PAGE','223285',jdecode('AGMath+Challenge'),jdecode(''),'/57427/223285.html','true',[],'','']
	],'',''],
	['PAGE','23806',jdecode('AMC'),jdecode(''),'/23806.html','true',[],'',''],
	['PAGE','7801',jdecode('Puzzles'),jdecode(''),'/7801.html','true',[],'',''],
	['PAGE','169763',jdecode('Submit+Content'),jdecode(''),'/169763.html','true',[],'',''],
	['PAGE','7822',jdecode('Links'),jdecode(''),'/7822.html','true',[],'',''],
	['PAGE','27517',jdecode('Message+Board'),jdecode(''),'/27517.html','true',[],'',''],
	['PAGE','117838',jdecode('Jason+Batterson'),jdecode(''),'/117838.html','false',[],'',''],
	['PAGE','131353',jdecode('Boyd+Blackburn'),jdecode(''),'/131353.html','false',[],'','']];
var siteelementCount=20;
theSitetree.topTemplateName='Orbit';
theSitetree.paletteFamily='333333';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='172';
theSitetree.graphicsetId='204';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='333333';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Orbit',
				paletteFamily: 	'333333',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'172',
				graphicsetId: 	'204',
				contentColor: 	'FFFFFF',
				contentBGColor: '333333',
				a_color: 		'333333',
				b_color: 		'999999',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1901',
internalId:  '',
customField: '20100810-005810'
};
webappMappings['1002']=webappMappings['1002-27517aendu0in2s1y']={
webappId:    '1002',
documentId:  '27517',
internalId:  '27517aendu0in2s1y',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1952',
internalId:  '',
customField: '20100503-183846'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1973',
internalId:  '',
customField: '20100321-124518'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '60527',
internalId:  '',
customField: '20100523-210314'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23806',
internalId:  '',
customField: '20100224-172831'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7801',
internalId:  '',
customField: '20090828-212026'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7822',
internalId:  '',
customField: '20090724-220203'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1901',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '152763',
internalId:  '',
customField: '20100810-010029'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '131353',
internalId:  '',
customField: '20090222-132853'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '117838',
internalId:  '',
customField: '20090510-151933'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27517',
internalId:  '',
customField: '20090826-165413'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '57427',
internalId:  '',
customField: '20100319-172615'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '98238',
internalId:  '',
customField: '20091217-174344'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '167463',
internalId:  '',
customField: '20100305-173805'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '169763',
internalId:  '',
customField: '20091116-170049'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '184874',
internalId:  '',
customField: '20100501-201821'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '191274',
internalId:  '',
customField: '20100301-192447'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '210174',
internalId:  '',
customField: '20091028-202310'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '223285',
internalId:  '',
customField: '20100108-213646'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '240590',
internalId:  '',
customField: '20091210-172149'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0IN2S1Y';
var companyName   = 'AGMath.com';
var htmlTitle	  = 'Algebra+and+Geometry+for+the+Academically+Gifted';
var metaKeywords  = 'Batterson%2C+Algebra%2C+Geometry%2C+Mathematics%2C+Math%2C+Puzzles%2C+Solving+Equations%2C+Integers%2C+Exponents%2C+Proportions%2C+Percent%2C+Dilations%2C+Linear+Equations%2C+Functions%2C+Polynomials%2C+GCF%2C+LCM%2C+FOIL%2C+Distribution%2C+Quadratics%2C+Pythagorean%2C+Reasoning%2C+Triangles%2C+Polygons%2C+Circles%2C+Area%2C+Perimeter%2C+Similarity%2C+Trigonometry%2C+Proofs%2C+Rotations%2C+Reflections%2C+Transformations%2C+EOG%2C+EOC';
var metaContents  = 'Algebra%2C+Geometry%2C+and+More+for+Academically+Gifted+Students';
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();
};

