/* [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','601',jdecode('Home'),jdecode(''),'/601.html','true',[],'',''],
	['PAGE','652',jdecode('About+Kingscastle'),jdecode(''),'/652/index.html','true',[ 
		['PAGE','673',jdecode('The+King+Family'),jdecode(''),'/652/673.html','true',[],'','']
	],'',''],
	['PAGE','757',jdecode('HORSES+FORSALE'),jdecode(''),'/757.html','true',[],'',''],
	['PAGE','694',jdecode('STALLIONS'),jdecode(''),'/694.html','true',[],'',''],
	['PAGE','715',jdecode('MARES'),jdecode(''),'/715.html','true',[],'',''],
	['PAGE','49483',jdecode('FOALS'),jdecode(''),'/49483/index.html','true',[ 
		['PAGE','60523',jdecode('FOALS+2010'),jdecode(''),'/49483/60523.html','true',[],'',''],
		['PAGE','49931',jdecode('FOALS+2009'),jdecode(''),'/49483/49931.html','true',[],'',''],
		['PAGE','46101',jdecode('FOALS+2008'),jdecode(''),'/49483/46101.html','true',[],'',''],
		['PAGE','12964',jdecode('FOALS+2007'),jdecode(''),'/49483/12964.html','true',[],'',''],
		['PAGE','12943',jdecode('FOALS+2006'),jdecode(''),'/49483/12943.html','true',[],'',''],
		['PAGE','12922',jdecode('FOALS+2005'),jdecode(''),'/49483/12922.html','true',[],'',''],
		['PAGE','12901',jdecode('FOALS+2004'),jdecode(''),'/49483/12901.html','true',[],'',''],
		['PAGE','736',jdecode('FOALS+2003'),jdecode(''),'/49483/736.html','true',[],'','']
	],'',''],
	['PAGE','778',jdecode('Mini+Australian+Shepherd'),jdecode(''),'/778.html','true',[],'',''],
	['PAGE','799',jdecode('PUPPIES'),jdecode(''),'/799.html','true',[],'',''],
	['PAGE','988',jdecode('FRIEND+HORSES+4SALE'),jdecode(''),'/988.html','true',[],'',''],
	['PAGE','820',jdecode('BARN+BUDDIES'),jdecode(''),'/820.html','true',[],'',''],
	['PAGE','17601',jdecode('Trainers'),jdecode(''),'/17601.html','true',[],'',''],
	['PAGE','17622',jdecode('Antiques+%26+Collectables'),jdecode(''),'/17622.html','true',[],'',''],
	['PAGE','883',jdecode('Blacksmith%26%23x27%3Bs+Nail'),jdecode(''),'/883/index.html','true',[ 
		['PAGE','862',jdecode('Horse+Tack'),jdecode(''),'/883/862.html','true',[],'','']
	],'',''],
	['PAGE','904',jdecode('TREES'),jdecode(''),'/904.html','true',[],'',''],
	['PAGE','925',jdecode('VINEYARD'),jdecode(''),'/925/index.html','true',[ 
		['PAGE','946',jdecode('Vineyard+Supplies'),jdecode(''),'/925/946.html','true',[],'',''],
		['PAGE','967',jdecode('Vines+forsale'),jdecode(''),'/925/967.html','true',[],'','']
	],'',''],
	['PAGE','1030',jdecode('Tips+Tricks+%26+Rib+Ticklers'),jdecode(''),'/1030.html','true',[],'',''],
	['PAGE','49537',jdecode('POETRY'),jdecode(''),'/49537.html','true',[],'',''],
	['PAGE','1051',jdecode('Interesting+links'),jdecode(''),'/1051.html','true',[],'',''],
	['PAGE','1072',jdecode('Contact'),jdecode(''),'/1072/index.html','true',[ 
		['PAGE','1093',jdecode('Address'),jdecode(''),'/1072/1093.html','true',[],'',''],
		['PAGE','1114',jdecode('How+to+find+us'),jdecode(''),'/1072/1114.html','true',[],'','']
	],'','']];
var siteelementCount=33;
theSitetree.topTemplateName='Medium';
theSitetree.paletteFamily='000000';
theSitetree.keyvisualId='2155';
theSitetree.keyvisualName='blanko.jpg';
theSitetree.fontsetId='357';
theSitetree.graphicsetId='408';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='000000';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Medium',
				paletteFamily: 	'000000',
				keyvisualId: 	'2155',
				keyvisualName: 	'blanko.jpg',
				fontsetId: 		'357',
				graphicsetId: 	'408',
				contentColor: 	'FFFFFF',
				contentBGColor: '000000',
				a_color: 		'000000',
				b_color: 		'8EBFC6',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '601',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '601',
internalId:  '',
customField: '20100518-141622'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '799',
internalId:  '',
customField: '20100515-232628'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '757',
internalId:  '',
customField: '20100809-143652'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '652',
internalId:  '',
customField: '20090217-221054'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '673',
internalId:  '',
customField: '20090217-221235'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '694',
internalId:  '',
customField: '20100420-142250'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '715',
internalId:  '',
customField: '20100420-142716'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12964',
internalId:  '',
customField: '20090511-230821'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46101',
internalId:  '',
customField: '20090619-151106'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '988',
internalId:  '',
customField: '20091118-231224'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '820',
internalId:  '',
customField: '20081210-002619'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17601',
internalId:  '',
customField: '20080811-184813'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '778',
internalId:  '',
customField: '20100407-154706'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17622',
internalId:  '',
customField: '20090217-225221'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '60523',
internalId:  '',
customField: '20100515-235828'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '862',
internalId:  '',
customField: '20070824-192502'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1030',
internalId:  '',
customField: '20091102-150452'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1051',
internalId:  '',
customField: '20070928-002731'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1072',
internalId:  '',
customField: '20081210-003518'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1093',
internalId:  '',
customField: '20071118-015534'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1114',
internalId:  '',
customField: '20070926-013007'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '736',
internalId:  '',
customField: '20080606-171157'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12901',
internalId:  '',
customField: '20090217-222459'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12922',
internalId:  '',
customField: '20080128-015022'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12943',
internalId:  '',
customField: '20090511-100105'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '883',
internalId:  '',
customField: '20091102-001143'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '904',
internalId:  '',
customField: '20071022-004048'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '925',
internalId:  '',
customField: '20070928-002529'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '946',
internalId:  '',
customField: '20070824-192502'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '967',
internalId:  '',
customField: '20070824-192502'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '49483',
internalId:  '',
customField: '20100515-232728'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '49537',
internalId:  '',
customField: '20091104-004932'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '49931',
internalId:  '',
customField: '20090619-150840'
};
var canonHostname = 'wsc-worker02.chi.us.siteprotect.com';
var accountId     = 'AHW050INX2XE';
var companyName   = 'KINGSCASTLE+RANCH+%26+VINEYARD';
var htmlTitle	  = 'KINGSCASTLE+RANCH++VINEYARD';
var metaKeywords  = 'kingscastleranch.com+Kingscastle+Ranch++Vineyard+Kingscastle+Smokin+Belle+Starr+Smokes+Bell+Mister+Dual+Pep+Mr+Dual+Smoke+Sanduskie+Blue+Lenas+Lucky+Star+Shiloh+Dream+Dancer+Kings+Sweet+Approval++Royal+Chrome+Doll+Cita+Savanna+Dollys+Rose+Vineyard+Miniture+Australian+Shepherds+Horses+Forsale+AQHA+APHA+Barn+Sale+Windmills+foals+Equine+Twins+Northern+California+Fall+River+Valley+McArthur+Mt.+Shasta+Mt.+Lassen+King+family+horses+homemade+treasures+blacksmith+quality+livestock+agriculture+vinaculture+grape+vines+tack+trees+cowboy+cookie+dough+ricochet+mini+aussies+blacksmith+puppies+puppy';
var metaContents  = '';
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();
};
