/* [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('Music+Store'),jdecode(''),'/501.html','true',[],'',''],
	['PAGE','901',jdecode('Guitars%2C+Basses%2C+%26+Drums'),jdecode(''),'/901.html','true',[],'',''],
	['PAGE','922',jdecode('Accessories%2C+Lessons%2C+Etc.'),jdecode(''),'/922.html','true',[],'','']];
var siteelementCount=3;
theSitetree.topTemplateName='Architekt';
theSitetree.paletteFamily='C8C0A4';
theSitetree.keyvisualId='1697';
theSitetree.keyvisualName='chart.jpg';
theSitetree.fontsetId='281';
theSitetree.graphicsetId='347';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='C8C0A4';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Architekt',
				paletteFamily: 	'C8C0A4',
				keyvisualId: 	'1697',
				keyvisualName: 	'chart.jpg',
				fontsetId: 		'281',
				graphicsetId: 	'347',
				contentColor: 	'000000',
				contentBGColor: 'C8C0A4',
				a_color: 		'C8C0A4',
				b_color: 		'5C5438',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Times New Roman, Times, serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
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: '20100608-175644'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '901',
internalId:  '',
customField: '20100601-175745'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '922',
internalId:  '',
customField: '20100608-175240'
};
var canonHostname = 'wsc-worker03.chi.us.siteprotect.com';
var accountId     = 'AHW050INX2QZ';
var companyName   = 'Trapp+Sound+and+Music';
var htmlTitle	  = 'TRAPP+SOUND+AND+MUSIC++Lebanon%2C+IN+46052';
var metaKeywords  = 'ESP%2C+LTD%2C+Ludwig%2C+guitars%2C+amplifiers%2C+basses%2C+drums%2C+music+store%2C+lessons%2C+musicians%2C+accessories%2C+music+books%2C+strings%2C++sticks%2C++capo%2C+tuner%2C+Alvarez%2C+Fender%2CEpiphone%2C+Ibanez%2C+new+and+used+guitars%2C+acoustic+and+electric++Lebanon+IN+46052%2Cjh200dc';
var metaContents  = 'Trapp+Sound+and+Music+Lebanon+IN%2C+46052.++NEW+MUSIC+STORE.+we+offer+lessons+for+guitar+%2Cbass+and+drums%2C%28765%29-482-7558+proud+ESP%2FLTD+dealers.+BUY+HERE%21++Check+us+out+for+rock+bottom+prices+on+LTD+and+ESP+guitars%2C+as+well+as+drums%2C+amps%2C+and+accessories.+alvarez%2C+fender%2C+epiphone%2C+crate%2C+ampeg%2C+new+and+used%2C++111+west+north+st.+Lebanon+IN+46052+BE+A+REAL+GUITAR+HERO%2C+BUY+A+REAL+GUITAR%21';
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();
};
