/* [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 theSitetree=[ 
	['PAGE','5001',jdecode('Home'),jdecode(''),'/5001.html','true',[],''],
	['PAGE','11501',jdecode('The+Book+'),jdecode(''),'/11501.html','true',[],''],
	['PAGE','11522',jdecode('About+the+Authors'),jdecode(''),'/11522.html','true',[],''],
	['PAGE','11543',jdecode('Additional+Resources'),jdecode(''),'/11543.html','true',[],''],
	['PAGE','11564',jdecode('Teaching+Science+Policy+'),jdecode(''),'/11564.html','true',[],''],
	['PAGE','11585',jdecode('Academic+Programs'),jdecode(''),'/11585.html','true',[],''],
	['PAGE','11606',jdecode('Conferences%2FSeminars+'),jdecode(''),'/11606.html','true',[],''],
	['PAGE','11627',jdecode('Internships%2FFellowships'),jdecode(''),'/11627.html','true',[],''],
	['PAGE','11648',jdecode('Contact+Us'),jdecode(''),'/11648.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Stars';
theSitetree.paletteFamily='000000';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10466';
theSitetree.graphicsetId='10916';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='000000';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Stars',
				paletteFamily: 	'000000',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10466',
				graphicsetId: 	'10916',
				contentColor: 	'FFFFFF',
				contentBGColor: '000000',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5001',
internalId:  '',
customField: '20090406-210924'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11501',
internalId:  '',
customField: '20090804-175029'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11522',
internalId:  '',
customField: '20080717-195250'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11543',
internalId:  '',
customField: '20090805-134724'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11585',
internalId:  '',
customField: '20080814-190749'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11564',
internalId:  '',
customField: '20090804-181409'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '5001',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11606',
internalId:  '',
customField: '20080814-203755'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11627',
internalId:  '',
customField: '20090808-093937'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11648',
internalId:  '',
customField: '20080814-191625'
};
var canonHostname = 'cmworker01.yourhostingaccount.com';
var accountId     = 'AENDU0IN2YCB';
var companyName   = 'U.S.+Science+Policy+in+the+21st+Century';
var htmlTitle	  = 'Science+Policy+in+the+21st+Century+';
var metaKeywords  = 'Science+policy%2C+Sputnik%2C+Science+education%2C+Scientific+workforce%2C+Scientific+ethics%2C+Big+Science%2C+National+laboratory%2C+Federal+Laboratory%2C+Technology+policy%2C+Scientific+grand+challenges%2C+Science+and+politics%2C+University-government+research%2C+Federal+research+funding%2C+Science+and+society%2C+Research+policy%2C+Jennifer+McCormick%2C+Homer+Neal%2C+Tobin+Smith%2C+Science+and+Policy%2C+Public+Policy+and+Science%2C+Space+Policy%2C+Environmental+Policy%2C+Political+Science+for+Scientists%2C+internships%2C+science+policy+internships%2C+Science+and+pulblic+policy%2C+STEM+Education%2C+Toby+Smith%2C+Research+universities%2C+State+RD%2C+RD+Policy%2C+Science+funding%2C+Science+and+National+Defense%2C+Science+Debate+2008%2C+Scientist+and+Engineers+for+American%2C+AAAS+Policy%2C+AAAS+Science+Policy+Fellows';
var metaContents  = 'A+website+and+book+for+people+interested+in+learning+about+science+policy+with+links+to+science+policy+related+resources+including+books%2C+magazines%2C+newsletters+and+federal+budget+information.+Also+contains+information+on+science+policy+related+seminars%2C+workshops%2C+internships%2C+fellowships+and+undergraduate%2Fgraduate+science+policy+programs+and+courses.+';
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();
};
