/* [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','65401',jdecode('Napier+'),jdecode(''), jdecode('%2F65401.html'), 'true',[],'',''],
	['PAGE','66201',jdecode('Havelock+North'),jdecode(''), jdecode('%2F66201.html'), 'true',[],'',''],
	['PAGE','11269',jdecode('Hot+Water+Shop'),jdecode(''), jdecode('%2F11269.html'), 'true',[],'',''],
	['PAGE','11143',jdecode('Contact+Details'),jdecode(''), jdecode('%2F11143.html'), 'true',[],'',''],
	['PAGE','40401',jdecode('Why+choose+us'),jdecode(''), jdecode('%2F40401.html'), 'true',[],'',''],
	['PAGE','79601',jdecode('Our+Plumbers'),jdecode(''), jdecode('%2F79601.html'), 'true',[],'',''],
	['PAGE','79801',jdecode('Gurantee'),jdecode(''), jdecode('%2F79801.html'), 'true',[],'',''],
	['PAGE','44201',jdecode('Eco+Plumbers'),jdecode(''), jdecode('%2F44201.html'), 'true',[],'',''],
	['PAGE','11353',jdecode('References'),jdecode(''), jdecode('%2F11353.html'), 'true',[],'',''],
	['PAGE','11332',jdecode('Tips+%26+Tricks'),jdecode(''), jdecode('%2F11332.html'), 'true',[],'',''],
	['PAGE','43701',jdecode('Terms+of+Trade'),jdecode(''), jdecode('%2F43701.html'), 'true',[],'',''],
	['PAGE','54101',jdecode('Current+Specials'),jdecode(''), jdecode('%2F54101%2Findex.html'), 'true',[ 
		['PAGE','54185',jdecode('Current+Specials'),jdecode(''), jdecode('%2F54101%2F54185.html'), 'true',[],'','']
	],'',''],
	['PAGE','11101',jdecode('About+us'),jdecode(''), jdecode('%2F11101.html'), 'false',[],'',''],
	['PAGE','39301',jdecode('Address'),jdecode(''), jdecode('%2F39301.html'), 'false',[],'','']];
var siteelementCount=15;
theSitetree.topTemplateName='Fragment';
theSitetree.paletteFamily='B3C6D1';
theSitetree.keyvisualId='3451';
theSitetree.keyvisualName='kv_3451.jpg';
theSitetree.fontsetId='10430';
theSitetree.graphicsetId='10764';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'mitdnz',
  product: 'WSCSYSSSSLYTC22A'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Fragment',
				paletteFamily: 	'B3C6D1',
				keyvisualId: 	'3451',
				keyvisualName: 	'kv_3451.jpg',
				fontsetId: 		'10430',
				graphicsetId: 	'10764',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'B3C6D1',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'3A5260',
				e_color: 		'3A5260',
				f_color: 		'3A5260',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '43701',
internalId:  '',
customField: '20120112-160028'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39301',
internalId:  '',
customField: '20110613-173330'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '54185',
internalId:  '',
customField: '20100715-171550'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '54101',
internalId:  '',
customField: '20120112-160047'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '65401',
internalId:  '',
customField: '20120112-161206'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11101',
internalId:  '',
customField: '20110803-222108'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11143',
internalId:  '',
customField: '20120112-155735'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11269',
internalId:  '',
customField: '20120112-161241'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '65401',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11332',
internalId:  '',
customField: '20120112-160010'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11353',
internalId:  '',
customField: '20120112-155939'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '66201',
internalId:  '',
customField: '20120112-162038'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '44201',
internalId:  '',
customField: '20120112-155908'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40401',
internalId:  '',
customField: '20120112-155804'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '79601',
internalId:  '',
customField: '20120112-161017'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '79801',
internalId:  '',
customField: '20110707-201839'
};
var webAppHostname = 'diycgi.cluster.stngva01.us.diy-servers.net:80';
var canonHostname = 'diywk01.verio.stngva01.us.diy-servers.net';
var accountId     = 'AVEC10INVCF8';
var companyName   = 'PLUMBERS+NAPIER+%26+HAVELOCK+NORTH';
var htmlTitle	  = 'Napier+%26+Havelock+Nth+Plumbers';
var metaKeywords  = '';
var metaContents  = '';
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();
};

