/* [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','5101',jdecode('HOME'),jdecode(''),'/5101.html','true',[],''],
	['PAGE','5301',jdecode('PRODUCTS'),jdecode(''),'/5301.html','true',[],''],
	['PAGE','5322',jdecode('SERVICE'),jdecode(''),'/5322.html','true',[],''],
	['PAGE','5343',jdecode('CONTACT+US+TODAY'),jdecode(''),'/5343.html','true',[],''],
	['PAGE','5152',jdecode('ON+LINE+STORE+%28buy+now%29'),jdecode(''),'/5152.html','true',[],''],
	['PAGE','5364',jdecode('EMPLOYMENT'),jdecode(''),'/5364.html','true',[],''],
	['PAGE','5385',jdecode('MEET+OUR+TEAM'),jdecode(''),'/5385.html','true',[],''],
	['PAGE','7201',jdecode('BUY+SELL+TRADE'),jdecode(''),'/7201.html','true',[],''],
	['PAGE','5406',jdecode('OTHER+LINKS'),jdecode(''),'/5406.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Metal';
theSitetree.paletteFamily='8D8C67';
theSitetree.keyvisualId='724';
theSitetree.keyvisualName='labtop.jpg';
theSitetree.fontsetId='145';
theSitetree.graphicsetId='153';
theSitetree.contentColor='DDDDDD';
theSitetree.contentBGColor='000000';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Metal',
				paletteFamily: 	'8D8C67',
				keyvisualId: 	'724',
				keyvisualName: 	'labtop.jpg',
				fontsetId: 		'145',
				graphicsetId: 	'153',
				contentColor: 	'DDDDDD',
				contentBGColor: '000000',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'8D8C67',
				b_color: 		'E4E2A7',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5101',
internalId:  '',
customField: '20100126-124058'
};
webappMappings['7008']=webappMappings['7008-22648']={
webappId:    '7008',
documentId:  '5343',
internalId:  '22648',
customField: 'language:en;country:US;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '5101',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5406',
internalId:  '',
customField: '20100125-125105'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5301',
internalId:  '',
customField: '20100125-124939'
};
webappMappings['1501']=webappMappings['1501-24095906']={
webappId:    '1501',
documentId:  '5101',
internalId:  '24095906',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5322',
internalId:  '',
customField: '20091121-230837'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5343',
internalId:  '',
customField: '20091120-095158'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5152',
internalId:  '',
customField: '20091123-092932'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5364',
internalId:  '',
customField: '20091209-115220'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5385',
internalId:  '',
customField: '20100413-003145'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7201',
internalId:  '',
customField: '20100414-110028'
};
webappMappings['8002']=webappMappings['8002-search']={
webappId:    '8002',
documentId:  '5152',
internalId:  'search',
customField: 'language:en;country:US;'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0INVO72';
var companyName   = 'BENNETT%27S+COMMUNICATIONS';
var htmlTitle	  = 'Bennetts+Communications-CCTV-Phone+Systems-Wiring-Troubleshooting';
var metaKeywords  = 'Service%2C+Avaya%2C+CCTV%2C+VM%2C+Voice-mail%2C+Valcom%2C+Plantronics%2C+Paging%2C+Wiring%2C+Cabling%2C+Voice%2C+Data%2C+Voice++Data%2C+Bennetts%2C+Pelco%2C+Speco%2C+Cordless+Ph%2C+Commercial%2C+Residential%2C+Industrial%2C+Maintenance+Plans%2C+Dicounts%2C+Cupon%2C+Georgia%2C+Florida%2C+North+Carolina%2C+South+Carolina%2C+GA%2C+FL%2C+NC%2C+SC%2C+ATT%2C+Lucent%2C+Single+Moms+discounts%2C+';
var metaContents  = 'BENNETTS+COMMUNICATIONS+CCTV+Soultions%2C+INC.+We+Service+What+We+Sell++Commerciall+%2F+Industrial+%2F+Residentail';
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();
};
