	var iTop = 115;
	function uniqueID(){
		var id = (new Date()).getTime();
		id += Math.random().toString().replace(/\./,"");
		return id;
	}
	function getCookie(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 setCookie(name, value, expires, path, domain, secure){
		document.cookie = name + "=" + escape(value) +
			( (expires) ? ";expires=" + expires.toGMTString() : "") +
			( (path) ? ";path=" + path : "") +
			( (domain) ? ";domain=" + domain : "") +
			( (secure) ? ";secure" : "");
	}
	function getHost() {
	  var host = (typeof window.all != 'undefined' && typeof window.opera == 'undefined') ?
	    window.location.hostname : window.location.host;
	  if (!host) host = document.location.hostname;
	  return !host?null:host;
	}

/**
 * Cookie functions:
 * In order to improve our service, we use cookies to
 * calculate the number of unique users.
 */
var SESSION_COOKIE = "sessionID";
var USER_COOKIE = "usrID";
var OLD_USER_COOKIE = "userID";
var LOGGED_IN_COOKIE = "show_logout";
initCookies = function() {
  var today = new Date();
  var dAdd = new Date(today.getTime() + (365 * 86400000));
  var host = getHost();
  var domain;
  if (host && host.indexOf(".") != -1){
    var hostArr = host.split(".");
    if (hostArr.length > 1){
      domain = "." + hostArr[hostArr.length-2] + "." + hostArr[hostArr.length-1]; 
    }
  }
  var sessionCookie = getCookie(SESSION_COOKIE);
  var oldUserCookie = getCookie(OLD_USER_COOKIE);
  //if (oldUserCookie !== null) delCookie(OLD_USER_COOKIE);
  var userCookie = getCookie(USER_COOKIE);
  //just touch the permanent cookie if exists
  if (userCookie !== null) {
    if (sessionCookie === null)
      setCookie(USER_COOKIE, userCookie, dAdd, "/", domain, false);
  }
  else {
    setCookie(USER_COOKIE, (oldUserCookie != null ? oldUserCookie : getUniqueID()), dAdd, "/", domain, false);
  }
  //unique cookie for this session
  if (sessionCookie === null)
    setCookie(SESSION_COOKIE, getUniqueID());
  //if logged in cookie is present, make the logout link visible
  if (getCookie(LOGGED_IN_COOKIE) !== null) {
    if (document.getElementById) {
	    var logoutLink = document.getElementById("logout_link");
	    if (logoutLink)
	    	logoutLink.style.display = "inline";
  	}
  }
}

/*
	var today = new Date();
	var dAdd = new Date(today.getTime() + (365 * 86400000));
	if (getCookie('userID') != null){
		setCookie('userID', getCookie('userID'), dAdd);
	}
	else{
		setCookie('userID', uniqueID(), dAdd);
	}
	if (getCookie('sessionID') == null){
		setCookie('sessionID', uniqueID());
	}
*/
	function IsNumeric(sText){
		var ValidChars = "0123456789.";
		var IsNumber=true;
		var Char;
		for (i = 0; i < sText.length && IsNumber == true; i++){ 
		    Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1){
		        IsNumber = false;
        	}
		}
		return IsNumber;   
	}
	function goToURL(sel){
		if (sel.options[sel.selectedIndex].value != ''){
			window.location.href = sel.options[sel.selectedIndex].value;
		}
	}
	function getNumber(sID){
		if (sID.indexOf('firstlink') != -1){			
			return sID.substr((sID.indexOf('firstlink') + 9), sID.length);			
		}
		if (sID.indexOf('divFirstLink') != -1){
			return sID.substr((sID.indexOf('divFirstLink') + 12), sID.length);			
		}
		else{
			return sID.substr((sID.indexOf('second') + 6), sID.length);
		}
	}
	function previousPipe(obj, s){
		var objSibling = obj.previousSibling;
		while (objSibling && objSibling.nodeType != 1) {
			objSibling = objSibling.previousSibling;1
		}
		setSibling(objSibling, s);
	}
	function nextPipe(obj, s){
		var objSibling = obj.nextSibling;
		while (objSibling && objSibling.nodeType != 1) {
			objSibling = objSibling.nextSibling;
		}
		setSibling(objSibling, s);
	}
	function setSibling(objSibling, s){
		if (objSibling){
			if (objSibling.id.indexOf('pipe') != -1){
				objSibling.className = s;
			}
		}
	}
	function showMenu(sID){
		var iID = getNumber(sID);
		if (activefirstlevel != -1){
			document.getElementById('firstlink' + activefirstlevel).className = 'firstOver';
			if (iID != activefirstlevel){
				document.getElementById('second' + activefirstlevel).className = 'secondlevelDiv';
				document.getElementById('first' + activefirstlevel).className = 'firstLevelSelOff';
			}
		}
		var objParent = document.getElementById('first' + iID);
		var objChild = document.getElementById('second' + iID);
		objParent.className = 'firstLevelOver';
		document.getElementById('firstlink' + iID).className = 'firstOver';
		objChild.className = 'secondlevelDivShow';
		objChild.style.left = 30;
		objChild.style.top = (document.getElementById('tblLayer2Background').offsetTop - 10);
		previousPipe(objParent, 'pipeOver');
		nextPipe(objParent, 'pipeOver');
	}
	function hideMenu(sID){		
		var iID = getNumber(sID);		
		if (iID != activefirstlevel){
			document.getElementById('first' + iID).className = 'firstLevelOff';
			document.getElementById('firstlink' + iID).className = 'first';
			document.getElementById('second' + iID).className = 'secondlevelDiv';
			previousPipe(document.getElementById('first' + iID), 'pipe');
			nextPipe(document.getElementById('first' + iID), 'pipe');
		}
		if (activefirstlevel != -1){
			document.getElementById('first' + activefirstlevel).className = 'firstLevelOver';
			document.getElementById('second' + activefirstlevel).className = 'secondlevelDivShow';
			previousPipe(document.getElementById('first' + activefirstlevel), 'pipeOver');
			nextPipe(document.getElementById('first' + activefirstlevel), 'pipeOver');
		}		
	}
	function innit(){		
		if (activefirstlevel > -1){
			showMenu('first' + activefirstlevel);
			if (activesecondlevel != -1){
				document.getElementById('second' + activefirstlevel + '-' + activesecondlevel).className = 'secondlevelSel';
			}
		}
	}
	function resetChildTop(){
		if (document.getElementById('second' + activefirstlevel)){
			document.getElementById('second' + activefirstlevel).style.top = (document.getElementById('tblLayer2Background').offsetTop - 10);
		}
	}

/**
 * List functions allow exanding/collapsing long lists on mouse click. To use them we have to prefix all expandable
 * items with LIST_PREFIX-realID. All list titles (where user would click the mouse) need to have the id={LIST_PREFIX}-realID-title.
 * Define LIST_PREFIX, and call initLists() in your code to enable this feature.
 */
//define images for expanded and collapsed states
var strImageExpanded = "<img alt=\"Click to collapse\" hspace=\"1\" border=\"0\" src=\"/img/minus.gif\"/>"
var strImageCollapsed = "<img alt=\"Click to expand\" hspace=\"1\" border=\"0\" src=\"/img/plus.gif\"/>"
/**
 * The Lists have to be wrapped in a div having id starting with globally defined variable: LIST_PREFIX
 */
function initLists()
{
	if (!LIST_PREFIX) return;
	changeLists(LIST_PREFIX, null);
}
/**
 * Depending on action parameter, this function locates all elements prefixed with idPrefix and 
 * its' title ( element with id {idPrefix}-title ).
 * If action is null (called on init) it defines variable expanded on divs, and attaches image and onclick event on title.
 *
 * @param idPrefix - prefix of the div id containing the list (  is the name of the title
 * @param action - string containing "expand", "collapse" or null.
 * 
 */
function changeLists(idPrefix, action)
{
	if (!idPrefix) return;
	var allDivElements = document.getElementsByTagName("div");
	if (allDivElements == null) allDivElements = document.all;
	if (!allDivElements) return;
	//attach onmouse event and collapse as default
	for (var i=0; i<allDivElements.length; i++)
	{
		var id= allDivElements[i].id;
		if (id.indexOf(idPrefix) == 0)
		{
			//find the title element and add image to it
			var objTitle = document.getElementById(id+"-title");
			if (objTitle)
			{
				if (!action)
				{
					//define boolean variable expanded on divs
					allDivElements[i].expanded = true;
					objTitle.onclick=function() { toggleDiv(this); };
					objTitle.style.cursor = "pointer";
					collapseDiv(allDivElements[i], objTitle);
				}
				else if (action == "expand")
				{
					expandDiv(allDivElements[i], objTitle, true);
				}
				else if (action == "collapse")
				{
					collapseDiv(allDivElements[i], objTitle);
				}
			}
		}
	}
}
function toggleDiv(objTitle)
{
	var titleID = objTitle.id;
	//be on the "safe" side
	if (titleID.indexOf("title") < 6) return;
	var objDiv = document.getElementById(titleID.substring(0, titleID.length - 6));
	if (!objDiv) return;
	if (objDiv.expanded == true)
		collapseDiv(objDiv, objTitle);
	else
		expandDiv(objDiv, objTitle);
}
function expandDiv(objDiv, objTitle, bSkipCollapseAll)
{
	//collapse all lists first
	if (!bSkipCollapseAll)
		collapseAll();
	if (objDiv.expanded == true) return;
	//make the list visible
	objDiv.style.display = "block";
	objDiv.expanded = true;
	//change title image to expanded
	objTitle.innerHTML = strImageExpanded + " " + objTitle.innerHTML.substring(objTitle.innerHTML.indexOf("> ") + 2);
}
function collapseDiv(objDiv, objTitle)
{
	if (objDiv.expanded == false) return;
	//make items visible
	objDiv.style.display = "none";
	objDiv.expanded = false;
	//change image on the title
	if (objTitle.innerHTML.toLowerCase().indexOf("<img ") == -1)
		//just add the image
		objTitle.innerHTML = strImageCollapsed + " " + objTitle.innerHTML;
	else
		//change title image to collapsed
		objTitle.innerHTML = strImageCollapsed +" " + objTitle.innerHTML.substring(objTitle.innerHTML.indexOf("> ") + 2);
}
function collapseAll()
{
	changeLists(LIST_PREFIX, "collapse");
}
function expandAll()
{
	changeLists(LIST_PREFIX, "expand");
}
/**
 * End expandable/collapsable list functions
 */

