/* [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','4701',jdecode('Home'),jdecode(''),'/4701.html','true',[],''],
	['PAGE','30001',jdecode('About+us'),jdecode(''),'/30001.html','true',[],''],
	['PAGE','30022',jdecode('Residential+'),jdecode(''),'/30022.html','true',[],''],
	['PAGE','30043',jdecode('Commercial'),jdecode(''),'/30043.html','true',[],''],
	['PAGE','28101',jdecode('Microfit+program'),jdecode(''),'/28101.html','true',[],''],
	['PAGE','4752',jdecode('Solar+power'),jdecode(''),'/4752.html','true',[],''],
	['PAGE','18801',jdecode('Microhydro+'),jdecode(''),'/18801.html','true',[],''],
	['PAGE','11301',jdecode('Projects'),jdecode(''),'/11301.html','true',[],''],
	['PAGE','9501',jdecode('Estimates'),jdecode(''),'/9501.html','true',[],''],
	['PAGE','9522',jdecode('Contact+us'),jdecode(''),'/9522.html','true',[],'']];
var siteelementCount=10;
theSitetree.topTemplateName='Mosaic';
theSitetree.paletteFamily='9EB9E9';
theSitetree.keyvisualId='2723';
theSitetree.keyvisualName='blanko.jpg';
theSitetree.fontsetId='10362';
theSitetree.graphicsetId='10517';
theSitetree.contentColor='234773';
theSitetree.contentBGColor='9EB9E9';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Mosaic',
				paletteFamily: 	'9EB9E9',
				keyvisualId: 	'2723',
				keyvisualName: 	'blanko.jpg',
				fontsetId: 		'10362',
				graphicsetId: 	'10517',
				contentColor: 	'234773',
				contentBGColor: '9EB9E9',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'D85161',
				e_color: 		'DAE4F0',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4701',
internalId:  '',
customField: '20100330-071330'
};
webappMappings['7008']=webappMappings['7008-436']={
webappId:    '7008',
documentId:  '9501',
internalId:  '436',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9522',
internalId:  '',
customField: '20090224-013155'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4752',
internalId:  '',
customField: '20090223-230640'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9501',
internalId:  '',
customField: '20090224-015257'
};
webappMappings['7060']=webappMappings['7060-67a5b94e180cad844e5a4160bd6132a7']={
webappId:    '7060',
documentId:  '11301',
internalId:  '67a5b94e180cad844e5a4160bd6132a7',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11301',
internalId:  '',
customField: '20091023-225451'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18801',
internalId:  '',
customField: '20100401-090413'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '28101',
internalId:  '',
customField: '20100407-055819'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30001',
internalId:  '',
customField: '20100422-080948'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30022',
internalId:  '',
customField: '20100422-080948'
};
var canonHostname = 'localhost';
var accountId     = 'ANFI10INX39B';
var companyName   = 'Positive+Electric';
var htmlTitle	  = 'positive+electric+';
var metaKeywords  = 'Electrical+Contractors%2C+serving+Central+Ontario%2C+cottage+country%2C++solar+panel+%2C+installation%2C++toronto%2C+muskoka%2C+electric%2C+wiring%2C+rewiring%2C+service%2C+upgrade%2C++panel+change%2C+knob+and+tube%2C+cannington%2C+electrician%2C+microhydro%2C+water+turbines%2C';
var metaContents  = 'Electrical+Contractors+serving+Central+Ontario+and+GTA';
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();
};
