	//moved from rightblock_dictionary 12.12.2007 - jw!
	var CursorLast = null;


	function Debug(_msg, _clean)
	{
		var debugfield = document.getElementById('jasonwiener_div_debug');
		if(debugfield == undefined)
		{
			debugfield = document.createElement('div');
			debugfield.setAttribute('style', 'border:1px solid #ccc;background:#fff;font-size:12px;width:400px;min-height:200px;padding:10px;');
			debugfield.setAttribute('id', 'jasonwiener_div_debug');
			document.getElementById('body').appendChild(debugfield);
		}
		
		if(_clean != undefined)
			debugfield.innerHTML = '';	

		debugfield.innerHTML += _msg + '<br>';
	}

	//moved from rightblock_notes 12.12.2007 - jw!
	function GetKeyCode(e){
		var keynum = -1;
		if(window.event){ // IE
			keynum = e.keyCode;
		}else if(e.which){ // Netscape/Firefox/Opera
			keynum = e.which;
		}
		return keynum;
	}

	//moved from rightblock_dictionary 12.12.2007 - jw!
	function SaveMousePosition(e){		
		position = getPosition(e);
		CursorLast = position;
	}

	//01.07.2008 - jw!
	function ClearField(_obj){
		_obj.value = '';
	}

	function getEventPosition(e) {
		if (!e) var e = window.event;
//		var relTarg = e.relatedTarget || e.fromElement;
//		e = e || window.event;

		var cursor = {x:0, y:0};
		if (e.pageX || e.pageY) {
			cursor.x = e.pageX;
			cursor.y = e.pageY;
		}else{
			var de = document.documentElement;
			var b = document.body;
			cursor.x = e.clientX + 
				(de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
			cursor.y = e.clientY + 
				(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
		}
		return cursor;
	}

	function getElementPosition(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}	
	
	
	function Goto(_loc){
		window.location.href = _loc;
	}

	function Signup(){
		Goto('/signup');
	}

	function Login(){
		Goto('/login');
	}

	function IsEnter(e){
		if(e != undefined)
		{
			var keynum = GetKeyCode(e);
			return (keynum == 13) ? true : false ;
		}
	}

	function IsNumeric(strString) {
		var strValidChars = "0123456789.-";
		var strChar;
		var blnResult = true;
	
		if(strString.length == 0) return false;
	
	   // test strString consists of valid characters listed above
		for(i = 0; i < strString.length && blnResult == true; i++){
			strChar = strString.charAt(i);
			if(strValidChars.indexOf(strChar) == -1){
				blnResult = false;
			}
		}
		return blnResult;
	}

	function trimAll(sString){
		return sString.trim();
	}

	function setCookie(c_name,value,expiredays){
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}

	function removeChildrenFromNode(_node)
	{
		if(_node == undefined || _node == null)
			return;

		while (_node.hasChildNodes())
		  _node.removeChild(_node.firstChild);
	}	
		
	String.prototype.trim = function() {
		return this.replace(/^\s+|\s+$/g,"");
	}
	String.prototype.ltrim = function() {
		return this.replace(/^\s+/,"");
	}
	String.prototype.rtrim = function() {
		return this.replace(/\s+$/,"");
	}

	function Shorten(_input, _maxlen){
		return (_input.length > _maxlen) ? _input.trim().substring(0,(_maxlen-3)) + '...' : _input;
	}

	function binaryQuickSearch(_haystack, _needle, _array_position)
	{
		try
		{
			var min = 0; 
			var max = _haystack.length-1;
			var m;
			
			while(true)
			{
				if(max < min)
					return -1;

				m = (min + max) / 2;
				
				if(_array_position != undefined)
					haystack_item = _haystack[m][_array_position];
				else
					haystack_item = _haystack[m];
				
				if(haystack_item < _needle)
					min = m + 1;
				else if(haystack_item > _needle)
					max = m - 1;
				else
					return m;
			}
		}
		catch(e){}
	}