<!--;
/**
*
* The myOnLoad function is used to choose the stuff you want to load in
* the page. If this is the same for all the pages, then why not move
* the defintion of myOnLoad to an external JS file?
*
*/
resourceid  = 'sal';

/* This is used in the user ratings - we'll use background images and no copy */
_STARMARKER = '&#160;';

/* This limits the number of comments that can appear on a page */
_MAX_COMMENTS = 20;

pageid = ''; /* this will be overwritten. For now it stops IE complaining in an ugly fashion */
function myOnLoad(){
	if (typeof(window['_FORCEDEBUG']) == "undefined") {
		/* offline */
		return '';
	};
	if(document.getElementById('metapath')){
		pageid   = document.getElementById('metapath').getAttribute('content');
	} else {
		alert('Document has missing meta data necessary for enhancements');
	};

	pagetitle    = document.title || 'Untitled Document';
	pagesubtitle = document.getElementById('unit').getAttribute('content');

	if(typeof(window['resourceid']) != "undefined" && resourceid
		&& typeof(window['_USERNAME']) != "undefined" && _USERNAME
		&& typeof(window['_PASSWORD']) != "undefined" && _PASSWORD){
		_dropins('span','username',_USERNAME);
		_dropins('span','groupname',_GROUPNAME);
		_hideOrShow('','','loggedinlink1','inline');
		_hideOrShow('','','loggedinlink0','none');
		_hideOrShow('','','tab_folder','inline');
		_hideOrShow('','','tab_routes','inline');
		_hideOrShow('','','logout','block');
		_hideOrShow('span','myaccount','','inline');
		_hideOrShow('','','bookmarklink','inline');
		_hideOrShow('','','home_login','none');
		_hideOrShow('','','home_routes','block');
		_hideOrShow('','','home_folder','block');
		_hideOrShow('','','notescontainer','block');
		_hideOrShow('','','commentscontainer','block');

		/* show a link to request updating your account, if you are logged in */
		_hideOrShow('','','requestuserupdatelink','inline');
		// prepSignupForm('loggedin');

		/* all group comments */
		// getCommentsOrNotes(actionName,somePageID,groupCall,note,comment,status,summary){
		getCommentsOrNotes('readcomment',pageid,1,'',1,1,0);
		// getCommentsOrNotes('readcomment',pageid,0,'',1,0,0);

		/* notes */
		getCommentsOrNotes('readnote',pageid,0,1,'','',0);


		/* log this page in the history */
		bookmarkOrHistory('history',pageid,pagetitle,pagesubtitle);

		/* get the routeInfo */
		readroute(pageid);

		// if (pageid == '/site/myfolder/listroutes.htm') {
		// };

	} else {
		_hideOrShow('','','loggedinlink1','none');
		_hideOrShow('','','loggedinlink0','inline');
		// _hideOrShow('a','logout','','none');
		// _hideOrShow('span','myaccount','','none');
		// _hideOrShow('','','bookmarklink','none');
		_hideOrShow('','','notescontainer','none');
		_hideOrShow('','','commentscontainer','none');

		/* show a link to request creating an account */
		_hideOrShow('','','requestsignuplink','block');
		// prepSignupForm('loggedout');
		if(document.getElementById('tab_lessons')){
			document.getElementById('tab_lessons').style.paddingRight = '15px';
			document.getElementById('tab_lessons').style.backgroundColor = '#D7DBDD';
		};
	};
	perPageJS();
};

/**
* Expect this to be overriden in individual pages
*/
function perPageJS(){ };

function loadQSet(someNumber,someInt){
	if(moz){try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");} catch (e) {};};
	if(someNumber != -1) {
		var myQSet = req[someInt].responseXML.documentElement.getElementsByTagName('questionset')[someNumber];
		var myForm = document.getElementById('infoform');
		document.getElementById('infoform').elements['name'].value = myQSet.getAttribute('name');
		for (var q=0;q<myQSet.getElementsByTagName('question').length;q++){
			var myId = myQSet.getElementsByTagName('question')[q].getAttribute('id') || '';
			var myResponse = myQSet.getElementsByTagName('question')[q].getAttribute('response') || '';
			if(myForm.elements[myId]) {
				for (var i=0;i<myForm.elements[myId].length;i++){
					if(myForm.elements[myId][i].value == myResponse) {
						myForm.elements[myId][i].checked = true;
					} else {
						myForm.elements[myId][i].checked = false;
					};
				};
			};
		};
	} else {
		document.getElementById('infoform').elements['name'].value = '';
	};
};

/**
*
* Overrides - these functions were defined in enhanced.js, but for
* each application we expect they will need to be overrriden.
*
*/

/**
* what is done after a good login:
* by default some cookeis are set and that's it
*/
function _postLogin(){
	document.location.href="postlogin.htm";
};

/**
* what is done after logout
*/
function _postLogout(){ myOnLoad();};

/**
* what is done after saving questionnaire info
*/
function process_writeinfo(someInt){
	document.location.href="viewroute.htm";
};

/**
* what is done when no route info is returned on a viewroute call
*/
function _noRoute(){
	document.location.href="questionnaire.htm";
};


/**
* what is done after reading questionnaire info
*/
function process_readinfo(someInt){
	_QUESTIONSETS = req[someInt].responseXML.documentElement;
	var qsetselect = '';
	qsetselect += '<select onChange="loadQSet(this.options[this.selectedIndex].value,'+ someInt +')">\n';
	qsetselect += '<option value="-1"></option>\n';
	for (var q=0;q<_QUESTIONSETS.getElementsByTagName('questionset').length;q++){
		var myName = _QUESTIONSETS.getElementsByTagName('questionset')[q].getAttribute('name');
		qsetselect += '<option value="'+ q +'">'+ myName +'</option>\n';
	};
	qsetselect += '</select>\n';
	if(_QUESTIONSETS.getElementsByTagName('questionset').length){
		document.getElementById('qsetselect').innerHTML = qsetselect;
	} else {
		document.getElementById('qsetselectrow').parentNode.removeChild(document.getElementById('qsetselectrow'));
	};
};
function preBookmarkOrHistory(type,pageid,pagetitle,pagesubtitle){
	if(confirm("Speaking and Listening: Please click 'ok' to add this item to my folder.")){
		bookmarkOrHistory(type,pageid,pagetitle,pagesubtitle);
	};
};

/**
* Override the default (which updates the comments list)
* As we've decided to only show approved comments.
*/ 
function process_writecomment(someInt) {
	alert("Thank you for submitting comments and ideas which, subject to approval from the moderator, will appear here shortly.");
};
//-->
