/* [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','8901',jdecode('We+Are+Grammie+Sage'),jdecode(''),'/8901/index.html','true',[ 
		['PAGE','9301',jdecode('Debra%26%23x27%3Bs+Duties'),jdecode(''),'/8901/9301.html','true',[],'',''],
		['PAGE','9601',jdecode('Warron%26%23x27%3Bs+Wisdom'),jdecode(''),'/8901/9601.html','true',[],'','']
	],'',''],
	['PAGE','100301',jdecode('Market+Dayz'),jdecode(''),'/100301.html','true',[],'',''],
	['PAGE','91101',jdecode('Grammie+Sage+Store'),jdecode(''),'/91101/index.html','true',[ 
		['PAGE','103101',jdecode('Natural+Health'),jdecode(''),'/91101/103101.html','true',[],'',''],
		['PAGE','9501',jdecode('Our+Jewelry+%26+Supplies'),jdecode(''),'/91101/9501.html','true',[],'','']
	],'',''],
	['PAGE','50101',jdecode('Grammie+Sage%26%23x27%3Bs+Blog+'),jdecode(''),'/50101.html','true',[],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='Workflow';
theSitetree.paletteFamily='B8BADF';
theSitetree.keyvisualId='7837';
theSitetree.keyvisualName='kv_7837.jpg';
theSitetree.fontsetId='16843';
theSitetree.graphicsetId='12288';
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: 			'Workflow',
				paletteFamily: 	'B8BADF',
				keyvisualId: 	'7837',
				keyvisualName: 	'kv_7837.jpg',
				fontsetId: 		'16843',
				graphicsetId: 	'12288',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'8487BF',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'8487BF',
				e_color: 		'979696',
				f_color: 		'707070',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8901',
internalId:  '',
customField: '20100730-145956'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9301',
internalId:  '',
customField: '20100730-150614'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '100301',
internalId:  '',
customField: '20100816-194323'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '91101',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '103101',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '8901',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9601',
internalId:  '',
customField: '20100730-162728'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '100301',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9501',
internalId:  '',
customField: '20100730-171712'
};
webappMappings['1501']=webappMappings['1501-13362358']={
webappId:    '1501',
documentId:  '8901',
internalId:  '13362358',
customField: '1501'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8901',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '9301',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '91101',
internalId:  '',
customField: '20100812-130651'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '9601',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '103101',
internalId:  '',
customField: '20100730-173021'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '9501',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '50101',
internalId:  '',
customField: '20100329-192054'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '50101',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['7050']=webappMappings['7050-15195']={
webappId:    '7050',
documentId:  '50101',
internalId:  '15195',
customField: 'language:en;country:US;'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0IN28MS';
var companyName   = 'Grammie+Sage';
var htmlTitle	  = 'Grammie+Sage+';
var metaKeywords  = 'Grammie+Sage%2C+Herbal+products%2C+Pickled+Vegetables%2C+Jams%2C+Jellies%2C+Marmalades%2C+Mustards%2C+Herbs%2C+Native+American+herbs%2C+Teas%2C+Tea+Blends%2C+Dry+Dips%2C+Spice+Blends%2C+goats%2C+brown+eggs%2C+The+Village%2C+Shawnee%2C+Oklahoma%2C+sweat+lodge%2C+Mysts%2C+Oils%2C+spices%2C+herbs%2C+smudge%2C+sage%2C+7+Lodges%2C+Warron%2C+Debra+%2C+Big+Eagle%2C+eggs%2C+goat+milk+soap%2C+retreats%2C+ear+candle%2C+spiritual+advisor%2C+spiritual+speaker%2C+pastor%2C+weddings%2C++motivational+speaker%2C+jewelry%2C+Native+american%2C+Cheyenne%2C+drums%2C+drumming%2C+medicine+bags%2C+dream+catchers%2C+herbal+pads%2C+eye+pillows%2C+dream+pillows%2C+cooking%2C+classes%2C+native+american+supplies.';
var metaContents  = 'Grammie+Sage%3B+bringing+back+the+old+ways+at+Harmony+Farm++The+Village.';
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();
};
