/* [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','601',jdecode('Home'),jdecode(''),'/601.html','true',[],'',''],
	['PAGE','5701',jdecode('Services'),jdecode(''),'/5701/index.html','true',[ 
		['PAGE','5722',jdecode('Pattern+Equipment'),jdecode(''),'/5701/5722.html','true',[],'',''],
		['PAGE','5764',jdecode('Machine+Shop'),jdecode(''),'/5701/5764.html','true',[],'',''],
		['PAGE','24201',jdecode('Rapid+Prototyping'),jdecode(''),'/5701/24201.html','true',[],'','']
	],'',''],
	['PAGE','5785',jdecode('Products'),jdecode(''),'/5785/index.html','true',[ 
		['PAGE','6301',jdecode('CoreBox+Clamps'),jdecode(''),'/5785/6301.html','true',[],'','']
	],'',''],
	['PAGE','38101',jdecode('Projects'),jdecode(''),'/38101/index.html','true',[ 
		['PAGE','38122',jdecode('Accurate+Sight+Models'),jdecode(''),'/38101/38122.html','true',[],'',''],
		['PAGE','38143',jdecode('Functional+Parts'),jdecode(''),'/38101/38143.html','true',[],'',''],
		['PAGE','38164',jdecode('Cast+Urethane+Parts'),jdecode(''),'/38101/38164.html','true',[],'',''],
		['PAGE','38185',jdecode('Direct+Casting+in+Zinc%2C+Aluminum%2C+Tin'),jdecode(''),'/38101/38185.html','true',[],'',''],
		['PAGE','38206',jdecode('Pattern+Equipment'),jdecode(''),'/38101/38206.html','true',[],'',''],
		['PAGE','38227',jdecode('CAD+Design+Services'),jdecode(''),'/38101/38227.html','true',[],'','']
	],'',''],
	['PAGE','5869',jdecode('About+us'),jdecode(''),'/5869/index.html','true',[ 
		['PAGE','30501',jdecode('Protoype+Brochure'),jdecode(''),'/5869/30501.html','true',[],'','']
	],'',''],
	['PAGE','10601',jdecode('News'),jdecode(''),'/10601.html','true',[],'',''],
	['PAGE','10622',jdecode('Employment'),jdecode(''),'/10622.html','true',[],'',''],
	['PAGE','5890',jdecode('Contact'),jdecode(''),'/5890.html','true',[],'',''],
	['PAGE','27701',jdecode('Map'),jdecode(''),'/27701.html','true',[],'','']];
var siteelementCount=20;
theSitetree.topTemplateName='Business';
theSitetree.paletteFamily='003366';
theSitetree.keyvisualId='2492';
theSitetree.keyvisualName='blanko.jpg';
theSitetree.fontsetId='420';
theSitetree.graphicsetId='463';
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: 			'Business',
				paletteFamily: 	'003366',
				keyvisualId: 	'2492',
				keyvisualName: 	'blanko.jpg',
				fontsetId: 		'420',
				graphicsetId: 	'463',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'003366',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '27701',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:false;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '601',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-9703']={
webappId:    '1501',
documentId:  '601',
internalId:  '9703',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '601',
internalId:  '',
customField: '20080923-155618'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5701',
internalId:  '',
customField: '20080924-102706'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5722',
internalId:  '',
customField: '20080924-102731'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5764',
internalId:  '',
customField: '20080924-103215'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '24201',
internalId:  '',
customField: '20080925-114317'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5785',
internalId:  '',
customField: '20080924-104050'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6301',
internalId:  '',
customField: '20080925-111738'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38101',
internalId:  '',
customField: '20080925-121135'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38122',
internalId:  '',
customField: '20080925-112227'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38143',
internalId:  '',
customField: '20080925-112345'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38164',
internalId:  '',
customField: '20080807-155427'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38185',
internalId:  '',
customField: '20080925-112424'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38206',
internalId:  '',
customField: '20080606-170004'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38227',
internalId:  '',
customField: '20080718-130243'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5869',
internalId:  '',
customField: '20080923-162618'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30501',
internalId:  '',
customField: '20080925-114407'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10601',
internalId:  '',
customField: '20071019-152124'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10622',
internalId:  '',
customField: '20100324-140638'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5890',
internalId:  '',
customField: '20080925-112806'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27701',
internalId:  '',
customField: '20071024-165130'
};
var canonHostname = 'wsc-worker02.chi.us.siteprotect.com';
var accountId     = 'AHW050INXSIT';
var companyName   = 'PEERLESS+PATTERN+WORKS%2C+INC.';
var htmlTitle	  = 'Peerless+Pattern+Works';
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();
};

