function highlight()
{
 var oObj = event.srcElement;
 oObj.style.color = '#ffffff' ;
}

function lolight()
{
 var oObj = event.srcElement;
  oObj.style.color = '#000000' ;
  oObj.style.textDecoration = "none" ;
}

function LogOut_onclick(CafeURL) {
location.href=CafeURL + '/Logout.asp'
}

function HelpWindow(PageName){
	newwin=window.open(PageName,"Help", "height=600, width=480, toolbar=no, menubar=no, scrollbars=yes,resizable=yes");
}

function NewWindow(PageName, WindowName){
	newwin=window.open(PageName, WindowName, "height=600, width=540, toolbar=no, menubar=no, scrollbars=yes, resizable=yes");
}

function JumpTo(url,confmsg)
{
	var theResponse = window.confirm(confmsg);
	if (theResponse) 
	{
		window.location=url
	}
}

function JumpToURL(url)
{
	window.location=url
}

//three spell checking functions for use with ieSpell:
//put the following on the button place:
//	<script language="JavaScript" type="text/javascript">checkspells();</script>

function checkspells() {
	try {
		var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
		document.write("&nbsp;<input type='button' name='btnSpell' value='Check Spelling' onclick='checkspell()'>");
		}
	catch(exception) {
	if (is_ie&&is_win) {
		document.write("&nbsp;<input type='button' name='btnSpell' value='Get ieSpell' onclick='checkspell()'>");
		}
	}
}

function forumcheckspells() {
	try {
		var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
		document.write("&nbsp;<img alt='Spellcheck' src='http://www.translatorscafe.com/cafe/megabbs/images/spellcheck.gif' align='top' name='spellcheck' onclick='checkspell()'>");
		}
	catch(exception) {
	if (is_ie&&is_win) {
		document.write("&nbsp;<img alt='Spellcheck' src='http://www.translatorscafe.com/cafe/megabbs/images/GetIESpell.gif' align='top' name='GetIESpell' onclick='checkspell()'>");
		}
	}
}

function checkspell() {
	try {
		var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
		tmpis.CheckAllLinkedDocuments(document);
	}
	catch(exception) {
		if (is_ie&&is_win) {
			window.open("http://www.iespell.com/download.php","DownLoad");
		}
	}
}

/* ie-activex fix taken from http://activecontent.blogspot.com/ */
var bo_ns_id = 0;

function ieFixStart()
{
  if(isIE())
  {
    document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
  }
}
function ieFixEnd()
{
  if(isIE())
  {
    document.write('</div>');
    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
    var theCode = theObject.innerHTML;
    theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"));
    document.write(theCode);
  }
}
function isIE()
{
  // only for Win IE 6+
  // But not in Windows 98, Me, NT 4.0, 2000
  var strBrwsr= navigator.userAgent.toLowerCase();
  if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0)
  {
    if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6)
    {
      return false;
    }
    if(strBrwsr.indexOf("win98") > -1 || strBrwsr.indexOf("win 9x 4.90") > -1 
      || strBrwsr.indexOf("winnt4.0") > -1 || strBrwsr.indexOf("windows nt 5.0") > -1)
    {
      return false;
    }
    return true;
  }
  else
  {
    return false;
  }
}
/* end of ie activex fix */

function hideElement (id) {
	var o = document.getElementById (id);
	if (o) {
		o.style.display = "none";
	}
}

window.onload = function () {
  document.body.onclick = uiHideMenu;
}

var gUiMenu = null;

function uiHideMenu () {
  if (gUiMenu) {
    gUiMenu.style.display = "none";
  }  
}

function uiSelectLng (link, e, isRtl) {

  if (!e) var e = window.event;
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
  uiHideMenu ();

  var mnu = document.getElementById ("uilSelector");
  
  if (mnu) {
    mnu.style.display = "block";

    var eBody = document.body;
    var nWindowHeight = (window.innerHeight != null)? window.innerHeight : eBody.clientHeight;
    var nWindowWidth = (window.innerWidth != null)? window.innerWidth : eBody.clientWidth;
    var top = uiGetElementTop (link) + link.offsetHeight;
    var left;

    if (isRtl) {
      left = uiGetElementLeft (link) - (mnu.offsetWidth - link.offsetWidth);
    }
    else {
      left = uiGetElementLeft (link);
    }
    
    mnu.style.top = top + "px";
    mnu.style.left = left + "px";

    gUiMenu = mnu;
  }
}

function uiGetElementTop (eElement) {
	// based on http://www.webreference.com/dhtml/diner/realpos1/index.html (originaly DL_GetElementTop())
		var nTopPos = eElement.offsetTop;        
		var eParElement = eElement.offsetParent; 
		while (eParElement != null)	{
				nTopPos += eParElement.offsetTop;
				eParElement = eParElement.offsetParent;
		}
		return nTopPos;
}

function uiGetElementLeft (eElement) {
	// based on http://www.webreference.com/dhtml/diner/realpos1/index.html (originaly DL_GetElementTop())
		var nLeftPos = eElement.offsetLeft;        
		var eParElement = eElement.offsetParent; 
		while (eParElement != null)	{
				nLeftPos += eParElement.offsetLeft;
				eParElement = eParElement.offsetParent;
		}
		return nLeftPos;
}

function tcLoadXml (url, fptr) {
  // branch for native XMLHttpRequest object
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    req.onreadystatechange = fptr;
    req.open ("GET", url, true);
    req.send(null);
  // branch for IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req) {
      req.onreadystatechange = fptr;
      req.open("GET", url, true);
      req.send();
    }
  }
}

function pausecomp(Delay) 
{
	// Delay in milliseconds
	var date = new Date();
	var CurDate = null;

	do { CurDate = new Date(); } 
	while(CurDate - date < Delay);
}

/* String concatenation by Lasse Reichstein Nielsen. */
function StringBuilder() {
  this.buffer = [];
}

StringBuilder.prototype.append = function append(string) {
  this.buffer.push(string);
  return this;
};

StringBuilder.prototype.toString = function toString() {
  return this.buffer.join("");
};

/* Text insertion */
var tcTextCursor = 0;
var tcTextField;
var tcTextCounter = new TextCounterFunction ();

function TextCounterFunction() {
  this.pointer = null;
  this.outputId = "";
  this.limit = 0;
}

// Track cursor position
function textPosition(o, pt, cntId, cntMax) {
  tcTextField = o;
  tcTextCounter.pointer = pt;
  tcTextCounter.outputId = cntId;
  tcTextCounter.limit = cntMax;
  if (!document.selection) { tcTextCursor = o.selectionStart; }
}

function textInsert(text) {

  if (!tcTextField) { return; }

  // Except Opera
  if (navigator.userAgent.indexOf('Opera') == -1) { tcTextField.focus(); }

  // IE, Opera
  if (document.selection) {
    document.selection.createRange().text = text;
  }

  // FireFox, Mozilla
  else {
    // Split text on cursor position
    var strFirst = tcTextField.value.substr(0, tcTextCursor);
    var strEnd = tcTextField.value.substr(tcTextCursor, tcTextField.value.length);
    var num = 0;
    if (strFirst == '') { num = 1; }
    // Insert the text
    tcTextField.value = strFirst + text + strEnd;
    // New cursor position
    tcTextCursor = strFirst.length + text.length + num;
    // Set cursor after the text
    tcTextField.selectionStart = tcTextField.selectionEnd = tcTextCursor;
  }

  if (tcTextCounter.pointer) {
    tcTextCounter.pointer (tcTextField, tcTextCounter.outputId, tcTextCounter.limit);
  }
}
