/* [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','1839',jdecode('Home'),jdecode(''), jdecode('%2F1839.html'), 'true',[],'',''],
	['PAGE','1890',jdecode('Contact'),jdecode(''), jdecode('%2F1890.html'), 'true',[],'',''],
	['PAGE','3139',jdecode('About+us'),jdecode(''), jdecode('%2F3139.html'), 'true',[],'',''],
	['PAGE','1911',jdecode('Service+%26+Parts'),jdecode(''), jdecode('%2F1911.html'), 'true',[],'',''],
	['PAGE','1932',jdecode('Installed+Beds'),jdecode(''), jdecode('%2F1932.html'), 'true',[],'',''],
	['PAGE','1953',jdecode('Freedom+Truck+Beds'),jdecode(''), jdecode('%2F1953.html'), 'true',[],'',''],
	['PAGE','1974',jdecode('CM+Truck+Beds'),jdecode(''), jdecode('%2F1974.html'), 'true',[],'',''],
	['PAGE','1995',jdecode('Rice+Trailers'),jdecode(''), jdecode('%2F1995.html'), 'true',[],'',''],
	['PAGE','13050',jdecode('RedMax'),jdecode(''), jdecode('%2F13050.html'), 'true',[],'',''],
	['PAGE','17050',jdecode('Truck+Accessories'),jdecode(''), jdecode('%2F17050.html'), 'true',[],'',''],
	['PAGE','20750',jdecode('Snow+Plows%2C+Parts+%26+Acc.'),jdecode(''), jdecode('%2F20750.html'), 'true',[],'','']];
var siteelementCount=11;
theSitetree.topTemplateName='Riga';
theSitetree.paletteFamily='66A251';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='11223';
theSitetree.graphicsetId='12044';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='66A251';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'wl_enom',
  product: 'WSCENOSSSLYTC21T'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Riga',
				paletteFamily: 	'66A251',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'11223',
				graphicsetId: 	'12044',
				contentColor: 	'FFFFFF',
				contentBGColor: '66A251',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['7060']=webappMappings['7060-70c0481a8be5ef1f1a4646fe5bfdf763']={
webappId:    '7060',
documentId:  '1953',
internalId:  '70c0481a8be5ef1f1a4646fe5bfdf763',
customField: 'language:en;country:US;'
};
webappMappings['7060']=webappMappings['7060-dcda7d2b3a12b30c9b22d566ed239c85']={
webappId:    '7060',
documentId:  '1974',
internalId:  'dcda7d2b3a12b30c9b22d566ed239c85',
customField: 'language:en;country:US;'
};
webappMappings['7060']=webappMappings['7060-538f169883f7bf9da5acb72febe5df42']={
webappId:    '7060',
documentId:  '1995',
internalId:  '538f169883f7bf9da5acb72febe5df42',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1839',
internalId:  '',
customField: '20111006-084510'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1890',
internalId:  '',
customField: '20111006-084756'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1911',
internalId:  '',
customField: '20111006-085401'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1953',
internalId:  '',
customField: '20110930-122348'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1839',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1932',
internalId:  '',
customField: '20110930-112618'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1974',
internalId:  '',
customField: '20111006-121117'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1995',
internalId:  '',
customField: '20111006-121002'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3139',
internalId:  '',
customField: '20111006-123606'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13050',
internalId:  '',
customField: '20111006-121033'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17050',
internalId:  '',
customField: '20111006-123000'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20750',
internalId:  '',
customField: '20111208-120157'
};
var webAppHostname = 'wsc.ehost-services.com:80';
var canonHostname = 'wscwrk01.ehost-services.com';
var accountId     = 'AEN340INP8CX';
var companyName   = 'TRAILERS+GALORE+%26+OUTDOOR+POWER';
var htmlTitle	  = 'Trailers+Galore+%26+Outdoor+Power';
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();
};

