/* [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','301',jdecode('Home'),jdecode(''),'/301.html','true',[],''],
	['PAGE','34901',jdecode('About+us'),jdecode(''),'/34901.html','true',[],''],
	['PAGE','352',jdecode('MDC+Construction%2C+Inc.'),jdecode(''),'/352.html','true',[],''],
	['PAGE','457',jdecode('MDC+Millworks%2C+Inc.'),jdecode(''),'/457.html','true',[],''],
	['PAGE','40701',jdecode('Testimonials'),jdecode(''),'/40701.html','true',[],''],
	['PAGE','55201',jdecode('Location'),jdecode(''),'/55201.html','true',[],''],
	['PAGE','478',jdecode('Contact+Us'),jdecode(''),'/478.html','true',[],''],
	['PAGE','59001',jdecode('Awards'),jdecode(''),'/59001.html','true',[],'']];
var siteelementCount=8;
theSitetree.topTemplateName='Delphi';
theSitetree.paletteFamily='434343';
theSitetree.keyvisualId='7542';
theSitetree.keyvisualName='kv_7542.jpg';
theSitetree.fontsetId='16657';
theSitetree.graphicsetId='12227';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='818181';
var theTemplate={
				name: 			'Delphi',
				paletteFamily: 	'434343',
				keyvisualId: 	'7542',
				keyvisualName: 	'kv_7542.jpg',
				fontsetId: 		'16657',
				graphicsetId: 	'12227',
				contentColor: 	'FFFFFF',
				contentBGColor: '818181',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'424242',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '301',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '301',
internalId:  '',
customField: '20090105-111629'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '352',
internalId:  '',
customField: '20090105-112141'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '457',
internalId:  '',
customField: '20090105-112213'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40701',
internalId:  '',
customField: '20081119-165601'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '478',
internalId:  '',
customField: '20090105-112326'
};
webappMappings['7008']=webappMappings['7008-10807']={
webappId:    '7008',
documentId:  '478',
internalId:  '10807',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34901',
internalId:  '',
customField: '20090105-112101'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '55201',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '55201',
internalId:  '',
customField: '20081121-154954'
};
var canonHostname = 'cmworker01.yourhostingaccount.com';
var accountId     = 'AENDU0IN29YN';
var companyName   = 'MITCHELL+DEAN+COLLINS+CONSTRUCTION';
var htmlTitle	  = 'MDC+Construction+%26+MDC+Millwork';
var metaKeywords  = 'Custom+Cabinets%2C+Custom+Decks%2C+New+Homes%2C+Remodles%2C+Millwork%2C+Construction%2C+custom+millwork%2C+all+your+construction+needs%2C+commercial+construction%2C+residential+construction';
var metaContents  = 'Custom+Cabinets%2C+Custom+Decks%2C+New+Homes%2C+Remodles%2C+Millwork%2C+Construction%2C+custom+millwork%2C+all+your+construction+needs%2C+commercial+construction%2C+residential+construction';
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();
};
