function Switch(SwitchContent,SwitchNav) {
//	var content=new Array("switch-one","switch-two","switch-three","switch-four","switch-five");
//	var nav=new Array("switch-nav-one","switch-nav-two","switch-nav-three","switch-nav-four","switch-nav-five");
	var content=new Array("switch-one","switch-two","switch-three","switch-four");
	var nav=new Array("switch-nav-one","switch-nav-two","switch-nav-three","switch-nav-four");
	for (i=0; i < content.length; i++) {
	temp=document.getElementById(nav[i]);
	if (SwitchNav == nav[i]) {
		temp.className='current-yes';
	}else{
		temp.className='current-no';
	}
	}
	for (i=0; i < content.length; i++) {
	temp=document.getElementById(content[i]);
	if (SwitchContent == content[i]) {
		temp.style.display='block';
	}else{
		temp.style.display='none';
	}
	}
}

function SwitchDocs(SwitchContent,SwitchNav) {
//	var content=new Array("switch-one","switch-two","switch-three","switch-four","switch-five");
//	var nav=new Array("switch-nav-one","switch-nav-two","switch-nav-three","switch-nav-four","switch-nav-five");
	var content=new Array("switch-one","switch-two");
	var nav=new Array("switch-nav-one","switch-nav-two");
	for (i=0; i < content.length; i++) {
	temp=document.getElementById(nav[i]);
	if (SwitchNav == nav[i]) {
		temp.className='current-yes';
	}else{
		temp.className='current-no';
	}
	}
	for (i=0; i < content.length; i++) {
	temp=document.getElementById(content[i]);
	if (SwitchContent == content[i]) {
		temp.style.display='block';
	}else{
		temp.style.display='none';
	}
	}
}

function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}
function countRows() {
	tables = document.getElementsByTagName('table');
	for(i=0; i<tables.length; i++) {
		if(tables[i].id.search(/count/) != -1) {
			rows = tables[i].getElementsByTagName('tr');
			fives = parseInt((rows.length - 1) / 5);
			toggleContainer = tables[i].getElementsByTagName('caption')[0];
			if(fives > 1) {
				for(i2=6; i2<rows.length; i2++) {
					rows[i2].className = 'hide';
				}
				for(i3=1; i3 <= fives; i3++) {
					thisFive = i3 * 5;
					toggleContainer.innerHTML = toggleContainer.innerHTML + '&nbsp;<a href="#">' + thisFive + '</a>';
				}
				if((rows.length - 1) > (fives * 5)) {
					toggleContainer.innerHTML = toggleContainer.innerHTML + '&nbsp;View All <a href="#">' + (rows.length - 1) + '</a> Rows';
				}
				if(toggleContainer.getElementsByTagName('a').length > 0) {
					for(i4=0; i4<toggleContainer.getElementsByTagName('a').length; i4++) {
						toggleContainer.getElementsByTagName('a')[i4].onclick = toggleRows;
						if(i4 == 0) {
							toggleContainer.getElementsByTagName('a')[i4].className = 'current-row';
						}
					}
				}
			}

		}
	}
}
function toggleRows() {
	tables = document.getElementsByTagName('table');
	displayNum = parseInt(this.innerHTML);
	for(i=0; i < tables.length; i++) {
		tableAnchors = tables[i].getElementsByTagName('a');
		for(i2=0; i2 < tableAnchors.length; i2++) {
			if(tableAnchors[i2] == this) {
				this.className = 'current-row';
				thisTable = tables[i];
				tableRows = thisTable.getElementsByTagName('tr');
				for(i3=0; i3 < tableRows.length; i3++) {
					if(i3 <= displayNum) {
						tableRows[i3].className = '';
					}else{
						tableRows[i3].className = 'hide';
					}
				}
			}
		}
	}
	anchors = thisTable.getElementsByTagName('a');
	for(i3=0; i3 < anchors.length; i3++) {
		if(anchors[i3].className == 'current-row' && anchors[i3] != this) {
			anchors[i3].className = '';
		}
	}
	return false;
}

function newWin(media) {
mediaWindow = window.open(media,
'mediaWin', 'scrollbars=yes,status=yes,width=600,height=400,resizable=yes');
window.mediaWindow.focus( );
}

function openNote(media) {
mediaWindow = window.open(media,
'secondWindow', 'menubar=yes,toolbar=no,scrollbars=yes,status=no,width=750,height=550,resizable=yes');
window.mediaWindow.focus( );
}


function openGloss(media) {

    AW = screen.availWidth;
	AH = screen.availHeight;
	mT=(AH-500)/2;
	mL=(AW-700)/2;
	mediaWindow = window.open(media,'secondWindow',
							  'screenX='+ mT +'screenY=' + mL + 'menubar=no,toolbar=no,scrollbars=yes,status=no,width=600,height=650,resizable=yes'
							  );
	window.mediaWindow.focus( );
}


function popUPwindow(URL,menu,toolbar,scrl,status,w,h,resizable) {
	AW = screen.availWidth;
	AH = screen.availHeight;
	if(!w){w=655;}
	if(!h){h=460;}
	if(!scrl){scrl=0;}
	if(!menu){menu=1;}
	if(!resizable){resizable=1;}
	if(!toolbar) {toolbar=1;}
	if(!status) {status=1;}
	mT=(AH-h)/2;
	mL=(AW-w)/2;
	var props = 'scrollbars='+scrl+',height='+h+',width='+w+',screenX='+mT+',screenY='+mL+',top='+mT+',left='+mL+',menubar='+menu+',resizable=' + resizable + ',tloolbar=' + toolbar + ',status=' + status;
	hndl=window.open(URL, "WnNm" , props);
}

//displays message window that the function is not available
function msgWind(){
var newWind, message
        newWind=window.open("", "Message", 'width=200,height=120,menubar=no,resizable=no,scrollbars=no,left=100px,top=100px')
        message="<title>Message</title><font face='Arial' size='3'>This function is not available on this screen.</font><br><br><br><a href='javascript:onclick=self.close()'><img align='right' src='/img/mcfa/closebtn.gif' border='0'></a>"
        newWind.document.write(message)
        newWind.document.close()
        newWind.focus()
}

function CheckAnswer(container,limit) {
	var q = document.getElementById(container);
	var children = q.childNodes;
	var ShowIncorrect = "no";
	for(var i=0; i < children.length; i++) {
		var c = children[i];
		if(c.className=="correct" && c.checked==0 || c.className=="incorrect" && c.checked==1) {
			var ShowIncorrect = "yes";
		}
		if(c.className=="message-counter") {
			var counter = c.value;
			if(counter=="start") {
				c.value = 1;
			}else{
				c.value = counter++;
			}
		}
		if(c.className=="message-incorrect") {
			var incorrectMessage = c;
		}
		if(c.className=="message-correct") {
			var correctMessage = c;
		}
		if(c.className=="message-limit") {
			var limitMessage = c;
		}
	}
	if(ShowIncorrect == "yes") {
		incorrectMessage.style.display="block";
		correctMessage.style.display="none";
	}else{
		incorrectMessage.style.display="none";
		correctMessage.style.display="block";
	}
	if(limitMessage != null) {
		if(counter == limit && ShowIncorrect=="yes") {
			correctMessage.style.display="none";
			incorrectMessage.style.display="none";
			limitMessage.style.display="block";		
		}
		if(counter == limit || ShowIncorrect!="yes") {
			var qInputs = q.getElementsByTagName("input");
			for (i=0; i < qInputs.length; i++) {
				qInputs[i].disabled="yes";
			}
			for(var i=0; i < children.length; i++) {
				var c = children[i];
				if(c.className == "correct") {
					c.checked=1;
				}else if(c.className == "incorrect") {
					c.checked=0;
				}else if(c.className == "label-correct") {
					c.style.color="#009900";
					c.style.fontWeight='bold';
				}
			}	
		}
	}
}

function SelectAnswer(ThisElement,ThisAnswer) {
	mycontainer=document.getElementById(ThisElement);
	containers=document.getElementsByTagName("div");
	formElement=document.getElementById(ThisAnswer);
	if(formElement.type == "radio") {
		for (i=0; i < containers.length; i++) {
			if (containers[i].className=='focus'){
				containers[i].className="none";
			}
		}
		mycontainer.className="focus";
		formElement.checked="yes";
	}else{
		if(formElement.checked!="") {
			formElement.checked="";
			mycontainer.className="no-focus";
		}else{
			formElement.checked="yes";
			mycontainer.className="focus";
		}
	}
}

/* JAVASCRIPT CODE FOR SORTING TABLES USING THE COLUMN HEADINGS */



var SORT_COLUMN_INDEX;

function sortables_init() {
    // Find all tables with class sortable and make them sortable
    if (!document.getElementsByTagName) return;
    tbls = document.getElementsByTagName("table");
    for (ti=0;ti<tbls.length;ti++) {
        thisTbl = tbls[ti];
        if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
            //initTable(thisTbl.id);
            ts_makeSortable(thisTbl);
        }
    }
}

function ts_makeSortable(table) {
    if (table.rows && table.rows.length > 0) {
        var firstRow = table.rows[0];
    }
    if (!firstRow) return;
    
    // We have a first row: assume it's the header, and make its contents clickable links
    for (var i=0;i<firstRow.cells.length;i++) {
        var cell = firstRow.cells[i];
        var txt = ts_getInnerText(cell);
        cell.innerHTML = '<a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'+txt+'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a>';
    }
}

function ts_getInnerText(el) {
	if (typeof el == "string") return el;
	if (typeof el == "undefined") { return el };
	if (el.innerText) return el.innerText;	//Not needed but it is faster
	var str = "";
	
	var cs = el.childNodes;
	var l = cs.length;
	for (var i = 0; i < l; i++) {
		switch (cs[i].nodeType) {
			case 1: //ELEMENT_NODE
				str += ts_getInnerText(cs[i]);
				break;
			case 3:	//TEXT_NODE
				str += cs[i].nodeValue;
				break;
		}
	}
	return str;
}

function ts_resortTable(lnk) {
    // get the span
    var span;
    for (var ci=0;ci<lnk.childNodes.length;ci++) {
        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
    }
    var spantext = ts_getInnerText(span);
    var td = lnk.parentNode;
    var column = td.cellIndex;
    var table = getParent(td,'TABLE');
    
    // Work out a type for the column
    if (table.rows.length <= 1) return;
    var itm = ts_getInnerText(table.rows[1].cells[column]);
    sortfn = ts_sort_caseinsensitive;
    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
    if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
	if (itm.match(/^[\d\.]+%/)) sortfn = ts_sort_numeric;
	if (itm.match(/^[\d\.]+/)) sortfn = ts_sort_numeric;
    SORT_COLUMN_INDEX = column;
    var firstRow = new Array();
    var newRows = new Array();
    for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
    for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }

    newRows.sort(sortfn);

    if (span.getAttribute("sortdir") == 'down') {
        ARROW = '&uarr;';
        newRows.reverse();
        span.setAttribute('sortdir','up');
    } else {
        ARROW = '&darr;';
        span.setAttribute('sortdir','down');
    }
    
    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
    // don't do sortbottom rows
    for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);}
    // do sortbottom rows only
    for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);}
    
    // Delete any other arrows there may be showing
    var allspans = document.getElementsByTagName("span");
    for (var ci=0;ci<allspans.length;ci++) {
        if (allspans[ci].className == 'sortarrow') {
            if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                allspans[ci].innerHTML = '&nbsp;&nbsp;&nbsp;';
            }
        }
    }
        
    span.innerHTML = ARROW;
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}
function ts_sort_date(a,b) {
    // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa.length == 10) {
        dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
    } else {
        yr = aa.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
    }
    if (bb.length == 10) {
        dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
    } else {
        yr = bb.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
    }
    if (dt1==dt2) return 0;
    if (dt1<dt2) return -1;
    return 1;
}

function ts_sort_currency(a,b) { 
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    return parseFloat(aa) - parseFloat(bb);
}

function ts_sort_numeric(a,b) { 
    aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
    if (isNaN(aa)) aa = 0;
    bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); 
    if (isNaN(bb)) bb = 0;
    return aa-bb;
}

function ts_sort_caseinsensitive(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}

function ts_sort_default(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}


function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 



// SORTING TABLE COLUMNS
var gblReverseSort		= 1;
var gblShowRanks		= 1;
var gblDefaultColumn	= -1;
var gblMakePretty		= true;

function sortables_init() {
    // Find all tables with class sortable and make them sortable
    if (!document.getElementsByTagName) return;
    tbls = document.getElementsByTagName("table");
    for (ti=0;ti<tbls.length;ti++) {
        thisTbl = tbls[ti];
        if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
            ts_makeSortable(thisTbl);
		} else {
			if(gblMakePretty){
				makePretty(thisTbl.getElementsByTagName('tbody')[0],-1,gblDefaultColumn);
			}
		}
    }
}

function ts_makeSortable(table) {
	var tblEl = table.getElementsByTagName('tbody')[0];
	if(gblMakePretty){
		makePretty(tblEl,-1,gblDefaultColumn);
	}

	if (table.rows && table.rows.length > 0) {
        var firstRow = table.rows[0];
    }
    if (!firstRow) return;
    // We have a first row: assume it's the header, and make its contents clickable links
    for (var i=0;i<firstRow.cells.length;i++) {
        var cell = firstRow.cells[i];
		if(cell.className == 'sortColumn'){
			var txt = getTextValue(cell);
			var linkURL = window.location;
			if(cell.title.length)
				linkURL = linkURL + '&amp;sortby='+cell.title;
			else
				linkURL = linkURL + '#';
			cell.innerHTML = '<a href="'+linkURL+'" class="sortheader" onclick="ts_resortTable(this);return false;">'+txt+'<span class="sortarrow">&nbsp;</span></a>';
		}
    }

}

function ts_resortTable(lnk) {
    // get the span
    var span;
    for (var ci=0;ci<lnk.childNodes.length;ci++) {
        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
    }
    var spantext = getTextValue(span);
    var td = lnk.parentNode;
    var column = td.cellIndex;
    var table = getParent(td,'TABLE');
    
	ARROW = '';
	if (span.getAttribute("sortdir") == 'down') {
        ARROW = '&uarr;';
        //newRows.reverse();
        span.setAttribute('sortdir','up');
    } else {
        ARROW = '&darr;';
        span.setAttribute('sortdir','down');
    }
    // Delete any other arrows there may be showing
    var allspans = document.getElementsByTagName("span");
    for (var ci=0;ci<allspans.length;ci++) {
        if (allspans[ci].className == 'sortarrow') {
            if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                allspans[ci].innerHTML = '&nbsp;';
            }
        }
    }
    span.innerHTML = ARROW;
	sortTable(table, column, gblReverseSort, gblDefaultColumn, gblShowRanks, gblMakePretty);
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}

function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 



//-----------------------------------------------------------------------------
// sortTable(id, col, rev, nmc, rank)
//
//  id  - ID of the TABLE, TBODY, THEAD or TFOOT element to be sorted.
//  col - Index of the column to sort, 0 = first column, 1 = second column,
//        etc.
//  rev - If true, the column is sorted in reverse (descending) order
//        initially.
//  nmc - Index of the "name" column.  0=first column, 1=second column, etc...
//	rnk - If true, the first column (0) is a rank column and we need to calculate
//		  the rows overall ranking for the current sort column.
//
// Note: the name column (index 0 or 1) is used as a secondary sort column and
// always sorted in ascending order. If rank col exists then index is 1 else 0.
//-----------------------------------------------------------------------------

function sortTable(table, col, rev, nmc, rnk, mp) {
  // Get the table or table section to sort.
   //var tblEl = document.getElementById(id);
	var tblEl = table.getElementsByTagName('tbody')[0];
	

  // The first time this function is called for a given table, set up an
  // array of reverse sort flags.
  if (tblEl.reverseSort == null) {
    tblEl.reverseSort = new Array();
  }

  // If this column has not been sorted before, set the initial sort direction.
  if (tblEl.reverseSort[col] == null)
    tblEl.reverseSort[col] = rev;

  // If this column was the last one sorted, reverse its sort direction.
  if (col == tblEl.lastColumn){
    tblEl.reverseSort[col] = !tblEl.reverseSort[col];
  }

  // Remember this column as the last one sorted.
  tblEl.lastColumn = col;

  // Set the table display style to "none" - necessary for Netscape 6 
  // browsers.
  var oldDsply = tblEl.style.display;
  tblEl.style.display = "none";

  // Sort the rows based on the content of the specified column using a
  // selection sort.

  var tmpEl;
  var i, j;
  var minVal, minIdx;
  var testVal;
  var cmp;
  for (i = 0; i < tblEl.rows.length - 1; i++) {
    // Assume the current row has the minimum value.
    minIdx = i;
    minVal = getTextValue(tblEl.rows[i].cells[col]);

    // Search the rows that follow the current one for a smaller value.
    for (j = i+1; j < tblEl.rows.length; j++) {
      testVal = getTextValue(tblEl.rows[j].cells[col]);
      cmp = compareValues(minVal, testVal);
      // Negate the comparison result if the reverse sort flag is set.
      if (tblEl.reverseSort[col])
        cmp = -cmp;
      // Sort by the each consecutive column until we find one that isnt equal or we run out of columns
	  if (cmp == 0 && col != nmc){
		for(var coli = 0; coli < tblEl.rows[j].cells.length; coli++){
			if (coli != col)
			{
				cmp = compareValues(getTextValue(tblEl.rows[minIdx].cells[coli]),
                    getTextValue(tblEl.rows[j].cells[coli]));
				
				if(cmp!=0)
					break;
			}
		}
		
	  }
      // If this row has a smaller value than the current minimum, remember its
      // position and update the current minimum value.
      if (cmp > 0) {
        minIdx = j;
        minVal = testVal;
      }
    }

    // By now, we have the row with the smallest value. Remove it from the
    // table and insert it before the current row.
    if (minIdx > i) {
      tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
      tblEl.insertBefore(tmpEl, tblEl.rows[i]);
    }
  }

  // Make it look pretty.
  if(mp){
  makePretty(tblEl, col, nmc);
  }

  // Restore the table's display style.
  tblEl.style.display = oldDsply;

  return false;
}

//-----------------------------------------------------------------------------
// Functions to get and compare values during a sort.
//-----------------------------------------------------------------------------

// This code is necessary for browsers that don't reflect the DOM constants
// (like IE).
if (document.ELEMENT_NODE == null) {
  document.ELEMENT_NODE = 1;
  document.TEXT_NODE = 3;
}

function getTextValue(el) {
  var i;
  var s;
  // Find and concatenate the values of all text nodes contained within the
  // element.
  s = "";
  try{
	  for (i = 0; i < el.childNodes.length; i++)
		if (el.childNodes[i].nodeType == document.TEXT_NODE)
		  s += el.childNodes[i].nodeValue;
		else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
				 el.childNodes[i].tagName == "BR")
		  s += " ";
		else
		  // Use recursion to get text within sub-elements.
		  s += getTextValue(el.childNodes[i]);
  }catch(err){}
  return normalizeString(s);
}

function compareValues(p1, p2) {
  var v1, v2;
  var f1, f2;

  var compVal = -1;

  v1=p1;
  v2=p2;

  // If the values are dates, convert them to date objects.
  f1 = new Date(v1);
  f2 = new Date(v2);
  if (!isNaN(f1) && !isNaN(f2)) {
    v1 = f1;
    v2 = f2;
  }

  // If the values are floats, convert them to float objects.
  if(v1==p1){
	  f1 = parseFloat(v1);
	  f2 = parseFloat(v2);
	  if (!isNaN(f1) && !isNaN(f2)) {
		v1 = f1;
		v2 = f2;
	  }
  }
  
  // If the values are currency, convert them to float objects.
  if(v1==p1){
	  f1 = parseCurrency(v1);
	  f2 = parseCurrency(v2);
	  if (!isNaN(f1) && !isNaN(f2)) {
		v1 = f1;
		v2 = f2;
	  }
  }

  // Compare the two values.
  if (v1 == v2)
	compVal = 0;
  if (v1 > v2)
	compVal = 1

	return compVal;
}

function parseCurrency(vS){
	// returns a currency string back as a float
	var currency = vS;
	if(isValid(vS,'Currency')){
		var cleanRegex = '[^0-9\.]';
		var reClean = new RegExp(cleanRegex,'gi');
		currency = vS.toString().replace(reClean,"");
	}
	currency = parseFloat(currency);

	return currency;
}

var valid = new Object();
	// REGEX Elements
	// matches zip codes
	valid.zipCode = /\d{5}(-\d{4})?/;
	// matches $17.23 or $14,281,545.45 or ...
	valid.Currency = /\$\d{1,3}(,\d{3})*\.\d{2}/;
	// matches 5:04 or 12:34 but not 75:83
	valid.Time = /^([1-9]|1[0-2]):[0-5]\d$/;
	//matches email
	valid.emailAddress = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
	// matches phone ###-###-####
	valid.phoneNumber = /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/;
	// International Phone Number
	valid.phoneNumberInternational = /^\d(\d|-){7,20}/;
	// IP Address
	valid.ipAddress = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
	// Date xx/xx/xxxx
	valid.Date = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
	// State Abbreviation
	valid.State = /^(AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NB|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i;
	// Social Security Number
	valid.SSN = /^\d{3}\-\d{2}\-\d{4}$/;

function isValid(vString,vType){
	var thePat = valid[vType]; 
	return thePat.exec(vString); 
}
// Regular expressions for normalizing white space.
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");

function normalizeString(s) {

  s = s.replace(whtSpMult, " ");  // Collapse any multiple whites space.
  s = s.replace(whtSpEnds, "");   // Remove leading or trailing white space.

  return s;
}

//-----------------------------------------------------------------------------
// Functions to update the table appearance after a sort.
//-----------------------------------------------------------------------------

// Style class names.
var rowClsNm = "alternateRow";
var colClsNm = "sortedColumn";

// Regular expressions for setting class names.
var rowTest = new RegExp(rowClsNm, "gi");
var colTest = new RegExp(colClsNm, "gi");

function makePretty(tblEl, col, nmc) {

  var i, j, namecol;
  var rowEl, cellEl;

  
	
  // Set style classes on each row to alternate their appearance.
  for (i = 0; i < tblEl.rows.length; i++) {
   rowEl = tblEl.rows[i];
   rowEl.className = rowEl.className.replace(rowTest, "");
    if (i % 2 != 0)
      rowEl.className += " " + rowClsNm;
    rowEl.className = normalizeString(rowEl.className);
    // Set style classes on each column (other than the name column) to
    // highlight the one that was sorted.
    for (j = 0; j < tblEl.rows[i].cells.length; j++) {
		  cellEl = rowEl.cells[j];
		  cellEl.className = cellEl.className.replace(colTest, "");
		  if (j == col)
			cellEl.className += " " + colClsNm;
		  cellEl.className = normalizeString(cellEl.className);
	  }
  }

  // Find the table header and highlight the column that was sorted.
  var el = tblEl.parentNode.tHead;
  if(el){
	  rowEl = el.rows[el.rows.length - 1];
	  // Set style classes for each column as above.
	  for (i = 0; i < rowEl.cells.length; i++) {
		cellEl = rowEl.cells[i];
		cellEl.className = cellEl.className.replace(colTest, "");
		// Highlight the header of the sorted column.
		/*if (i == col)
		  cellEl.className += " " + colClsNm;
		  cellEl.className = normalizeString(cellEl.className);
		  */
	  }
  }
}

//###################################################

/**
 * This array is used to remember mark status of rows in browse mode  */ var marked_row = new Array;

/**
 * enables highlight and marking of rows in data tables
 *
 */
function PMA_markRowsInit() {
    // for every table row ...
	var rows = document.getElementsByTagName('tr');
	for ( var i = 0; i < rows.length; i++ ) {
	    // ... with the class 'odd' or 'even' ...
		if ( 'odd' != rows[i].className && 'even' != rows[i].className ) {
		    continue;
		}
	    // ... add event listeners ...
        // ... to highlight the row on mouseover ...
	    if ( navigator.appName == 'Microsoft Internet Explorer' ) {
	        // but only for IE, other browsers are handled by :hover in css
			rows[i].onmouseover = function() {
			    this.className += ' hover';
			}
			rows[i].onmouseout = function() {
			    this.className = this.className.replace( ' hover', '' );
			}
	    }
        // ... and to mark the row on click ...
		rows[i].onmousedown = function() {
		    var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'input' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
		        return;
		    }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
			    this.className += ' marked';
            } else {
			    this.className = this.className.replace(' marked', '');
            }

            if ( checkbox && checkbox.disabled == false ) {
                checkbox.checked = marked_row[unique_id];
            }
		}

		// ... and disable label ...
		var labeltag = rows[i].getElementsByTagName('label')[0];
		if ( labeltag ) {
		    labeltag.onclick = function() {
		        return false;
		    }
	    }
	    // .. and checkbox clicks
		var checkbox = rows[i].getElementsByTagName('input')[0];
		if ( checkbox ) {
		    checkbox.onclick = function() {
		        // opera does not recognize return false;
		        this.checked = ! this.checked;
		    }
	    }
	}
}
window.onload=PMA_markRowsInit;

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function markAllRows( container_id ) {
	var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

	for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
	    }
	}

	return true;
}

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function unMarkAllRows( container_id ) {
	var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

	for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
	}

	return true;
}

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not  */ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) {
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
    if (theAction == "over" || theAction == "click") {
        theRow.style.cursor='pointer';
    } else {
        theRow.style.cursor='default';
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

/*
 * Sets/unsets the pointer and marker in vertical browse mode
 *
 * @param   object    the table row
 * @param   integer   the column number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 *
 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)  */ function setVerticalPointer(theRow, theColNum, theAction, theDefaultColor1, theDefaultColor2, thePointerColor, theMarkColor) {
    var theCells = null;
    var tagSwitch = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    if (typeof(document.getElementsByTagName) != 'undefined') {
        tagSwitch = 'tag';
    } else if (typeof(document.getElementById('table_results')) != 'undefined') {
        tagSwitch = 'cells';
    } else {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (tagSwitch == 'tag') {
        theRows     = document.getElementById('table_results').getElementsByTagName('tr');
        theCells    = theRows[1].getElementsByTagName('td');
    } else if (tagSwitch == 'cells') {
        theRows     = document.getElementById('table_results').rows;
        theCells    = theRows[1].cells;
    }

    // 3. Gets the current color...
    var rowCnt         = theRows.length;
    var domDetect      = null;
    var currentColor   = null;
    var newColor       = null;

    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[theColNum].getAttribute) != 'undefined') {
        currentColor = theCells[theColNum].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        domDetect    = false;
        currentColor = theCells[theColNum].style.backgroundColor;
    } // end 3

    var c = null;

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor1.toLowerCase()
        || currentColor.toLowerCase() == theDefaultColor2.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        } else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theColNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase() &&
             (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum]) || marked_row[theColNum] == false) {
            if (theAction == 'out') {
                if (theColNum % 2) {
                    newColor              = theDefaultColor1;
                } else {
                    newColor              = theDefaultColor2;
                }
            }
            else if (theAction == 'click' && theMarkColor != '') {
                newColor              = theMarkColor;
                marked_row[theColNum] = true;
            }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : ((theColNum % 2) ? theDefaultColor1 : theDefaultColor2);
            marked_row[theColNum] = false;
        }
    } // end 4

    // 5 ... with DOM compatible browsers except Opera

    for (c = 0; c < rowCnt; c++) {
        if (tagSwitch == 'tag') {
            Cells = theRows[c].getElementsByTagName('td');
        } else if (tagSwitch == 'cells') {
            Cells = theRows[c].cells;
        }

        Cell  = Cells[theColNum];

        // 5.1 Sets the new color...
        if (newColor) {
            if (domDetect) {
                Cell.setAttribute('bgcolor', newColor, 0);
            } else {
                Cell.style.backgroundColor = newColor;
            }
        } // end 5
    } // end for

     return true;
 } // end of the 'setVerticalPointer()' function

/**
 * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div)
 *
 * @param   string   container_id  the container id
 * @param   boolean  state         new value for checkbox (true or false)
 * @return  boolean  always true
 */
function setCheckboxes( container_id, state ) {
	var checkboxes = document.getElementById(container_id).getElementsByTagName('input');

	for ( var i = 0; i < checkboxes.length; i++ ) {
        if ( checkboxes[i].type == 'checkbox' ) {
            checkboxes[i].checked = state;
	    }
	}

	return true;
} // end of the 'setCheckboxes()' function


// added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
//   copy the checked from left to right or from right to left
//   so it's easier for users to see, if $cfg['ModifyAtRight']=true, what they've checked ;)
function copyCheckboxesRange(the_form, the_name, the_clicked) {
    if (typeof(document.forms[the_form].elements[the_name]) != 'undefined' && typeof(document.forms[the_form].elements[the_name + 'r']) != 'undefined') {
        if (the_clicked !== 'r') {
            if (document.forms[the_form].elements[the_name].checked == true) {
                document.forms[the_form].elements[the_name + 'r'].checked = true;
            }else {
                document.forms[the_form].elements[the_name + 'r'].checked = false;
            }
        } else if (the_clicked == 'r') {
            if (document.forms[the_form].elements[the_name + 'r'].checked == true) {
                document.forms[the_form].elements[the_name].checked = true;
            }else {
                document.forms[the_form].elements[the_name].checked = false;
            }
       }
    }
}

//////////  ###  Not needed at this time. 31 Jan 06.  ####  //////////
//
//// added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de> //  - this was directly written to each td, so why not a function ;) //  setCheckboxColumn(\'id_rows_to_delete' . $row_no . ''\'); function setCheckboxColumn(theCheckbox){
//    if (document.getElementById(theCheckbox)) {
//        document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);
//        if (document.getElementById(theCheckbox + 'r')) {
//            document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
//        }
//    } else {
//        if (document.getElementById(theCheckbox + 'r')) {
//            document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
//            if (document.getElementById(theCheckbox)) {
//                document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
//            }
//        }
//    }
//// }
//
//////////

/**
  * Checks/unchecks all options of a <select> element
  *
  * @param   string   the form name
  * @param   string   the element name
  * @param   boolean  whether to check or to uncheck the element
  *
  * @return  boolean  always true
  */
function setSelectOptions(the_form, the_select, do_check) {
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

    return true;
} // end of the 'setSelectOptions()' function

/**
  * Inserts multiple fields.
  *
  */
function insertValueQuery() {
    var myQuery = document.sqlform.sql_query;
    var myListBox = document.sqlform.dummy;

    if(myListBox.options.length > 0) {
    	sql_box_locked = true;
        var chaineAj = "";
        var NbSelect = 0;
        for(var i=0; i<myListBox.options.length; i++) {
            if (myListBox.options[i].selected){
                NbSelect++;
                if (NbSelect > 1)
                    chaineAj += ", ";
                chaineAj += myListBox.options[i].value;
            }
        }

        //IE support
        if (document.selection) {
            myQuery.focus();
            sel = document.selection.createRange();
            sel.text = chaineAj;
            document.sqlform.insert.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
            var startPos = document.sqlform.sql_query.selectionStart;
            var endPos = document.sqlform.sql_query.selectionEnd;
            var chaineSql = document.sqlform.sql_query.value;

            myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
        } else {
            myQuery.value += chaineAj;
        }
    	sql_box_locked = false;
    }
}

/**
  * listbox redirection
  */
function goToUrl(selObj, goToLocation) {
    eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'"); }

/**
 * getElement
 */
function getElement(e,f){
    if(document.layers){
        f=(f)?f:self;
        if(f.document.layers[e]) {
            return f.document.layers[e];
        }
        for(W=0;i<f.document.layers.length;W++) {
            return(getElement(e,fdocument.layers[W]));
        }
    }
    if(document.all) {
        return document.all[e];
    }
    return document.getElementById(e);
}

//#############################################

/* $Id: mcfa.js,v 1.15 2006/02/21 16:43:12 doakey Exp $ */


/**
 * Displays the Tooltips (hints), if we have some
 * 2005-01-20 added by Michael Keck (mkkeck)  */

var ttXpos = 0, ttYpos = 0;
var ttXadd = 10, ttYadd = -10;
var ttDisplay = 0, ttHoldIt = 0;
// Check if browser does support dynamic content and dhtml
var ttNS4 = (document.layers) ? 1 : 0;           // the old Netscape 4
var ttIE4 = (document.all) ? 1 : 0;              // browser wich uses document.all
var ttDOM = (document.getElementById) ? 1 : 0;   // DOM-compatible browsers
if (ttDOM) { // if DOM-compatible, set the others to false
    ttNS4 = 0;
    ttIE4 = 0;
}

var myTooltipContainer = null;

if ( (ttDOM) || (ttIE4) || (ttNS4) ) {
    // mouse-event
    if ( ttNS4 ) {
        document.captureEvents(Event.MOUSEMOVE);
    } else {
        document.onmousemove = mouseMove;
    }
}

/**
 * init the tooltip and write the text into it
 *
 * @param string theText tooltip content  */ function textTooltip(theText) {
    if	(ttDOM || ttIE4) {                   // document.getEelementById || document.all
        myTooltipContainer.innerHTML = "";  // we should empty it first
        myTooltipContainer.innerHTML = theText;
    } else if (ttNS4) {                     // document.layers
        var layerNS4 = myTooltipContainer.document;
        layerNS4.write(theText);
        layerNS4.close();
    }
}

/**
 * @var integer
 */
var ttTimerID = 0;

/**
 * swap the Tooltip // show and hide
 *
 * @param boolean stat view status
 */
function swapTooltip(stat) {
    if (ttHoldIt!=1) {
        if (stat!='default') {
            if (stat=='true')
                showTooltip(true);
            else if (stat=='false')
                showTooltip(false);
        } else {
            if (ttDisplay)
                ttTimerID = setTimeout("showTooltip(false);",500);
            else
                showTooltip(true);
        }
    } else {
        if (ttTimerID) {
           clearTimeout(ttTimerID);
           ttTimerID = 0;
        }
        showTooltip(true);
    }
}

/**
 * show / hide the Tooltip
 *
 * @param boolean stat view status
 */
function showTooltip(stat) {
    if (stat==false) {
        if (ttNS4)
            myTooltipContainer.visibility = "hide";
        else
            myTooltipContainer.style.visibility = "hidden";
        ttDisplay = 0;
    } else {
        if (ttNS4)
            myTooltipContainer.visibility = "show";
        else
            myTooltipContainer.style.visibility = "visible";
        ttDisplay = 1;
    }
}
/**
 * hold it, if we create or move the mouse over the tooltip  */ function holdTooltip() {
    ttHoldIt = 1;
    swapTooltip('true');
    ttHoldIt = 0;
}

/**
 * move the tooltip to mouse position
 *
 * @param integer posX    horiz. position
 * @param integer posY    vert. position
 */
function moveTooltip(posX, posY) {
    if (ttDOM || ttIE4) {
        myTooltipContainer.style.left	=	posX + "px";
        myTooltipContainer.style.top  =	posY + "px";
    } else if (ttNS4) {
        myTooltipContainer.left = posX;
        myTooltipContainer.top  = posY;
    }
}

/**
 * build the tooltip
 *
 * @param    string    theText    tooltip content
 */
function pmaTooltip( theText ) {
    // reference to TooltipContainer
    if ( null == myTooltipContainer ) {
        if (ttNS4) {
            myTooltipContainer = document.TooltipContainer;
        } else if (ttIE4) {
            myTooltipContainer = document.all('TooltipContainer');
        } else if (ttDOM) {
            myTooltipContainer = document.getElementById('TooltipContainer');
        } else {
            return;
        }

        if ( typeof( myTooltipContainer ) == 'undefined' ) {
            return;
        }
    }

    var plusX=0, plusY=0, docX=0, docY=0;
    var divHeight = myTooltipContainer.clientHeight;
    var divWidth  = myTooltipContainer.clientWidth;
    if (navigator.appName.indexOf("Explorer")!=-1) {
        if (document.documentElement && document.documentElement.scrollTop) {
            plusX = document.documentElement.scrollLeft;
            plusY = document.documentElement.scrollTop;
            docX = document.documentElement.offsetWidth + plusX;
            docY = document.documentElement.offsetHeight + plusY;
        } else {
            plusX = document.body.scrollLeft;
            plusY = document.body.scrollTop;
            docX = document.body.offsetWidth + plusX;
            docY = document.body.offsetHeight + plusY;
        }
    } else {
        docX = document.body.clientWidth;
        docY = document.body.clientHeight;
    }

    ttXpos = ttXpos + plusX;
    ttYpos = ttYpos + plusY;

    if ((ttXpos + divWidth) > docX)
        ttXpos = ttXpos - (divWidth + (ttXadd * 2));
    if ((ttYpos + divHeight) > docY)
        ttYpos = ttYpos - (divHeight + (ttYadd * 2));

    textTooltip(theText);
    moveTooltip((ttXpos + ttXadd), (ttYpos + ttYadd));
    holdTooltip();
}

/**
 * register mouse moves
 *
 * @param    event    e
 */
function mouseMove(e) {
    if ( typeof( event ) != 'undefined' ) {
        ttXpos = event.x;
        ttYpos = event.y;
    } else {
        ttXpos = e.pageX;
        ttYpos = e.pageY;
    }
}