/* [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','201',jdecode('Home'),jdecode(''), jdecode('%2F201.html'), 'true',[],'',''],
	['PAGE','207',jdecode('Why+Suri+Alpacas'),jdecode(''), jdecode('%2F207.html'), 'true',[],'',''],
	['PAGE','212',jdecode('Alpacas+Facts%2FLinks'),jdecode(''), jdecode('%2F212.html'), 'true',[],'','']];
var siteelementCount=3;
theSitetree.topTemplateName='Inspiration';
theSitetree.paletteFamily='819B9B';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='100';
theSitetree.graphicsetId='126';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='819B9B';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'enom',
  product: 'WSCENOSSSLYTC21A'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Inspiration',
				paletteFamily: 	'819B9B',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'100',
				graphicsetId: 	'126',
				contentColor: 	'FFFFFF',
				contentBGColor: '819B9B',
				a_color: 		'819B9B',
				b_color: 		'C8C899',
				c_color: 		'000000',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '201',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '201',
internalId:  '',
customField: '20111010-153530'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '207',
internalId:  '',
customField: '20110104-071634'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '212',
internalId:  '',
customField: '20111007-032654'
};
var webAppHostname = 'wsc.ehost-services.com:80';
var canonHostname = 'wscwrk01.ehost-services.com';
var accountId     = 'AEN010INXFFA';
var companyName   = 'Alpacas+of+Club+Suri';
var htmlTitle	  = 'Club+Suri+Alpacas+offers+the+finest+full+Peruvian+and+Accoyo+Alpacas+For+Sale%2C+Ohio+Alpacas+For+Sale%2C+Alpaca+Sales%2C+Cria+For+Sale%2C+Accoyo+Suri+Alpaca+For+Sale+and+more.';
var metaKeywords  = 'Ohio%2C+OH%2C+alpaca%2C+alpacas%2C+alpaca+for+sale%2C+alpacas+for+sale%2C+alpaca+sales%2C+cria%2C+cria+for+sale%2C+cria+sales%2C+Ohio+alpaca%2C+Ohio+alpacas%2C+Ohio+alpaca+for+sale%2C+Ohio+alpacas+for+sale%2C+Ohio+alpaca+sales%2C+Ohio+cria%2C+Ohio+cria+for+sale%2C+Ohio+cria+sales%2C+OH+alpaca%2C+OH+alpacas%2C+OH+alpaca+for+sale%2C+OH+alpacas+for+sale%2C+OH+alpaca+sales%2C+OH+cria%2C+OH+cria+for+sale%2C+OH+cria+sales%2C+accoyo+alpaca%2C+suri+alpaca%2C+accoyo+alpaca+for+sale%2C+suri+alpaca+for+sale%2C+accoyo+suri+alpaca+for+sale%2C+alpaca+fiber%2C+i+love+alpacas%2C+alpaca+yarn+META+NAME%3Drobots+content%3Dindex%2Cfollow++META+NAME+%3DGOOGLEBOT+content%3Dindex%2Cfollow+++META+NAME%3Drevisit-after+CONTENT%3D14+days++';
var metaContents  = 'Club+Suri+Alpacas+offers+Alpacas%2C+Alpacas+For+Sale%2C+Ohio+Alpacas+for+Sale%2C+Cria+Alpacas%2C+Suri+Alpacas%2C+Accoyo+Alpacas%2C+Alpaca+Breeding%2C+Alpaca+Yarn%2C+Alpaca+Fiber%2C+Suri+Alpaca+Breeding+and+more';
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();
};

