/* [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','6501',jdecode('Home'),jdecode(''), jdecode('%2F6501.html'), 'true',[],'',''],
	['PAGE','7701',jdecode('Online+Store'),jdecode(''), jdecode('%2F7701.html'), 'true',[],'',''],
	['PAGE','6552',jdecode('About+us'),jdecode(''), jdecode('%2F6552.html'), 'true',[],'',''],
	['PAGE','6573',jdecode('Contact'),jdecode(''), jdecode('%2F6573.html'), 'true',[],'','']];
var siteelementCount=4;
theSitetree.topTemplateName='Crisscross';
theSitetree.paletteFamily='C64732';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='11052';
theSitetree.graphicsetId='11813';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='C64732';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'hps_testtown',
  product: 'WSCSYSSSSLYTCPH7'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Crisscross',
				paletteFamily: 	'C64732',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'11052',
				graphicsetId: 	'11813',
				contentColor: 	'000000',
				contentBGColor: 'C64732',
				a_color: 		'C64732',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6501',
internalId:  '',
customField: '20111103-181445'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6552',
internalId:  '',
customField: '20111103-180917'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7701',
internalId:  '',
customField: '20111103-172220'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6573',
internalId:  '',
customField: '20110720-140639'
};
var webAppHostname = 'cgi-wsc.chi.us.siteprotect.com:80';
var canonHostname = 'wsc-worker01.chi.us.siteprotect.com';
var accountId     = 'AHW050INFNJB';
var companyName   = 'Custom+Saddlery%27s+Tack+Store';
var htmlTitle	  = 'Custom+Saddlery+Tack+Store';
var metaKeywords  = 'English%2C+Dressage%2C+Hunter%2C+Jumper%2C+Leather%2C+Repair%2C+Breeches%2C+Show+Coat%2C+Horse%2C+Fly%2C+Boots%2C+Custom%2C+Rat+Catcher%2C+Pikeur%2C+Cavallo%2C+Goode+Rider%2C+Tailored+Sportsman%2C+Grand+Prix%2C+RJ+Classics%2C+Ariat%2C+Eskadron%2C+Passier%2C+Red+Barn+by+KL+Select%2C+Rambo%2C+PRI%2C+GPA%2C+Troxel%2C+Charles+Owen%2C+Reins%2C+Saddle%2C+Pad%2C+Bit%2C+Bridle%2C+Socks%2C+Shampoo%2C+Hoof%2C+Supplement%2C+supplements%2C+dewormer%2C+hay%2C+bucket%2C+buckets%2C+martingale%2C+breast+collar%2C+girth%2C+spray%2C+tack+store%2C+San+Marcos%2C+draw+reins%2C+cavason%2C+nose+band%2C+top+hat%2C+helmet%2C+show+clothes%2C+tall+boot%2C+tall+boots%2C+%0A%0A';
var metaContents  = 'We+specialize+in+Hunter%2FJumper%2C+Eventing%2C+and+Dressage+goods.+Our+shop+brands+include%3A+Pikeur%2C+Cavallo%2C+Goode+Rider%2C+Tailored+Sportsman%2C+Grand+Prix%2C+RJ+Classics%2C+Ariat%2C+Eskadron%2C+Passier%2C+Red+Barn+by+KL+Select%2C+Rambo%2C+PRI%2C+GPA%2C+Troxel%2C+Charles+Owen%2C+and+many+many+more.+We+have+from+Shampoo+to+Shadbelly%27s%21';
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();
};

