/* [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','501',jdecode('Home'),jdecode(''),'/501.html','true',[],'',''],
	['PAGE','18827',jdecode('Auctions'),jdecode(''),'/18827.html','true',[],'',''],
	['PAGE','573',jdecode('Commemoratives'),jdecode(''),'/573.html','true',[],'',''],
	['PAGE','594',jdecode('Guns+For+Sale'),jdecode(''),'/594/index.html','true',[ 
		['PAGE','615',jdecode('Shotguns'),jdecode(''),'/594/615.html','true',[],'',''],
		['PAGE','636',jdecode('Rifles'),jdecode(''),'/594/636.html','true',[],'',''],
		['PAGE','657',jdecode('Pistols'),jdecode(''),'/594/657.html','true',[],'','']
	],'',''],
	['PAGE','678',jdecode('Knives+and+Accessories'),jdecode(''),'/678.html','true',[],'',''],
	['PAGE','2601',jdecode('Contact+Us'),jdecode(''),'/2601.html','true',[],'',''],
	['PAGE','699',jdecode('Links+and+Resources'),jdecode(''),'/699.html','true',[],'',''],
	['PAGE','39401',jdecode('Test'),jdecode(''),'/39401.html','false',[],'',''],
	['PAGE','40201',jdecode('Rifles'),jdecode(''),'/40201.html','false',[],'','']];
var siteelementCount=12;
theSitetree.topTemplateName='Card';
theSitetree.paletteFamily='990000';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='430';
theSitetree.graphicsetId='479';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Card',
				paletteFamily: 	'990000',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'430',
				graphicsetId: 	'479',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'FFFFFF',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20100611-021420'
};
webappMappings['7060']=webappMappings['7060-625681e82c4389f9b011599a051672a4']={
webappId:    '7060',
documentId:  '39401',
internalId:  '625681e82c4389f9b011599a051672a4',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '573',
internalId:  '',
customField: '20100415-100535'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '594',
internalId:  '',
customField: '20100522-151243'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '615',
internalId:  '',
customField: '20100605-171504'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '636',
internalId:  '',
customField: '20100605-165931'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '657',
internalId:  '',
customField: '20100522-150323'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '678',
internalId:  '',
customField: '20090620-142928'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2601',
internalId:  '',
customField: '20100106-142055'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '699',
internalId:  '',
customField: '20091203-183858'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18827',
internalId:  '',
customField: '20090724-194722'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39401',
internalId:  '',
customField: '20091202-234653'
};
webappMappings['7060']=webappMappings['7060-df34098c6d7eae670992d99c659c48a7']={
webappId:    '7060',
documentId:  '40201',
internalId:  'df34098c6d7eae670992d99c659c48a7',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40201',
internalId:  '',
customField: '20090730-201518'
};
var canonHostname = 'wsc-worker01.chi.us.siteprotect.com';
var accountId     = 'AHW050INXXIL';
var companyName   = 'Elite+Firearms+Unltd.';
var htmlTitle	  = 'Reloading+Supplies+CA+Remington+Rifle+Colt+Firearms+Marlin+Rifle+Ruger+Pistol+Remington+Shotguns';
var metaKeywords  = 'Elite+Firearms+Unltd.%2C+Elite+Firearms+Unlimited%2C+New+Guns%2C+Used+Guns%2C+Antique+Guns%2C+Gun+Accessories%2C+Black+Powder+Supplies%2C+Curio%2C+Relics%2C+Shooting+Supplies%2C+Reloading+Supplies%2C+Gun+Shop%2C+Gun+Store%2C+Laguna+Niguel+CA%2C+Orange+County+Gun+Shop%2C+OC+Gun+Shop%2C+OC+Gun+Store%2C+Orange+County+Gun+Store%2C+Browning%2C+Steyer%2C+Parker%2C+Remington%2C+Winchester%2C+Ruger%2C+Schultzlarsen%2C+Charles+Daly%2C+Piotti%2C+Westley+Richards%2C+Merkel%2C+Savage%2C+Kreigoff%2C+LC+Smith%2C+Sako%2C+Marlin%2C+Mountain+Rifle%2C+Ithaca%2C+Jp+Sauer%2C+Kerner%2C+Sw%2C+Hk%2C+Colt%2C+Beretta%2C+Collectible+Firearms+And+High+Grade+Guns%2C+Sell%2C+Buy%2C+and+Consign+Guns%2C+Gun+Related+Equipment%2C+Complete+Gun+Collections';
var metaContents  = 'Contact+Elite+Firearms+Unlimited+for+Reloading+Supplies+CA%2C+Remington+Rifle%2C+Colt+Firearms%2C+Marlin+Rifle%2C+Ruger+Pistol%2C+Remington+Shotguns';
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();
};
