/* [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','15101',jdecode('Home+%2F+News'),jdecode(''), jdecode('%2F15101.html'), 'true',[],'',''],
	['PAGE','673',jdecode('Software'),jdecode(''), jdecode('%2F673.html'), 'true',[],'',''],
	['PAGE','694',jdecode('Geodaten'),jdecode(''), jdecode('%2F694.html'), 'true',[],'',''],
	['PAGE','37801',jdecode('Webmaps'),jdecode(''), jdecode('%2F37801.html'), 'true',[],'',''],
	['PAGE','652',jdecode('Lehrmittel'),jdecode(''), jdecode('%2F652.html'), 'true',[],'',''],
	['PAGE','57201',jdecode('Mat%C3%A9riel+scolaire'),jdecode(''), jdecode('%2F57201.html'), 'true',[],'',''],
	['PAGE','14301',jdecode('Weiterbildung'),jdecode(''), jdecode('%2F14301.html'), 'true',[],'',''],
	['PAGE','6901',jdecode('Lektionen'),jdecode(''), jdecode('%2F6901.html'), 'true',[],'',''],
	['PAGE','736',jdecode('Schulen+mit+GIS'),jdecode(''), jdecode('%2F736.html'), 'true',[],'',''],
	['PAGE','30501',jdecode('GIS+Day'),jdecode(''), jdecode('%2F30501.html'), 'true',[],'',''],
	['PAGE','29401',jdecode('ESRI+Sommercamp+im+SNP'),jdecode(''), jdecode('%2F29401.html'), 'true',[],'',''],
	['PAGE','18701',jdecode('e-geo.ch-Innovationspreis'),jdecode(''), jdecode('%2F18701.html'), 'true',[],'',''],
	['PAGE','34101',jdecode('GLOBE+Schweiz'),jdecode(''), jdecode('%2F34101.html'), 'true',[],'',''],
	['PAGE','12001',jdecode('Links'),jdecode(''), jdecode('%2F12001.html'), 'true',[],'',''],
	['PAGE','18101',jdecode('Kontakt'),jdecode(''), jdecode('%2F18101.html'), 'true',[],'','']];
var siteelementCount=15;
theSitetree.topTemplateName='Stylus';
theSitetree.paletteFamily='B5D3B5';
theSitetree.keyvisualId='1986';
theSitetree.keyvisualName='powerbutton2.jpg';
theSitetree.fontsetId='330';
theSitetree.graphicsetId='384';
theSitetree.contentColor='A00000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'de',
  country: 'CH'
};
var prodDef={
  wl_name: 'bluewin',
  product: 'WSCBLUSSSLYTC2MS'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Stylus',
				paletteFamily: 	'B5D3B5',
				keyvisualId: 	'1986',
				keyvisualName: 	'powerbutton2.jpg',
				fontsetId: 		'330',
				graphicsetId: 	'384',
				contentColor: 	'A00000',
				contentBGColor: 'FFFFFF',
				a_color: 		'B5D3B5',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '15101',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29401',
internalId:  '',
customField: '20111212-134314'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15101',
internalId:  '',
customField: '20111227-152955'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '652',
internalId:  '',
customField: '20090508-003801'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14301',
internalId:  '',
customField: '20110812-155353'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '673',
internalId:  '',
customField: '20111107-134340'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '694',
internalId:  '',
customField: '20111227-154035'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6901',
internalId:  '',
customField: '20111026-150207'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '736',
internalId:  '',
customField: '20110729-152040'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18701',
internalId:  '',
customField: '20101118-141557'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12001',
internalId:  '',
customField: '20101008-143449'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18101',
internalId:  '',
customField: '20101118-220906'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30501',
internalId:  '',
customField: '20110217-144652'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34101',
internalId:  '',
customField: '20101029-125108'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '37801',
internalId:  '',
customField: '20111208-150457'
};
webappMappings['5000']=webappMappings['5000--']={
webappId:    '5000',
documentId:  '57201',
internalId:  '-',
customField: '20120104-090723'
};
var webAppHostname = 'cgi.hpt001.bluewin.ch:80';
var canonHostname = 'hptworkerdb01a.bluewin.ch';
var accountId     = 'ABW0X0IN23G9';
var companyName   = 'GIS+an+Schweizer+Mittelschulen';
var htmlTitle	  = 'schulgis.ch+-+GIS+an+Schweizer+Mittelschulen';
var metaKeywords  = 'GIS+Geografische+Informationssysteme+Geoinformationssysteme+ESRI+VSGg+Schulen+Schule+Geografieunterricht+Unterricht';
var metaContents  = 'GIS+an+Schweizer+Mittelschulen';
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();
};

