/* [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 theSitetree=[ 
	['PAGE','8001',jdecode('Home'),jdecode(''),'/8001.html','true',[],''],
	['PAGE','8052',jdecode('Services'),jdecode(''),'/8052.html','true',[],''],
	['PAGE','13701',jdecode('Photo+Gallery'),jdecode(''),'/13701.html','true',[],''],
	['PAGE','8094',jdecode('Tips+and+tricks'),jdecode(''),'/8094.html','true',[],''],
	['PAGE','8401',jdecode('References'),jdecode(''),'/8401.html','true',[],''],
	['PAGE','8157',jdecode('Contact'),jdecode(''),'/8157.html','true',[],''],
	['PAGE','9201',jdecode('Promotions'),jdecode(''),'/9201.html','true',[],'']];
var siteelementCount=7;
theSitetree.topTemplateName='Common';
theSitetree.paletteFamily='E7AF4C';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='26637';
theSitetree.graphicsetId='13446';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Common',
				paletteFamily: 	'E7AF4C',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'26637',
				graphicsetId: 	'13446',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8001',
internalId:  '',
customField: '20100621-093817'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8052',
internalId:  '',
customField: '20100621-093847'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8094',
internalId:  '',
customField: '20100614-152503'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8401',
internalId:  '',
customField: '20090327-130358'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8157',
internalId:  '',
customField: '20100616-122416'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9201',
internalId:  '',
customField: '20100630-165148'
};
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 canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0INED64';
var companyName   = 'Kyngdom+Plumbing%2CLLC+';
var htmlTitle	  = 'Kyngdom+Plumbing';
var metaKeywords  = 'Gas+Pipe+leak+detectors+raleigh+nc%2C+gas+pipe+repair+triangle+nc%2C+gas+pipe+installation+raleigh+nc%2C+Water+Heater+Repair%2C+Water+Heater+Replacement%2C+tankless+water+heater%2C+pipe+replacement+in+raleigh+nc%2C+pipe+repair+raleigh+nc%2C+plumbing+services+in+holly+springs+nc%2C+plumbers+durham+nc%2C+cracked+pipe+triangle+nc%2C+fixture+installation+north+carolina%2C+plumbing+services+apex+nc%2C+plumber+raleigh+nc%2C+plumber+cary+nc%2C+fuquay-varina+plumbing+repair%2C+tub+installation+raleigh+north+carolina%2C+sink+repair+raleigh%2C+dishwasher+installation+and+repair+raleigh%2C+morrisville+plumbing+services';
var metaContents  = 'Kyngdom+Plumbing+is+a+licensed+and+insured+plumbing+company+serving+the+triangle+region+of+North+Carolina.++We+provide+plumbing+services+to+Raleigh%2C+Durham%2C+Holly+Springs%2C+Morrisville%2C+Cary%2C+Apex%2C+Garner%2C+Knightdale+and+Fuquay-Varina+NC.++We+serve+Wake+County+and+Durham.++Our+services+include%3A+plumber%2C+water+heater+installation%2C+water+heater+replacements%2C+polybutylene+pipe+replacement%2C+sink+installation%2C+bathtub%2C+jetted+tub+and+whirlpool+services.++We+also+repair+and+replace+pipes+and+so+much+more%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();
};
