/* [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','6401',jdecode('Home'),jdecode(''), jdecode('%2F6401.html'), 'true',[],'',''],
	['PAGE','6452',jdecode('Contact+and+Weblog'),jdecode(''), jdecode('%2F6452.html'), 'true',[],'',''],
	['PAGE','6473',jdecode('About+us'),jdecode(''), jdecode('%2F6473%2Findex.html'), 'true',[ 
		['PAGE','9601',jdecode('Our+Policies+'),jdecode(''), jdecode('%2F6473%2F9601.html'), 'true',[],'','']
	],'',''],
	['PAGE','6494',jdecode('Expedition+Calendar'),jdecode(''), jdecode('%2F6494%2Findex.html'), 'true',[ 
		['PAGE','10901',jdecode('Expedition+Details'),jdecode(''), jdecode('%2F6494%2F10901.html'), 'true',[],'','']
	],'',''],
	['PAGE','6557',jdecode('Speaking+Engagements'),jdecode(''), jdecode('%2F6557.html'), 'true',[],'',''],
	['PAGE','6536',jdecode('Links'),jdecode(''), jdecode('%2F6536.html'), 'true',[],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='Palette';
theSitetree.paletteFamily='CC0000';
theSitetree.keyvisualId='9354';
theSitetree.keyvisualName='kv_9354.jpg';
theSitetree.fontsetId='17396';
theSitetree.graphicsetId='12795';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'fatcow',
  product: 'WSCSYSSSSLY0XRNC'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Palette',
				paletteFamily: 	'CC0000',
				keyvisualId: 	'9354',
				keyvisualName: 	'kv_9354.jpg',
				fontsetId: 		'17396',
				graphicsetId: 	'12795',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				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['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6401',
internalId:  '',
customField: '20111027-132809'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6452',
internalId:  '',
customField: '20091215-160140'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6494',
internalId:  '',
customField: '20110101-184829'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6557',
internalId:  '',
customField: '20101124-144520'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6536',
internalId:  '',
customField: '20100309-173248'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6473',
internalId:  '',
customField: '20100309-175004'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10901',
internalId:  '',
customField: '20091230-123356'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '6401',
internalId:  '1006',
customField: '1006'
};
webappMappings['7008']=webappMappings['7008-23746']={
webappId:    '7008',
documentId:  '6452',
internalId:  '23746',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-23747']={
webappId:    '7008',
documentId:  '6401',
internalId:  '23747',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-23748']={
webappId:    '7008',
documentId:  '6494',
internalId:  '23748',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9601',
internalId:  '',
customField: '20091212-172338'
};
webappMappings['7008']=webappMappings['7008-23815']={
webappId:    '7008',
documentId:  '10901',
internalId:  '23815',
customField: 'language:en;country:US;'
};
var webAppHostname = 'cgiwsc.enhancedsitebuilder.com:80';
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0INVUHO';
var companyName   = 'WildPERU+-custom+jungle+adventure-';
var htmlTitle	  = 'WildPeru+Custom+Jungle+Adventure';
var metaKeywords  = 'Peru%2C+eco-tourism%2C+tour%2C+travel%2C+South+America%2C+Tropical+fish%2C+catfish%2C+killifish%2C+photography%2C+birding%2C+herpetology%2C+frogs%2C+snakes%2C+wildlife%2C+conservation%2C+adventure%2C+outdoors%2C+camping%2C+jungle%2C+selva%2C+Madre+de+dios%2C+endangered+species%2C+Puerto+Maldonado%2C+Expedition%2C+outfitting%2C+guide+Export%2C+collecting%2C+research%2C+Amazon%2C+Dart+frog%2C+tapir%2C+turtle%2C+jaguar%2C+Wildperu%2C+cloud+forest%2C+Orchids%2C+Botany%2C+bromeliad%2C+river%2C+catfish%2C+flyfishing%2C+insects%2C+spiders%2C+nature%2C+natural%2C+butterflies%2C+hummingbirds%2C+biodiverity%2C+biodiversidad%2C+hikong%2C+camping%2C+tropics';
var metaContents  = 'We+are+based+in+Puerto+Maldonado%2C+Peru+offering+expedition+outfitting%2C+guide+and+export+services+to+tropical+fish+enthusiasts%2C+researchers%2C+journalists+and+academics+worldwide.';
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();
};

