/* [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','8001',jdecode('Kyngdom+Plumbing'),jdecode(''), jdecode('%2F8001.html'), 'true',[],'',''],
	['PAGE','13701',jdecode('Plumbing+Photo+Gallery'),jdecode(''), jdecode('%2F13701.html'), 'true',[],'',''],
	['PAGE','9201',jdecode('Plumbing+Promotions'),jdecode(''), jdecode('%2F9201.html'), 'true',[],'',''],
	['PAGE','8401',jdecode('Plumbing+References'),jdecode(''), jdecode('%2F8401.html'), 'true',[],'',''],
	['PAGE','8052',jdecode('Plumbing+Services'),jdecode(''), jdecode('%2F8052.html'), 'true',[],'',''],
	['PAGE','8094',jdecode('Plumbing+Tips+and+Tricks'),jdecode(''), jdecode('%2F8094.html'), 'true',[],'',''],
	['PAGE','8157',jdecode('Contact+Page'),jdecode(''), jdecode('%2F8157.html'), 'true',[],'','']];
var siteelementCount=7;
theSitetree.topTemplateName='Common';
theSitetree.paletteFamily='E7AF4C';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='26638';
theSitetree.graphicsetId='13446';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'fatcow',
  product: 'WSCSYSSSSLY0XRN4'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Common',
				paletteFamily: 	'E7AF4C',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'26638',
				graphicsetId: 	'13446',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8001',
internalId:  '',
customField: '20111226-210824'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8052',
internalId:  '',
customField: '20111226-210012'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8094',
internalId:  '',
customField: '20110119-020538'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8401',
internalId:  '',
customField: '20111226-204545'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8157',
internalId:  '',
customField: '20111226-205811'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9201',
internalId:  '',
customField: '20100630-170951'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8001',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8052',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8094',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8401',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8157',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '9201',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['1501']=webappMappings['1501-12641544']={
webappId:    '1501',
documentId:  '8001',
internalId:  '12641544',
customField: '1501'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '8001',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13701',
internalId:  '',
customField: '20100614-152311'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '13701',
internalId:  '',
customField: 'language:en;country:US;'
};
var webAppHostname = 'cgiwsc.enhancedsitebuilder.com:80';
var canonHostname = 'cmworker01.yourhostingaccount.com';
var accountId     = 'AENDU0INED64';
var companyName   = 'Kyngdom+Plumbing%2CLLC++++++++++++++++++++++++919-201-6358';
var htmlTitle	  = 'Raleigh-Durham+Plumbing-+Licensed+and+Insured+Kyngdom+Plumbing';
var metaKeywords  = 'Raleigh+Plumbing%2C+Durham+Plumbing%2C+Tankless+Water+Heater%2CRaleigh+Plumber%2C+Durham+Plumber%2C+Holly+Springs+Plumber%2C+Sewer+Camera+Inspection%2C+Leaking+pipe+repair%2C';
var metaContents  = 'Experienced%2C+local%2C+licensed+and+insured+plumbing+company+specializing+in+tankless+hot+water+heaters%2C+pipe+replacements+and+supreme+showers.+';
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();
};

