/* [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','501',jdecode('Accueil'),jdecode(''), jdecode('%2F501.html'), 'true',[],'',''],
	['PAGE','1801',jdecode('News'),jdecode(''), jdecode('%2F1801.html'), 'true',[],'',''],
	['PAGE','1822',jdecode('Cours+%2F+Rencontres'),jdecode(''), jdecode('%2F1822.html'), 'true',[],'',''],
	['PAGE','129401',jdecode('Contacts+%2F+Inscriptions'),jdecode(''), jdecode('%2F129401.html'), 'true',[],'',''],
	['PAGE','1843',jdecode('Nordic+Walking'),jdecode(''), jdecode('%2F1843.html'), 'true',[],'',''],
	['PAGE','128901',jdecode('Vos+commentaires'),jdecode(''), jdecode('%2F128901.html'), 'true',[],'',''],
	['PAGE','26301',jdecode('Photos'),jdecode(''), jdecode('%2F26301.html'), 'true',[],'',''],
	['PAGE','1927',jdecode('Liens'),jdecode(''), jdecode('%2F1927.html'), 'true',[],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='Trend';
theSitetree.paletteFamily='3F70CF';
theSitetree.keyvisualId='7970';
theSitetree.keyvisualName='kv_7970.jpg';
theSitetree.fontsetId='16912';
theSitetree.graphicsetId='12323';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'de',
  country: 'CH'
};
var prodDef={
  wl_name: 'bluewin',
  product: 'WSCBLUSSSLYTC2QE'
};
var theTemplate={
				hasFlashNavigation: 'true',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				name: 			'Trend',
				paletteFamily: 	'3F70CF',
				keyvisualId: 	'7970',
				keyvisualName: 	'kv_7970.jpg',
				fontsetId: 		'16912',
				graphicsetId: 	'12323',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				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['1002']=webappMappings['1002-128901abw0x0in2k5k']={
webappId:    '1002',
documentId:  '128901',
internalId:  '128901abw0x0in2k5k',
customField: 'icq=false'
};
webappMappings['7008']=webappMappings['7008-13434']={
webappId:    '7008',
documentId:  '129401',
internalId:  '13434',
customField: 'language:fr;country:FR;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20120118-210512'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1801',
internalId:  '',
customField: '20120130-184545'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1822',
internalId:  '',
customField: '20120110-213152'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1843',
internalId:  '',
customField: '20120105-012913'
};
webappMappings['5000']=webappMappings['5000--']={
webappId:    '5000',
documentId:  '128901',
internalId:  '-',
customField: '20120105-102116'
};
webappMappings['5000']=webappMappings['5000--']={
webappId:    '5000',
documentId:  '129401',
internalId:  '-',
customField: '20120106-152050'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '26301',
internalId:  '',
customField: '20111114-000106'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1927',
internalId:  '',
customField: '20100723-232914'
};
var webAppHostname = 'cgi.hpt001.bluewin.ch:80';
var canonHostname = 'hptworkerdb01b.bluewin.ch';
var accountId     = 'ABW0X0IN2K5K';
var companyName   = 'nyonwalking.ch';
var htmlTitle	  = 'nyonwalking.ch';
var metaKeywords  = 'Nordic+Walking+Nyon%2C+marche+nordique%2C+nyonwalking%2C+cours+de+nordic+walking%2C+rencontres+de+nordic+walking';
var metaContents  = 'Nordic+Walking+%C3%A0+Nyon%2C+Prangins+et+Tr%C3%A9lex%2C+sport%2C+activit%C3%A9+physique%2C+bien-%C3%AAtre%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();
};

