/* [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','2601',jdecode('Bellydance+Sheet+Music'),jdecode(''),'/2601.html','true',[],'',''],
	['PAGE','7301',jdecode('Purchase+Sheet+Music'),jdecode(''),'/7301.html','true',[],'',''],
	['PAGE','13001',jdecode('Free+items+and+Lyrics'),jdecode(''),'/13001.html','true',[],'',''],
	['PAGE','11701',jdecode('How+does+this+work%3F'),jdecode(''),'/11701.html','true',[],'',''],
	['PAGE','3485',jdecode('Which+music+for+you%3F'),jdecode(''),'/3485.html','true',[],'',''],
	['PAGE','2673',jdecode('About+Melissa+Murphey'),jdecode(''),'/2673.html','true',[],'',''],
	['PAGE','10201',jdecode('Events+and+Workshops'),jdecode(''),'/10201/index.html','true',[ 
		['PAGE','11101',jdecode('Pennsic+2010'),jdecode(''),'/10201/11101.html','true',[],'','']
	],'',''],
	['PAGE','2652',jdecode('Contact'),jdecode(''),'/2652.html','true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Surround';
theSitetree.paletteFamily='C12C21';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10502';
theSitetree.graphicsetId='11132';
theSitetree.contentColor='DDDDDD';
theSitetree.contentBGColor='C12C21';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Surround',
				paletteFamily: 	'C12C21',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10502',
				graphicsetId: 	'11132',
				contentColor: 	'DDDDDD',
				contentBGColor: 'C12C21',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'FEA7A1',
				e_color: 		'FEA7A1',
				f_color: 		'FEA7A1',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2601',
internalId:  '',
customField: '20090613-233603'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2652',
internalId:  '',
customField: '20090507-193658'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2673',
internalId:  '',
customField: '20090508-131523'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7301',
internalId:  '',
customField: '20091113-185312'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3485',
internalId:  '',
customField: '20090614-000200'
};
webappMappings['4001']=webappMappings['4001-4092931']={
webappId:    '4001',
documentId:  '7301',
internalId:  '4092931',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11101',
internalId:  '',
customField: '20100717-125649'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11701',
internalId:  '',
customField: '20090716-121559'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10201',
internalId:  '',
customField: '20100701-050658'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13001',
internalId:  '',
customField: '20090716-122033'
};
webappMappings['1501']=webappMappings['1501-4253710']={
webappId:    '1501',
documentId:  '2601',
internalId:  '4253710',
customField: '1501'
};
var canonHostname = 'localhost';
var accountId     = 'ANFI10INX3T1';
var companyName   = 'Vintage+Bellydance+Sheet+Music+by+Melissa+Murphey';
var htmlTitle	  = 'Bellydance+Sheet+Music';
var metaKeywords  = 'bellydance%2C+sheet+music%2C+middle+eastern%2C+mediterranean%2C+Ishtar%2C+Melissa+Murphey%2C+bellyrock%2C+pdf%2C+SCA%2C+hafla%2C+Jalsah.';
var metaContents  = 'Sheet+music+of+the+Middle+East+and+Mediterranean+available+for+sale.+Popular+bellydance+and+hafla+songs+in+simple+format.';
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();
};

