  // BROWSER RELATED STUFFS
  function qs( keyword ) {
     var query = window.location.search.substring(1);
     var parms = query.split('&');
     for (var i=0; i<parms.length; i++) {
         var pos = parms[i].indexOf('=');
         if (pos > 0) {
             var nam = parms[i].substring(0,pos);
             var val = parms[i].substring(pos+1);
             if ( keyword == nam ) return val;
         }
     }
     
     return null;
  }
  
  function bName() {
	// return 1 for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer")
	  return 1;

	// return 2 for Navigator
	if (navigator.appName == "Netscape")
	  return 2;

	// return 0 for other browsers
	return 0;
  }

  function bVer() {
	// return version number (e.g., 4.03)
	return parseFloat(navigator.appVersion);
  }

  function isNetscapeBrowser() {
	var nameCode = bName();
	if ( nameCode == 2 )
	{
		return true;
	}

	return false;
  }

  function isInternetExplorerBrowser() {
	var nameCode = bName();
	if ( nameCode == 1 )
	{
		return true;
	}

	return false;
  }

  function isVersionBrowserGreaterThanEqual( vc ) {
	var versionCode = bVer();
	if ( versionCode >= vc )
	{
		return true;
	}

	return false;
  }

  // COOKIE RELATED STUFFS
    
  function Get_Cookie(name) {
      var start = document.cookie.indexOf(name+"=");
      var len = start+name.length+1;
      if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
      if (start == -1) return null;
      var end = document.cookie.indexOf(";",len);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(len,end));
  }

  function Set_Cookie(name,value) {
      document.cookie = name + "=" + escape(value);
  }

  function Delete_Cookie(name) {
      if (Get_Cookie(name)) document.cookie = name + "=" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  }
  function Get_Cookie_StartsWith(name) {
      var start = document.cookie.indexOf(name);
      var len = start+name.length+1;
      if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
      if (start == -1) return null;
      var end = document.cookie.indexOf(";",len);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(0,end));
  }

  function Delete_Cookie_StartsWith( name ) {
	  while ( Get_Cookie_StartsWith( name ) )
	  {
		  var start = document.cookie.indexOf( "=" );
		  var nm = document.cookie.substring( 0, start-1 );
		  Delete_Cookie( nm );
	  }
  }

  var days = 14; // valid two weeks from now

  function isCookieEnabled() {
     if (document.all) return navigator.cookieEnabled;
     Set_Cookie('testcookie',today.getTime());
     var tc = Get_Cookie('testcookie');
     Delete_Cookie('testcookie');
     return (tc == today.getTime());
  }

  var today = new Date();
  var zero_date = new Date(0,0,0);
  today.setTime(today.getTime() - zero_date.getTime());

  var todays_date = new Date(today.getYear(),today.getMonth(),today.getDate(),0,0,0);
  var expires_date = new Date(todays_date.getTime() + (days * 86400000));

// ERROR MESSAGE RELATED STUFFS
  function msgFunctionToBeImplemented() {
	  alert( "This function is to be implemented." );
  }

  function msgInfomation( s ) {
	  alert( s );
  }

// COMMON OBJECTS
  function dateObject() {
  	var today=new Date();
	var year=today.getYear();
	if (year < 1000) year+=1900;
	var day=today.getDay();
	var month=today.getMonth();
	var daym=today.getDate();
	if (daym<10) daym="0"+daym;
	var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	return ("<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>");
  }
  
// FOCUS OBJECT 
  function placeFocus( thisform ) {
	if (document.forms.length > 0) {
		for (i = 0; i < document.forms.length; i++) {
			if ( document.forms[i] == thisform ) {
				for (j=0; j < thisform.elements.length; j++ ) {
			    		if ((thisform.elements[j].type == "text")     || 
			    		    (thisform.elements[j].type == "textarea")) {
			     			thisform.elements[j].focus();
						break;
					} // if
				} // for
	         	} // if
	        } // for
      	} // if
  }

// LIST/MENU EXPANDABLE
function initMenus() {
	if (!document.getElementsByTagName) return;
	
	var aMenus = document.getElementsByTagName("LI");
	for (var i = 0; i < aMenus.length; i++) {
		var mclass = aMenus[i].className;
		if (mclass.indexOf("treenode") > -1) {
			var submenu = aMenus[i].childNodes;
			for (var j = 0; j < submenu.length; j++) {
				if (submenu[j].tagName == "A") {
					
					submenu[j].onclick = function() {
						var node = this.nextSibling;
											
						while (1) {
							if (node != null) {
								if (node.tagName == "UL") {
									var d = (node.style.display == "none")
									node.style.display = (d) ? "block" : "none";
									this.className = (d) ? "treeopen" : "treeclosed";
									return false;
								}
								node = node.nextSibling;
							} else {
								return false;
							}
						}
						return false;
					}
					
					submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
				}
				
				if (submenu[j].tagName == "UL")
					submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
			}
		}
	}
}

// TIMER STUFFS
var timeoutID;
var timeoutMilliseconds=600000;  // 10 minutes = 600000 / (60 * 1000);
var timeoutMsg="Your login session has been timed out. As a security precaution, sessions are ended after "
        + getTotalIdleAllowedInMinute(timeoutMilliseconds) + " minutes of inactivity. You can login again to resume.";
function getTotalIdleAllowedInMinute(myTimeoutMilliseconds)
{
    totalTimeoutMilliseconds = myTimeoutMilliseconds;
    totalIdleAllowedInMinute = totalTimeoutMilliseconds / (60 * 1000);
    return totalIdleAllowedInMinute;
}
function resetTimer()
{
    setupTimeout(timeoutMilliseconds);
}
function setupTimeout(myTimeoutMilliseconds)
{
    window.clearTimeout(timeoutID);

    timeoutID = window.setTimeout('displayTimeoutMsg()', myTimeoutMilliseconds); // Setting up final timeout
}
function displayTimeoutMsg()
{
    alert(timeoutMsg);
    document.SignOff.submit();
}

// player stuffs
// for example: <a href="somefile.mp3" onclick="return showplayer(this)">Listen to the MP3</a> 
//
function showplayer(link) { 
   if (!document.createElement) return true; // if this script isn't supported, follow the link 

   var player = document.createElement("object"); 

   player.setAttribute("classid","clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"); 
   player.setAttribute("codebase","http://www.apple.com/qtactivex/qtplugin.cab"); 
   player.setAttribute("type","application/x-oleobject"); 
   player.setAttribute("height","16"); 
   player.setAttribute("width","240"); 
   player.appendChild(makeParam("src",link.href)); 
   player.appendChild(makeParam("controller","true")); 
   player.appendChild(makeParam("autostart","true")); 
   var obj = document.createElement("object"); 
   obj.setAttribute("type","audio/mpeg"); // or whatever the mime type for MP3 is 
   obj.setAttribute("data",link.href); 
   obj.setAttribute("class","mp3") 
   obj.setAttribute("height","16"); 
   obj.setAttribute("width","240"); 
   obj.appendChild(makeParam("controller","true")); 
   obj.appendChild(makeParam("autostart","true")); 
   
   player.appendChild(obj); 
   link.parentNode.replaceChild(player,link); 

   return false; // if the script succeeds, don't follow the link 
} 
function makeParam(name,value) { 
   var newparam = document.createElement("param"); 

   newparam.setAttribute("name",name); 
   newparam.setAttribute("value",value); 

   return newparam; 
} 

//window.onload = initMenus;