/* [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','1701',jdecode('Electric+Vehicles+Home'),jdecode(''),'/1701.html','true',[],'',''],
	['PAGE','3022',jdecode('Shop-+EV+Components'),jdecode(''),'/3022.html','true',[],'',''],
	['PAGE','3064',jdecode('Marine'),jdecode(''),'/3064.html','true',[],'',''],
	['PAGE','16823',jdecode('Urban+Transport'),jdecode(''),'/16823.html','true',[],'',''],
	['PAGE','36034',jdecode('Environmental'),jdecode(''),'/36034.html','true',[],'',''],
	['PAGE','32934',jdecode('Aviation'),jdecode(''),'/32934.html','true',[],'',''],
	['PAGE','3106',jdecode('About+Us'),jdecode(''),'/3106.html','true',[],'',''],
	['PAGE','3127',jdecode('Contact+Us'),jdecode(''),'/3127.html','true',[],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='View';
theSitetree.paletteFamily='236A8C';
theSitetree.keyvisualId='11132';
theSitetree.keyvisualName='kv_11132.jpg';
theSitetree.fontsetId='32028';
theSitetree.graphicsetId='13853';
theSitetree.contentColor='2F2F2F';
theSitetree.contentBGColor='236A8C';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'View',
				paletteFamily: 	'236A8C',
				keyvisualId: 	'11132',
				keyvisualName: 	'kv_11132.jpg',
				fontsetId: 		'32028',
				graphicsetId: 	'13853',
				contentColor: 	'2F2F2F',
				contentBGColor: '236A8C',
				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:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1701',
internalId:  '',
customField: '20100619-023004'
};
webappMappings['7008']=webappMappings['7008-9442']={
webappId:    '7008',
documentId:  '3127',
internalId:  '9442',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32934',
internalId:  '',
customField: '20100523-054321'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3022',
internalId:  '',
customField: '20100524-024031'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1701',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3064',
internalId:  '',
customField: '20100619-023223'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3106',
internalId:  '',
customField: '20100419-182216'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3127',
internalId:  '',
customField: '20100531-012249'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16823',
internalId:  '',
customField: '20100619-023105'
};
webappMappings['1501']=webappMappings['1501-14619760']={
webappId:    '1501',
documentId:  '1701',
internalId:  '14619760',
customField: '1501'
};
webappMappings['4001']=webappMappings['4001-14975146']={
webappId:    '4001',
documentId:  '3022',
internalId:  '14975146',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36034',
internalId:  '',
customField: '20100804-170909'
};
var canonHostname = 'diywk01.verio.stngva01.us.diy-servers.net';
var accountId     = 'AVFL30INHI59';
var companyName   = 'Earthling+EnVirons+%28EV%29+LTD.';
var htmlTitle	  = 'Electric+Vehicle+Design';
var metaKeywords  = 'EV%2CAgni%2CLifebatt%2Celectric%2Csolar%2CLifepo4%2C+Kiteboat%2C+E-Bike%2C+E-car%2C+E-Boat%2C+battery%2C+controller%2C+power%2C+KW%2C+electric+motorcycle%2C+electric+car%2C+electric+boat%2C+electric+conversion%2C+Electric+cars%2CElectric+motorcycles%2CLithium+ion%2Cwarp%2Ctranswarp%2C+impulse%2Clogisystems%2Calltrax%2CLi+ion%2Cheadway%2Clynch%2Clemco%2Cpermanent+magnet%2Cdc+motor%2C+e-bob%2Clca%2C';
var metaContents  = 'Electric+Vehichle+Design++Components';
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();
};
