function OnSubmitForm()
{
  if(document.loginform.schoolcode.value == 'stjc')
  {
    document.loginform.action ="http://classnav.sjc.co.za/module.php?id=verify";
  }
  else
  {
    document.loginform.action ="module.php?id=verify";
  }
  return true;
}

function togglesection(secid) {
	secid = "g"+secid;
	if (document.getElementById) {
		var secparent = document.getElementById(secid+"-parent");
		var secimage = document.getElementById(secid+"-image");
		var sectitle = document.getElementById(secid+"-title");
		var secblock = document.getElementById(secid+"-block");
		var secmore = document.getElementById(secid+"-more");
		if (secblock.style.display == "none") {
			secblock.style.display = "block";
			secimage.src = "hp_image/directory_service/img/collapse.gif";
			sectitle.innerText = "Less Information...";
			secparent.style.overflow = "hidden";
			secmore.style.overflow = "visible";
			secmore.style.position = "absolute";
			secmore.style.zIndex = 1000;
		} else {
			secblock.style.display = "none";
			secimage.src = "hp_image/directory_service/img/expand.gif";
			sectitle.innerText = "More Information...";
			secparent.style.overflow = "visible";
			secmore.style.overflow = "hidden";
			secmore.style.position = "absolute";
			secmore.style.zIndex = 1;
		}
	}
}

function LTrim(str) {
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {

      var j=0, i = s.length;

      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      s = s.substring(j, i);
   }
   return s;
}
function RTrim(str) {
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {

      var i = s.length - 1;       // Get length of string

      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;

      s = s.substring(0, i+1);
   }

   return s;
}
function Trim(str) {
   return RTrim(LTrim(str));
}
function pollgen() {
	polltype = prompt("Enter the topic you wish voted upon", "");
	if (polltype != "")  {
		thepoll = "[pollstart]\n[polltitle]"+polltype+"[/polltitle]\n";
	} else {
		thepoll = null
	}
	pollentry = "initial";
	while ((pollentry != "") && (pollentry != null)) {
		pollentry = prompt("Enter a poll option. You can enter as many as you like. \nPress cancel or just leave blank to complete the poll", "");
		if ((pollentry != "") && (pollentry != null)) {
			thepoll = thepoll+"[polloption]"+pollentry+"[/polloption]\n";
		} else {
			thepoll = thepoll+"[/pollstart]";
		}
	}
	var polldatahandle = document.all("upolldata");
	polldatahandle.value = thepoll;
	polldatahandle.focus();
	return;
}
function pollsort() {
	polldatahandle = document.all("upolldata");
	pollform = document.all("modpoll");
	numopts = polldatahandle.value - 1;
	myopt = 0;
	pollout = "";
	while (myopt <= numopts) {
		optionhandle = document.all("option-" + myopt);
		pollout = pollout + optionhandle.value + "/-/0";
		if (myopt != numopts) {
			pollout = pollout + "/¬/";
		}
		myopt = myopt + 1;
	}
	polldatahandle.value = pollout;
	pollform.Submit();
	return;
}
function handle(obj, parentobj) {
	var handle = document.all(obj);
	var phandle = document.all(parentobj);
	if (handle.style.display == "none") {
    	handle.style.display = "";
		phandle.src = "img/collapse.jpg";
	}
	else {
		handle.style.display = "none";
		phandle.src = "img/expand.jpg";
	}
}
function handle2(obj, shandle, closedText, openText) {
	var handle = document.all(obj);
	// var shandle = document.all(selfobj);
	if (handle.style.display == "none") {
    	handle.style.display = "";
		shandle.innerHTML = openText;
	}
	else {
		handle.style.display = "none";
		shandle.innerHTML = closedText;
	}
}
function changeclass(obj) {
	var counter = 0;
	var limiter = document.all("calendar_upperlimit");
	var upperlimit = limiter.innerText;
	while (counter < upperlimit) {
		var thiscell = document.all("calcell_" + counter);
		thiscell.className='cbck';
		counter = counter + 1;
	}
	var the_home = document.all("calcell_home");
	the_home.className='cbck_today';
	var the_old = document.all("calcell_old");
	if (the_old) { the_old.className='cbck_old'; }
	var item = document.all(obj);
	item.className='cbck_selected';
}
function delhandle(parentobj) {
	if (parentobj == "edit") {
    	deletediv.style.visibility = "hidden";
	}
	else {
		deletediv.style.visibility = "visible";
	}
}
function updateUsernames(number,pageID) {
	if (!number) return;
	var tBox = document.all("cmembers_txt");
	var cur_group = document.all("group");
	var grpname = "grp_" + number;
	cur_group.value = number;
	var list = myGroups[grpname];
	var finalList = ""; var shimg = "";
	for(i=0;i<list.length;i+=3) {
	    if (list[i+2] == '1') {
			shimg = "<a href=\'module.php?id="+pageID+"&action=del&type=member&group="+number+"&subid="+list[i+1]+"\'><img src=\'img/collapse.jpg\' border=0></a> ";
	    } else {
	        shimg = "";
	    }
	    if (list[i+1] == 'nosel') {
	        finalList += list[i]+"<br>\n";
	    } else {
			finalList += shimg+list[i]+"<br>\n";
	    }
	}
	tBox.innerHTML = finalList;
}
function hoverspan(obj) {
	if (obj.className.indexOf("_hover") != -1) {
		obj.className = obj.className.substr(0, obj.className.indexOf("_hover"));
		obj.style.cursor = 'auto';
	} else if (obj.className.indexOf("_click") == -1) {
	    obj.className = obj.className + "_hover";
	    obj.style.cursor = 'hand';
	}
}
function hoverspan_nohand(obj) {
	if (obj.className.indexOf("_hover") != -1) {
		obj.className = obj.className.substr(0, obj.className.indexOf("_hover"));
	} else if (obj.className.indexOf("_click") == -1) {
	    obj.className = obj.className + "_hover";
	}
}
function clickspan(obj_txt, myObj) {
	var plainClass = myObj.className;
	if (plainClass.indexOf("_hover") != -1) {
		plainClass = plainClass.substr(0, plainClass.indexOf("_hover"));
	} else if (plainClass.indexOf("_click") != -1) {
		plainClass = plainClass.substr(0, plainClass.indexOf("_click"));
	}
	var obj = document.all(obj_txt);
	var loop = 0;
	for (loop=0;loop<obj.length;loop++) {
		obj[loop].className = plainClass;
	}
	myObj.className = plainClass + "_click";
}
function popitup(url) {
	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,'name','height=200,width=150');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}
function iframe_passthru(frameName, returnName, formName, resultName, tsCode, arrElements) {
    arrElements = arrElements.split("/");
    var frameObj = frames[frameName];
	for(var loop = 0;loop<arrElements.length;loop++) {
	    var str = arrElements[loop];
	    var thisObj = document.forms[formName].elements[str];
	    if (thisObj.type == undefined) {
	        if (thisObj[0].type != undefined) {
	            for (var i=0;i<thisObj.length;i++) {
	                if (thisObj[i].checked) {
	                    frameObj.document.forms[formName].elements[str].value = thisObj[i].value;
	                }
	            }
	        } else {
	            alert("Script Error: Make sure you are using the form correctly and from the Class Navigator website!");
	            return false;
	        }
	    } else {
	        frameObj.document.forms[formName].elements[str].value = thisObj.value;
	    }
	}
	frameObj.document.forms[formName].elements['returnName'].value = returnName;
	frameObj.document.forms[formName].elements['formName'].value = formName;
	frameObj.document.forms[formName].elements['resultName'].value = resultName;
	frameObj.document.forms[formName].elements['tscode'].value = tsCode;
	frameObj.document.forms[formName].submit();
}
function newTopics(agValue) {
	var sBox = document.all("subid");
	var tBox = document.all("topic");
	tBox.options.length = 0;
    var number = sBox.options[sBox.selectedIndex].value;
    if (number == 'all') {
        tBox.options[0] = new Option(agValue,'all');
        return;
    }
	var grpname = "grp_" + number;
	var list = myGroups[grpname];
	var count = 0;
	for(i=0;i<list.length;i+=2) {
	    tBox.options[count] = new Option(list[i],list[i+1]);
	    count++;
	}
}
function getObj(name) {
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  } else if (document.all) {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  } else if (document.layers) {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}
function getObjNN4(obj,name) {
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++) {
		if (x[i].id == name) {
		 	foundLayer = x[i];
		} else if (x[i].layers.length) {
			var tmp = getObjNN4(x[i],name);
		}
		if (tmp) { foundLayer = tmp; }
	}
	return foundLayer;
}
function storeCaret (textEl) {
	if (textEl.createTextRange) {
		textEl.caretPos = document.selection.createRange().duplicate();
	}
}
function insertAtCaret (textEl, text) {
	if (!textEl.name.indexOf('_html')) {
		if (textEl.createTextRange && textEl.caretPos) {
			var caretPos = textEl.caretPos;
			caretPos.text =
				caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
				text + ' ' : text;
		} else {
			textEl.value  = textEl.value + text; // for non MSIE browsers just append it
		}
	} else {
	    editor_insertHTML(textEl.name,text);
	}
	return true;
}
function insertVariable(nameToInsert) {
	var x = document.all['whatelement'].innerText;
    insertAtCaret(document.all[x],nameToInsert);
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}
function deleteMsgs(formParent, checkArray) {
	var x = document.all[checkArray];
	var numchecked = 0;

	for (var i=0;i<x.length;i++) {
		if (x[i].checked) { numchecked++; }
	}
	if (numchecked) {
		if (!confirm('Are you sure you wish to delete these '+numchecked+' messages?')) {
		    return false;
		} else {
		    return true;
		}
	} else {
	    return false;
	}
}
function checkall(masterBox, checkArray) {
	var x = document.all[checkArray];
	
	for (var i=0;i < x.length;i++) {
		x[i].checked = masterBox.checked;
	}
}

function checkall_button(checkArray,true_false) {
	var x = document.all[checkArray];

	for (var i=0;i < x.length;i++) {
		x[i].checked = true_false;
	}
}


/*--------------------------------------------------|

| dTree 2.05 | www.destroydrop.com/javascript/tree/ |

|---------------------------------------------------|

| Copyright (c) 2002-2003 Geir Landrö               |

|                                                   |

| This script can be used freely as long as all     |

| copyright messages are intact.                    |

|                                                   |

| Updated: 17.04.2003                               |

|--------------------------------------------------*/



// Node object

function Node(id, pid, name, url, title, target, icon, iconOpen, open) {

	this.id = id;

	this.pid = pid;

	this.name = name;

	this.url = url;

	this.title = title;

	this.target = target;

	this.icon = icon;

	this.iconOpen = iconOpen;

	this._io = open || false;

	this._is = false;

	this._ls = false;

	this._hc = false;

	this._ai = 0;

	this._p;

};



// Tree object

function dTree(objName) {

	this.config = {

		target					: null,

		folderLinks			: true,

		useSelection		: true,

		useCookies			: true,

		useLines				: true,

		useIcons				: true,

		useStatusText		: false,

		closeSameLevel	: false,

		inOrder					: false

	}

	this.icon = {

		root				: 'img/tree_img/base.gif',

		folder			: 'img/tree_img/folder.gif',

		folderOpen	: 'img/tree_img/folderopen.gif',

		node				: 'img/tree_img/page.gif',

		empty				: 'img/tree_img/empty.gif',

		line				: 'img/tree_img/line.gif',

		join				: 'img/tree_img/join.gif',

		joinBottom	: 'img/tree_img/joinbottom.gif',

		plus				: 'img/tree_img/plus.gif',

		plusBottom	: 'img/tree_img/plusbottom.gif',

		minus				: 'img/tree_img/minus.gif',

		minusBottom	: 'img/tree_img/minusbottom.gif',

		nlPlus			: 'img/tree_img/nolines_plus.gif',

		nlMinus			: 'img/tree_img/nolines_minus.gif'

	};

	this.obj = objName;

	this.aNodes = [];

	this.aIndent = [];

	this.root = new Node(-1);

	this.selectedNode = null;

	this.selectedFound = false;

	this.completed = false;

};



// Adds a new node to the node array

dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {

	this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);

};



// Open/close all nodes

dTree.prototype.openAll = function() {

	this.oAll(true);

};

dTree.prototype.closeAll = function() {

	this.oAll(false);

};



// Outputs the tree to the page

dTree.prototype.toString = function() {

	var str = '<div class="dtree">\n';

	if (document.getElementById) {

		if (this.config.useCookies) this.selectedNode = this.getSelected();

		str += this.addNode(this.root);

	} else str += 'Browser not supported.';

	str += '</div>';

	if (!this.selectedFound) this.selectedNode = null;

	this.completed = true;

	return str;

};



// Creates the tree structure

dTree.prototype.addNode = function(pNode) {

	var str = '';

	var n=0;

	if (this.config.inOrder) n = pNode._ai;

	for (n; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == pNode.id) {

			var cn = this.aNodes[n];

			cn._p = pNode;

			cn._ai = n;

			this.setCS(cn);

			if (!cn.target && this.config.target) cn.target = this.config.target;

			if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);

			if (!this.config.folderLinks && cn._hc) cn.url = null;

			if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {

					cn._is = true;

					this.selectedNode = n;

					this.selectedFound = true;

			}

			str += this.node(cn, n);

			if (cn._ls) break;

		}

	}

	return str;

};



// Creates the node icon, url and text

dTree.prototype.node = function(node, nodeId) {

	var str = '<div class="dTreeNode">' + this.indent(node, nodeId);

	if (this.config.useIcons) {

		if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);

		if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;

		if (this.root.id == node.pid) {

			node.icon = this.icon.root;

			node.iconOpen = this.icon.root;

		}

		str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" border=0/>';

	}

	if (node.url) {

		str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';

		if (node.title) str += ' title="' + node.title + '"';

		if (node.target) str += ' target="' + node.target + '"';

		if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';

		if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))

			str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';

		str += '>';

	}

	else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)

		str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';

	str += node.name;

	if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';

	str += '</div>';

	if (node._hc) {

		str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';

		str += this.addNode(node);

		str += '</div>';

	}

	this.aIndent.pop();

	return str;

};



// Adds the empty and line icons

dTree.prototype.indent = function(node, nodeId) {

	var str = '';

	if (this.root.id != node.pid) {

		for (var n=0; n<this.aIndent.length; n++)

			str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" border=0 />';

		(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);

		if (node._hc) {

			str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img border=0 id="j' + this.obj + nodeId + '" src="';

			if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;

			else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );

			str += '" alt="" /></a>';

		} else str += '<img border=0 src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';

	}

	return str;

};



// Checks if a node has any children and if it is the last sibling

dTree.prototype.setCS = function(node) {

	var lastId;

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == node.id) node._hc = true;

		if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;

	}

	if (lastId==node.id) node._ls = true;

};



// Returns the selected node

dTree.prototype.getSelected = function() {

	var sn = this.getCookie('cs' + this.obj);

	return (sn) ? sn : null;

};



// Highlights the selected node

dTree.prototype.s = function(id) {

	if (!this.config.useSelection) return;

	var cn = this.aNodes[id];

	if (cn._hc && !this.config.folderLinks) return;

	if (this.selectedNode != id) {

		if (this.selectedNode || this.selectedNode==0) {

			eOld = document.getElementById("s" + this.obj + this.selectedNode);

			eOld.className = "node";

		}

		eNew = document.getElementById("s" + this.obj + id);

		eNew.className = "nodeSel";

		this.selectedNode = id;

		if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);

	}

};



// Toggle Open or close

dTree.prototype.o = function(id) {

	var cn = this.aNodes[id];

	this.nodeStatus(!cn._io, id, cn._ls);

	cn._io = !cn._io;

	if (this.config.closeSameLevel) this.closeLevel(cn);

	if (this.config.useCookies) this.updateCookie();

};



// Open or close all nodes

dTree.prototype.oAll = function(status) {

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {

			this.nodeStatus(status, n, this.aNodes[n]._ls)

			this.aNodes[n]._io = status;

		}

	}

	if (this.config.useCookies) this.updateCookie();

};



// Opens the tree to a specific node

dTree.prototype.openTo = function(nId, bSelect, bFirst) {

	if (!bFirst) {

		for (var n=0; n<this.aNodes.length; n++) {

			if (this.aNodes[n].id == nId) {

				nId=n;

				break;

			}

		}

	}

	var cn=this.aNodes[nId];

	if (cn.pid==this.root.id || !cn._p) return;

	cn._io = true;

	cn._is = bSelect;

	if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);

	if (this.completed && bSelect) this.s(cn._ai);

	else if (bSelect) this._sn=cn._ai;

	this.openTo(cn._p._ai, false, true);

};



// Closes all nodes on the same level as certain node

dTree.prototype.closeLevel = function(node) {

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {

			this.nodeStatus(false, n, this.aNodes[n]._ls);

			this.aNodes[n]._io = false;

			this.closeAllChildren(this.aNodes[n]);

		}

	}

}



// Closes all children of a node

dTree.prototype.closeAllChildren = function(node) {

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {

			if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);

			this.aNodes[n]._io = false;

			this.closeAllChildren(this.aNodes[n]);

		}

	}

}



// Change the status of a node(open or closed)

dTree.prototype.nodeStatus = function(status, id, bottom) {

	eDiv	= document.getElementById('d' + this.obj + id);

	eJoin	= document.getElementById('j' + this.obj + id);

	if (this.config.useIcons) {

		eIcon	= document.getElementById('i' + this.obj + id);

		eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;

	}

	eJoin.src = (this.config.useLines)?

	((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):

	((status)?this.icon.nlMinus:this.icon.nlPlus);

	eDiv.style.display = (status) ? 'block': 'none';

};





// [Cookie] Clears a cookie

dTree.prototype.clearCookie = function() {

	var now = new Date();

	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);

	this.setCookie('co'+this.obj, 'cookieValue', yesterday);

	this.setCookie('cs'+this.obj, 'cookieValue', yesterday);

};



// [Cookie] Sets value in a cookie

dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {

	document.cookie =

		escape(cookieName) + '=' + escape(cookieValue)

		+ (expires ? '; expires=' + expires.toGMTString() : '')

		+ (path ? '; path=' + path : '')

		+ (domain ? '; domain=' + domain : '')

		+ (secure ? '; secure' : '');

};



// [Cookie] Gets a value from a cookie

dTree.prototype.getCookie = function(cookieName) {

	var cookieValue = '';

	var posName = document.cookie.indexOf(escape(cookieName) + '=');

	if (posName != -1) {

		var posValue = posName + (escape(cookieName) + '=').length;

		var endPos = document.cookie.indexOf(';', posValue);

		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));

		else cookieValue = unescape(document.cookie.substring(posValue));

	}

	return (cookieValue);

};



// [Cookie] Returns ids of open nodes as a string

dTree.prototype.updateCookie = function() {

	var str = '';

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {

			if (str) str += '.';

			str += this.aNodes[n].id;

		}

	}

	this.setCookie('co' + this.obj, str);

};



// [Cookie] Checks if a node id is in a cookie

dTree.prototype.isOpen = function(id) {

	var aOpen = this.getCookie('co' + this.obj).split('.');

	for (var n=0; n<aOpen.length; n++)

		if (aOpen[n] == id) return true;

	return false;

};



// If Push and pop is not implemented by the browser

if (!Array.prototype.push) {

	Array.prototype.push = function array_push() {

		for(var i=0;i<arguments.length;i++)

			this[this.length]=arguments[i];

		return this.length;

	}

};

if (!Array.prototype.pop) {

	Array.prototype.pop = function array_pop() {

		lastElement = this[this.length-1];

		this.length = Math.max(this.length-1,0);

		return lastElement;

	}

};
// Title: Tigra Hints
// URL: http://www.softcomplex.com/products/tigra_hints/
// Version: 1.3
// Date: 09/03/2003 (mm/dd/yyyy)
// Note: Permission given to use this script in ANY kind of applications if
//    header lines are left unchanged.

var THintsS = [];
function THints (o_cfg, items) {
	this.n_id = THintsS.length;
	THintsS[this.n_id] = this;
	this.top = o_cfg.top ? o_cfg.top : 0;
	this.left = o_cfg.left ? o_cfg.left : 0;
	this.n_dl_show = o_cfg.show_delay;
	this.n_dl_hide = o_cfg.hide_delay;
	this.b_wise = o_cfg.wise;
	this.b_follow = o_cfg.follow;
	this.x = 0;
	this.y = 0;
	this.divs = [];
	this.iframes = [];
	this.show  = TTipShow;
	this.showD = TTipShowD;
	this.hide = TTipHide;
	this.move = TTipMove;
	// register the object in global collection
	this.n_id = THintsS.length;
	THintsS[this.n_id] = this;
	// filter Netscape 4.x out
	if (document.layers) return;
	var b_IE = navigator.userAgent.indexOf('MSIE') > -1,
	s_tag = ['<iframe frameborder="0" scrolling="No" id="TTifip%name%" style="visibility:hidden;position:absolute;top:0px;left:0px;',   b_IE ? 'width:1px;height:1px;' : '', o_cfg['z-index'] != null ? 'z-index:' + o_cfg['z-index'] : '', '" width=1 height=1></iframe><div id="TTip%name%" style="visibility:hidden;position:absolute;top:0px;left:0px;',   b_IE ? 'width:1px;height:1px;' : '', o_cfg['z-index'] != null ? 'z-index:' + o_cfg['z-index'] : '', '"><table cellpadding="0" cellspacing="0" border="0"><tr><td class="', o_cfg.css, '" nowrap>%text%</td></tr></table></div>'].join('');


	this.getElem =
		function (id) { return document.all ? document.all[id] : document.getElementById(id); };
	this.showElem =
		function (id, hide) {
		this.divs[id].o_css.visibility = hide ? 'hidden' : 'visible';
		this.iframes[id].o_css.visibility = hide ? 'hidden' : 'visible';
		};
	this.getWinSz = window.innerHeight != null
		? function (b_hight) { return b_hight ? innerHeight : innerWidth; }
		: function (b_hight) { return document.body[b_hight ? 'clientHeight' : 'clientWidth']; };
	this.getWinSc = window.innerHeight != null
		? function (b_hight) { return b_hight ? pageYOffset : pageXOffset; }
		: function (b_hight) { return document.body[b_hight ? 'scrollTop' : 'scrollLeft']; };
	if (window.opera) {
		this.getSize = function (id, b_hight) {
			return this.divs[id].o_css[b_hight ? 'pixelHeight' : 'pixelWidth']
		};
		document.onmousemove = function () {
			for (var n_i in THintsS) {
				THintsS[n_i].x = event.clientX;
				THintsS[n_i].y = event.clientY;
				if (THintsS[n_i].b_follow && THintsS[n_i].visible)
					THintsS[n_i].move(THintsS[n_i].visible);
			}
			return true;
		};
	}
	else {
		this.getSize = function (id, b_hight) {
			return this.divs[id].o_obj[b_hight ? 'offsetHeight' : 'offsetWidth']
		};
		document.onmousemove = b_IE
		? function () {
			for (var n_i in THintsS) {
				THintsS[n_i].x = event.clientX + document.body.scrollLeft;
				THintsS[n_i].y = event.clientY + document.body.scrollTop;
				if (THintsS[n_i].b_follow && THintsS[n_i].visible)
					THintsS[n_i].move(THintsS[n_i].visible);
			}
			return true;
		}
		: function (e) {
			for (var n_i in THintsS) {
				THintsS[n_i].x = e.pageX;
				THintsS[n_i].y = e.pageY;
				if (THintsS[n_i].b_follow && THintsS[n_i].visible)
					THintsS[n_i].move(THintsS[n_i].visible)
			}
			return true;
		};
	}
	for (i in items) {
		document.write (s_tag.replace(/%text%/g, items[i]).replace(/%name%/g, i));
		this.divs[i] = { 'o_obj' : this.getElem('TTip' + i) };
		this.divs[i].o_css = this.divs[i].o_obj.style;
		this.iframes[i] = { 'o_obj' : this.getElem('TTifip' + i) };
		this.iframes[i].o_css = this.iframes[i].o_obj.style;

	}
}
function TTipShow (id) {
	if (document.layers) return;
	this.hide();
	if (this.divs[id]) {
		if (this.n_dl_show) this.divs[id].timer = setTimeout('THintsS[' + this.n_id + '].showD("' + id + '")', this.n_dl_show);
		else this.showD(id);
		this.visible = id;
	}
}

function TTipShowD (id) {
	this.move(id);
	this.showElem(id);
	if (this.n_dl_hide) this.timer = setTimeout("THintsS[" + this.n_id + "].hide()", this.n_dl_hide);
}

function TTipMove (id) {
	var n_x = this.x + this.left, n_y = this.y + this.top;
	if (this.b_wise) {
		var n_w = this.getSize(id), n_h = this.getSize(id, true),
		n_win_w = this.getWinSz(), n_win_h = this.getWinSz(true),
		n_win_l = this.getWinSc(), n_win_t = this.getWinSc(true);
		if (n_x + n_w > n_win_w + n_win_l) n_x = n_win_w + n_win_l - n_w;
		if (n_x < n_win_l) n_x = n_win_l;
		if (n_y + n_h > n_win_h + n_win_t) n_y = n_win_h + n_win_t - n_h;
		if (n_y < n_win_t) n_y = n_win_t;
	}
	this.divs[id].o_css.left = n_x;
	this.divs[id].o_css.top = n_y;
	this.iframes[id].o_css.left = n_x;
	this.iframes[id].o_css.top = n_y;
	this.iframes[id].o_css.height = n_h-this.top;
	this.iframes[id].o_css.width = this.getSize(id, false)-this.left;
}

function TTipHide () {
	if (this.timer) clearTimeout(this.timer);
	if (this.visible != null) {
		if (this.divs[this.visible].timer) clearTimeout(this.divs[this.visible].timer);
		setTimeout('THintsS[' + this.n_id + '].showElem("' + this.visible + '", true)', 10);
		this.visible = null;
	}
}

