/* [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','9501',jdecode('WELCOME'),jdecode(''), jdecode('%2F9501.html'), 'true',[],'',''],
	['PAGE','10001',jdecode('TEACHINGS'),jdecode(''), jdecode('%2F10001.html'), 'true',[],'',''],
	['PAGE','9901',jdecode('CONTACTS'),jdecode(''), jdecode('%2F9901.html'), 'true',[],'','']];
var siteelementCount=3;
theSitetree.topTemplateName='Billy';
theSitetree.paletteFamily='A24E4E';
theSitetree.keyvisualId='7102';
theSitetree.keyvisualName='kv_7102.jpg';
theSitetree.fontsetId='16390';
theSitetree.graphicsetId='12125';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='A24E4E';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'gate',
  product: 'WSCSYSSSSLYTC24M'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Billy',
				paletteFamily: 	'A24E4E',
				keyvisualId: 	'7102',
				keyvisualName: 	'kv_7102.jpg',
				fontsetId: 		'16390',
				graphicsetId: 	'12125',
				contentColor: 	'FFFFFF',
				contentBGColor: 'A24E4E',
				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:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9501',
internalId:  '',
customField: '20120117-141113'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9901',
internalId:  '',
customField: '20090919-153942'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10001',
internalId:  '',
customField: '20111119-124545'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '9501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5003']=webappMappings['5003-tid:1;pid:WSCSYSSSSLYTC24M']={
webappId:    '5003',
documentId:  '9501',
internalId:  'tid:1;pid:WSCSYSSSSLYTC24M',
customField: 'en:US::;language:en;country:US;'
};
var webAppHostname = 'cgi-wsc.chi.us.siteprotect.com:80';
var canonHostname = 'wsc-worker02.chi.us.siteprotect.com';
var accountId     = 'AHW050INVSFK';
var companyName   = '';
var htmlTitle	  = 'Kay+Hill+Ministries';
var metaKeywords  = 'Christian%2C+ordained+minister%2Cteacher%2Ccharasmatic%2Canointed%2Csalvation%2Cspirit+filled%2Cbible+teacher%2Cfaith%2Cgifts%2CHolySpirit%2Cpray%2Chealing%2Cprophetic%2Cmiracles%2Csigns%2Cwonders%2Cpower%2Cglory%2Cordained%2C+discipleship%2Cwomens+speaker%2Cwomens+pastor%2Cteacher%2Cleadership%2Ctraining%2Cmentoring%2Cvision%2CChrist+Jesus%2Cinternational%2C+speaker%2Cmissionary%2Chealing%2CChrist+Jesus%2C+Christ%2CJesus%2CSavior%2CLord%2C+church%2C+bible%2CHoly+Spirit%2Cleader%2Cwomen%2Cwoman%2Cpastor%2Cministry%2Cauthority%2Cself+image%2Cself+esteem%2C+confidence%2C+peace%2Cjoy%2Cxpmedia%2Cpatricia+king';
var metaContents  = 'Kay+Hill+Ministries%2C+International+Christian+teacher+speaker%2C+Womens+ministry%2C+Pastor%2C+vision+to+teach+others+who+they+are+in+Christ+Jesus%2C+official+site+of+Kay+Hill+Ministries%2C+Ordained+minister%2C+Spirit+filled%2C+anointed+bible+teacher%2C+bible+speaker%2C+San+Marcos%2C+Texas%2C+leadership+training%2C+conference+teacher%2C+womens+conference+teacher%2C+speaker%2C+faith%2C+prophetic%2C+missionary%2C+manifestations+of+Holy+Spirit%2C+ministering+in+the+power+and+glory+of+God%2C+healing+ministry%2C+discipleship%2C+womens+speaker%2C+';
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();
};

