;;;function ______GLOBALS________(){}

/*---------------------------------------------------------------------------------------------*
|	This source code is in the public domain					|
*---------------------------------------------------------------------------------------------- */

var jbDomDone = false;
var jbInitDone = false;

var jarrEvents = new Array();
var jarrLoad = new Array();

var jMouseMoveFunc = null;
var jKeyDownFunc = null;
var jKeyUpFunc = null;
var jKeyPressFunc = null;

var jOldMouseMoveFunc = null;
var jOldKeyDownFunc = null;
var jOldKeyUpFunc = null;
var jOldKeyPressFunc = null;
var jOldOnLoadFunc = null;
var jOldOnUnLoadFunc = null;

var jnTimerID = 0;
var jnTimerInterval = 10;
var jarrTimerData = new Array();
var jnTimerLength = 0;
var jnLastTimerTime = 0;

var jstrDebug = "";
var jbDebugOn = false;
var jnDebugCnt = 0;
var jnDebugMaxStringLength = 6000;

var jbMouseDown = false;
var jnMouseX;
var jnMouseY;

var jbDrag = false;
var jnDragStartX = 0;
var jnDragStartY = 0;
var jnDragStartMouseX = 0;
var jnDragStartMouseY = 0;

var FOREVER = 18446744073709552000;

var START = 1000000;

//ONE  TIME EVENTS
var ONLOAD = START++;
var ONDOMLOADED = START++;
var ONUNLOAD = START++;

//OBJECT EVENTS
var MOUSEOVER = START++;
var MOUSEOUT = START++;
var MOUSEDOWN = START++;
var MOUSEUP = START++;
var CLICK = START++;
var DBLCLICK = START++;

//GLOBAL EVENTS
var MOUSEMOVE = START++;
var KEYUP = START++;
var KEYDOWN = START++;
var KEYPRESS = START++;

//SET & GET
START = 2000000;
var IMAGE = START++;
var OPACITY = START++;
var POS = START++;
var SIZE = START++;
var DISPLAY = START++;
var BGCOLOR =START++;
var BGIMAGE = START++;
var FONTSIZE = START++;
var FONTCOLOR = START++;
var INNERHTML = START++;
var ZINDEX = START++;
var HREF = START++;

var VALUE = START++;
var OVERFLOW = START++;
var LEFT = START++;
var TOP = START++;
var WIDTH = START++;
var HEIGHT = START++;
var FONTWEIGHT = START++;
var TEXTALIGN = START++;
var CURSOR = START++;


//SET ONLY
var KILL = START++;
var REMOVEEVENT = START++;

//SET INTERN ONLY
var DELAY = START++;

//GET ONLY
var CLIENT_WIDTH = START++;
var CLIENT_HEIGHT = START++;
var MOUSE_UP = START++;
var MOUSE_DOWN = START++;

//SET OPTION values
var START = -1000000;
var NONE = START--;
var ALL = START--;
var ADD = START--;


;;;function _____RGB_FUNCTIONS__(){};

function jRGBtoHex(R,G,B) 
{
	return jToHex(R)+jToHex(G)+jToHex(B);
};

function jToHex(N) 
{
	 if (N==null) return "00";
	 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
	 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
	 return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16);
};

function jHexToR(h) 
{
	return parseInt((jCutHex(h)).substring(0,2),16);
};

function jHexToG(h) 
{
	return parseInt((jCutHex(h)).substring(2,4),16);
};

function jHexToB(h) 
{
	return parseInt((jCutHex(h)).substring(4,6),16);
};

function jCutHex(h) 
{	
	return (h.charAt(0)=="#") ? h.substring(1,7):h;
};

function jConvFFRGBtoHex(str) 
{    
	str = str.replace(/rgb\(|\)/g, "").split(",");
	str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
	str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
	str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
	str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
	str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
	str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];
	return ('#' + str.join(""));
};

;;;function ______FUNCTIONS_____(){};

function jDebug(string)
{	
	;;;if (!jbDebugOn) return;
	;;;jstrDebug = jnDebugCnt + ": " + string + "<br>" + jstrDebug.substring(0, jnDebugMaxStringLength);
	;;;jnDebugCnt++;	
	;;;if (jGet("divDebug") != null)	jGet("divDebug").innerHTML = jstrDebug;
};

function jRandom(min, max)
{
	return Math.floor(Math.random() * (max - min + 1) + min);
};

;;;function ______SET___________(){};

function jSetOpacity(obID, nOpacity) 
{
	var object = document.getElementById(obID).style; 
	object.opacity = (nOpacity / 100);
	object.MozOpacity = (nOpacity / 100);
	object.KhtmlOpacity = (nOpacity / 100);
	object.filter = "alpha(opacity=" + nOpacity + ")";
};

;;;function ______GET___________(){};

function jGetMousePos(e) 
{ 
	if (!e) e = event; 
	return e.pageX ? {'x':e.pageX, 'y':e.pageY} : 
	{'x':e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, 'y':e.clientY + document.documentElement.scrollTop + document.body.scrollTop}; 
};

function jGetClientWidth() 
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
};

function jGetClientHeight() 
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
};
	

function jGetOpacity (id)
{
    var opac = 100; 
    if(document.getElementById(id).style.opacity < 100)  opac = document.getElementById(id).style.opacity * 100; 
	return opac;
};


;;;function _____ACTIONS________(){};


function jCreateTimerData(id, action, value, options, timer, timerstart, s1, s2, s3, a1, a2, a3) 
{
	this.id = id;
	this.action = action;
	this.value = value;
	this.options = options;
	this.timer = timer;
	this.timerstart = timerstart;
	this.s1 = s1;
	this.s2 = s2;
	this.s3 = s3;
	this.a1 = a1;
	this.a2 = a2;
	this.a3 = a3;
};
	
function jRemoveFromTimer(tindex)
{
	;;;if (jbDebugOn) jDebug("Removed from timer: " + jarrTimerData[tindex].action + ", " + jarrTimerData[tindex].id);
	jarrTimerData[tindex] = jarrTimerData[jnTimerLength - 1];
	jnTimerLength--;

	//stop timer
	if (jnTimerLength == 0)
	{
		;;;if (jbDebugOn) jDebug("Timer stopped");
		clearInterval(jnTimerID);
	}
};

function jKillFromTimer(id, action)
{
	var nCnt;
	for(nCnt = 0; nCnt < jnTimerLength; nCnt++)
	{
		if ((jarrTimerData[nCnt].id == id) && (jarrTimerData[nCnt].action == action))
		{
			;;;if (jbDebugOn) jDebug("jAddToTimer removed running: " + id + ", " + action);
			jRemoveFromTimer(nCnt);
			break;
		}
	}	
};

function jAddToTimer(id, action, value, options, timer, delay)
{	
	var nCnt;
	var atime = new Date();
	var now = atime.getTime();
	
	var obj;
	var tmp;
	var s1;
	var s2;
	var s3;
	var a1;
	var a2;
	var a3;
	
	if (delay > 0)
	{
		s1 = action;
		s2 = timer;
		action = DELAY;
		timer = delay;
	}

	if (typeof(action) == "function")
	{
		//functions want's timer
		if (options != "")
		{
			//save interval
			s1 = parseInt(options);
			s2 = s1;
			//clear invalid data
			if (isNaN(s1))
			{
				s1 = null;
			}
		}
	}	
	else if (action == KILL)
	{
	
	}
	else
	{
		obj = jGet(id);
		if (obj == null)
		{
			;;;if (jbDebugOn) jDebug("WARNING jAddToTimer rejected: " + event + "," + id + " has invalid id");	
			return;
		}

		//save necessary start data
		switch(action)
		{ 		
		case OPACITY:
			s1 = jGetOpacity(id);
			a1 = parseInt(value) - s1;
			break;
		case POS:
			s1 = parseInt(obj.offsetLeft);
			s2 = parseInt(obj.offsetTop);
			if (value.charAt(0) == "a") a1 = parseInt(value.substr(4));
			else if (value == "same") a1 = 0;
			else { a1 = value - s1;}
			if (options.charAt(0) == "a") a2 = parseInt(options.substr(4));
			else if (options == "same") a2 = 0;
			else a2 = options - s2;	
			break;    
		case SIZE:
			s1 = parseInt(obj.offsetWidth);
			s2 = parseInt(obj.offsetHeight);
			if (value.charAt(0) == "a") a1 = parseInt(value.substr(4));
			else if (value == "same") a1 = 0;
			else a1 = value - s1;
			if (options.charAt(0) == "a") a2 = parseInt(options.substr(4));
			else if (options == "same") a2 = 0;
			else a2 = options - s2;				
			break;
		case BGCOLOR:
			//IE
			if (obj.currentStyle) {tmp = obj.currentStyle["backgroundColor"];}
			//FF-MOZILLA
			else if (window.getComputedStyle)
			{
				tmp = document.defaultView.getComputedStyle(obj,null).getPropertyValue("background-color");	
				tmp = jConvFFRGBtoHex(tmp);		
			}
			s1 = jHexToR(tmp);
			s2 = jHexToG(tmp);
			s3 = jHexToB(tmp);
			a1 = jHexToR(value) - s1;
			a2 = jHexToG(value) - s2;
			a3 = jHexToB(value) - s3;		
			break;  
		case FONTSIZE:
			//IE
			if (obj.currentStyle) tmp = obj.currentStyle["fontSize"];
			//FF-MOZILLA
			else if (window.getComputedStyle) tmp = document.defaultView.getComputedStyle(obj,null).getPropertyValue("font-size");
			tmp = tmp.substring(0,tmp.length - 2);
			s1 = parseInt(tmp);
			a1 = value - s1;
			break;    			
		case FONTCOLOR:
			//IE
			if (obj.currentStyle) tmp = obj.currentStyle["color"];
			//FF-MOZILLA
			else if (window.getComputedStyle)
			{
				tmp = document.defaultView.getComputedStyle(obj,null).getPropertyValue("color");	
				tmp = jConvFFRGBtoHex(tmp);		
			}
			s1 = jHexToR(tmp);
			s2 = jHexToG(tmp);
			s3 = jHexToB(tmp);
			a1 = jHexToR(value) - s1;
			a2 = jHexToG(value) - s2;
			a3 = jHexToB(value) - s3;		
			break;    			
		}	
	}

	//save timer data
	jarrTimerData[jnTimerLength] = new jCreateTimerData(id, action, value, options, timer, now, s1, s2, s3, a1, a2, a3);
	jnTimerLength++;
	
	;;;if (jbDebugOn) jDebug("jAddToTimer added: " + id + ", " + action);

	//start timer
	if (jnTimerLength == 1)
	{
		jnLastTimerTime = now;
		jnTimerID = setInterval('jOnTimer()', jnTimerInterval);
		;;;if (jbDebugOn) jDebug("Timer started");
	}
};


function jOnTimer()
{
	var nCnt;
	var nTimeDif;
	var nProgress;
	var nTmp;
	var obj;
	var time = new Date();
	var ctime = time.getTime();
	
	var id;
	var action;
	var value;
	var options;
	var timer;
	var timerstart;
	var s1;
	var s2;
	var s3;
	var a1;
	var a2;
	var a3;
	
	for(nCnt = 0; nCnt < jnTimerLength; nCnt++)
	{
		id = jarrTimerData[nCnt].id;
		action = jarrTimerData[nCnt].action;
		value = jarrTimerData[nCnt].value;
		options = jarrTimerData[nCnt].options;
		timer = jarrTimerData[nCnt].timer;
		timerstart = jarrTimerData[nCnt].timerstart;
		s1 = jarrTimerData[nCnt].s1;
		s2 = jarrTimerData[nCnt].s2;
		s3 = jarrTimerData[nCnt].s3;
		a1 = jarrTimerData[nCnt].a1;
		a2 = jarrTimerData[nCnt].a2;
		a3 = jarrTimerData[nCnt].a3;

		nTimeDif = ctime - timerstart;	

//somehow nTimeDif ends up negative with new timer objects?? why?? 
//the question is: did I accidentally fix this?
		if (nTimeDif < 0) nTimeDif = 0;

		//if over time -> set object to end state and remove from timer
		if (nTimeDif > timer)
		{
			jRemoveFromTimer(nCnt);
			nCnt--;
			switch(action)
			{ 					
			case POS:
				jSetEnd(id, action, "" + (s1 + a1) , "" + (s2 + a2));	
				break;    
			case SIZE:
				jSetEnd(id, action, "" + (s1 + a1) , "" + (s2 + a2));	
				break;
			case DELAY:
				jSet(id, s1, value, options, s2);	
				break;
			default:
				jSetEnd(id, action, value, options);
			}	
			continue;
		}
		
		if (typeof(action) == "function")
		{
			//function wants timer
			if (s1 != null)
			{
				if (jarrTimerData[nCnt].s2 == 0)
				{
					action(id, value, nProgress);
				}
				else
				{
					if (jnLastTimerTime < ctime)
					{
						jarrTimerData[nCnt].s2 = jarrTimerData[nCnt].s2 - (ctime - jnLastTimerTime);
					}
					else
					{
//alert("negiie!");
					}
					//fire when interval has passed
					if (jarrTimerData[nCnt].s2 <= 5)
					{
						action(id, value, nProgress);
						//reset interval
						jarrTimerData[nCnt].s2 = jarrTimerData[nCnt].s1;
					}
				}
			}
			continue;
		}	

		nProgress = nTimeDif / timer;
		obj = jGet(id);	
		if (obj == null) continue;
		
		switch(action)
		{ 					
		case OPACITY:
			nTmp = Math.round(s1 + (a1 * nProgress));						
			jSetOpacity (id, nTmp);
			break;
		case POS:
			obj.style.left = Math.round(s1 + (a1 * nProgress)) + "px";
			obj.style.top = Math.round(s2 + (a2 * nProgress)) + "px";		
			break;    
		case SIZE:
			obj.style.width = Math.round(s1 + (a1 * nProgress)) + "px";			
			obj.style.height = Math.round(s2 + (a2 * nProgress)) + "px";			
			break;    				  				
		case BGCOLOR:
			var nTmpR = Math.round(s1 + (a1 * nProgress));
			var nTmpG = Math.round(s2 + (a2 * nProgress));
			var nTmpB = Math.round(s3 + (a3 * nProgress));		
			obj.style.backgroundColor = "#" +  jRGBtoHex(nTmpR, nTmpG, nTmpB);
			break;    				
		case FONTSIZE:
			var nTmpR = Math.round(s1 + (a1 * nProgress * 10 / 10));
			obj.style.fontSize = nTmpR + "px";
			break;    			
		case FONTCOLOR:
			var nTmpR = Math.round(s1 + (a1 * nProgress));
			var nTmpG = Math.round(s2 + (a2 * nProgress));
			var nTmpB = Math.round(s3 + (a3 * nProgress));		
			obj.style.color = "#" +  jRGBtoHex(nTmpR, nTmpG, nTmpB);
			break;    						 			
		}	
	}
	
	jnLastTimerTime = ctime;
};



function jSetEnd(id, action, value, options)
{
	;;;if (jbDebugOn) jDebug("Ending jSet: " + id + ", " + action + ", " + value + ", " + options);
	
	var nTmp;

	if (typeof(action) == "function")
	{
		action(id, value, 1);
		return;
	}
	else if (action == KILL)
	{
		var nCnt;
		for(nCnt = 0; nCnt < jnTimerLength; nCnt++)
		{
			if ((jarrTimerData[nCnt].id == id) || (id == ""))
			{
				if (value == "all")
				{
					jRemoveFromTimer(nCnt);
					nCnt--;
				}
				else if (jarrTimerData[nCnt].action == value)
				{
					jRemoveFromTimer(nCnt);
					break;
				}
			}
		}
		return;
	}
	
	var obj = jGet(id);
	if (obj == null)
	{
		;;;if (jbDebugOn) jDebug("WARNING jSetEnd rejected: " + action + "," + id + " has invalid id");	
		return;
	}

	switch(action)
	{
	case IMAGE:
		obj.src = value;
		break;    
	case OPACITY:
		jSetOpacity(id, value);
		break;
	case POS:	
		//offsets left
		if (value.charAt(0) == "a")
		{
			nTmp = parseInt(obj.offsetLeft) + parseInt(value.substr(4));
			obj.style.left = nTmp + "px";	
		}
		//skip
		else if (value == "same");
		//set new left
		else obj.style.left = value + "px";
		
		//offsets top
		if (options.charAt(0) == "a")
		{
			nTmp = parseInt(obj.offsetTop) + parseInt(options.substr(4));
			obj.style.top = nTmp + "px";	
		}
		//skip
		else if (options == "same");
		//set new top
		else obj.style.top = options + "px";
		break;    
	case SIZE:
		//offsets width
		if (value.charAt(0) == "a")
		{
			nTmp = parseInt(obj.offsetWidth) + parseInt(value.substr(4));
			obj.style.width = nTmp + "px";	
		}
		//skip
		else if (value == "same");
		//set new width
		else obj.style.width = value + "px";
		
		//offsets height
		if (options.charAt(0) == "a")
		{
			nTmp = parseInt(obj.offsetHeight) + parseInt(options.substr(4));
			obj.style.height = nTmp + "px";	
		}
		//skip
		else if (options == "same");
		//set new height
		else obj.style.height = options + "px";
		break;
	case DISPLAY:
		obj.style.display = value;
		break;    			
	case BGCOLOR:
		obj.style.backgroundColor = (value.charAt(0)!="#") ? ("#" + value) : value;
		break;    		
	case BGIMAGE:
		obj.style.backgroundImage = "url(" + value + ")";	
		break;    		
	case FONTSIZE:
		obj.style.fontSize = value + "px";
		break;    			
	case FONTCOLOR:
		obj.style.color = (value.charAt(0)!="#") ? ("#" + value) : value;
		break;    			
	case INNERHTML:
		obj.innerHTML =  value;
		break;  
	case HREF:
		obj.href =  value;
		break;  		
	case ZINDEX:
		obj.zIndex =  value;
		break;  
	case OVERFLOW:
		obj.style.overflow =  value;
		break;  
		
	default:
		;;;if (jbDebugOn) jDebug("ERROR jSetEnd : no such action : " + id + ", " + action + ", " + value + ", " + options + " or " + timer);
	}
};


;;;function _____EVENTS_________(){};


function jFire(e) 
{
	var nCnt;
	var e = e || window.event;
	var event = e.type || window.event.type;
	var id = this.id;

	//kill evil bubbles
	if (this.nodeName == "DIV")
	{
		//if target from is a child of this div or mouse moves from itself to itself -> fake mouse over
		if (event == "mouseover")
		{
			var targetFrom = (e.relatedTarget) ? e.relatedTarget : e.fromElement;
			if ((typeof(eval(this.getElementsByTagName("*")[targetFrom.id])) != "undefined") || (id == targetFrom.id)) return;
		}
		//if target to is a child of this  or mouse moves from itself to itself -> fake mouse over
		else if (event == "mouseout")
		{
			var targetTo = (e.relatedTarget) ? e.relatedTarget : e.toElement;
			if ((typeof(eval(this.getElementsByTagName("*")[targetTo.id])) != "undefined") || (id == targetTo.id)) return;
		}
	}
	

	var nEvent = NONE;
	switch(event)
	{
		case "mouseover":
			nEvent = MOUSEOVER;
			break;
		case "mouseout":
			nEvent = MOUSEOUT;
			break;
		case "mousedown":
			var mp = jGetMousePos(e);
			jnMouseX = mp.x;
			jnMouseY = mp.y;
			nEvent = MOUSEDOWN;
			break;
		case "mouseup":
			nEvent = MOUSEUP;
			break;
		case "click":
			nEvent = CLICK;
			break;
		case "dblclick":
			nEvent = DBLCLICK;
			break;			
	}		
	//find the right events and start them
	for (nCnt = 0; nCnt < jarrEvents.length; nCnt++)
	{
		if ((jarrEvents[nCnt].event == nEvent) && (jarrEvents[nCnt].id == id))
		{
			
			jSet(id, jarrEvents[nCnt].action, jarrEvents[nCnt].value, jarrEvents[nCnt].options, jarrEvents[nCnt].timer, jarrEvents[nCnt].delay);
		}
	}
};

function jFireGlobal(e) 
{
	var nCnt;
	var e = e || window.event;
	var event = e.type || window.event.type;

	
	switch(event)
	{
		case "mousedown":
			jbMouseDown = true;
			break;
		case "mouseup":
			jbMouseDown = false;
			break;
		case "keydown":
			if (jKeyDownFunc != null)
			{
			
			}
			break;
		case "keyup":
			if (jKeyUpFunc != null)
			{
			
			}
			break;
		case "keypress":
			if (jKeyPressFunc != null)
			{
			
			}
			break;
	}
};

function jOnMouseMove(e)
{
	if (jMouseMoveFunc != null)
	{
		var mp = jGetMousePos(e);
		jMouseMoveFunc(e, mp.x, mp.y);
	}
	if (jbDrag)
	{
	/*	
var jbDrag = false;
var jnDragStartX = 0;
var jnDragStartY = 0;
var jnDragStartMouseX = 0;
var jnDragStartMouseY = 0;
*/
	}
};

function jAttachEvent(event, id)
{
	if (jGet(jarrEvents[nCnt].id) == null)
	{
		;;;if (jbDebugOn) jDebug("WARNING jAttachEvent id is invalid: " + jarrEvents[nCnt].event + ", " + jarrEvents[nCnt].id + ", " + jarrEvents[nCnt].action);
		return;
	}
	
	switch(event)
	{
		case MOUSEOVER:
			;;;if (jbDebugOn) jDebug("Created mouseover for " + id);
			jGet(id).onmouseover = jFire;
			break;
		case MOUSEOUT:
			;;;if (jbDebugOn) jDebug("Created mouseout for " + id);
			jGet(id).onmouseout = jFire;
			break;
		case MOUSEDOWN:
			;;;if (jbDebugOn) jDebug("Created mousedown for " + id);
			jGet(id).onmousedown = jFire;
			break;
		case MOUSEUP:
			;;;if (jbDebugOn) jDebug("Created mouseup for " + id);
			jGet(id).onmouseup = jFire;
			break;
		case CLICK:
			;;;if (jbDebugOn) jDebug("Created click for " + id);
			jGet(id).onclick = jFire;
			break;
		case DBLCLICK:
			;;;if (jbDebugOn) jDebug("Created dblclick for " + id);
			jGet(id).ondblclick = jFire;
			break;		
	}
};


function jRemoveEvent(event, id)
{
	if (jGet(jarrEvents[nCnt].id) == null)
	{
		;;;if (jbDebugOn) jDebug("WARNING jAttachEvent id is invalid: " + jarrEvents[nCnt].event + ", " + jarrEvents[nCnt].id + ", " + jarrEvents[nCnt].action);
		return;
	}
	
	switch(event)
	{
		case MOUSEOVER:
			;;;if (jbDebugOn) jDebug("Removed mouseover for " + id);
			jGet(id).onmouseover = null;
			break;
		case MOUSEOUT:
			;;;if (jbDebugOn) jDebug("Removed mouseout for " + id);
			jGet(id).onmouseout = null;
			break;
		case MOUSEDOWN:
			;;;if (jbDebugOn) jDebug("Removed mousedown for " + id);
			jGet(id).onmousedown = null;
			break;
		case MOUSEUP:
			;;;if (jbDebugOn) jDebug("Removed mouseup for " + id);
			jGet(id).onmouseup = null;
			break;
		case CLICK:
			;;;if (jbDebugOn) jDebug("Removed click for " + id);
			jGet(id).onclick = null;
			break;
		case DBLCLICK:
			;;;if (jbDebugOn) jDebug("Removed dblclick for " + id);
			jGet(id).ondblclick = null;
			break;		
	}
};


function jCreateEvent(event, id, action, value, options, timer, delay) 
{
	this.event = event;
	this.id = id;
	this.action = action;
	this.value = value;
	this.options = options;
	this.timer = timer;
	this.delay = delay;
};


;;;function _____INIT_EXIT_______(){};

	
function jOnDomLoaded()
{
	if (jbDomDone) return;
	
	;;;if (jbDebugOn) jDebug("jDomloaded start");
	// digestondomloaded events
	for (nCnt = 0; nCnt < jarrLoad.length; nCnt++)
	{
		if (jarrLoad[nCnt].event == ONDOMLOADED)
		{
			;;;if (jbDebugOn) jDebug("OnDomLoaded fired for " + jarrLoad[nCnt].id);
			jSet(jarrLoad[nCnt].id, jarrLoad[nCnt].action, jarrLoad[nCnt].value, jarrLoad[nCnt].options, jarrLoad[nCnt].timer);
		}
	}

	jbDomDone = true;
	;;;if (jbDebugOn) jDebug("jDomloaded end");	
};


function jOnLoad(e)
{
	;;;if (jbDebugOn) jDebug("jInit start");
	
	if (jbInitDone) return;
	
	//if (!jbDomDone) jOnDomLoaded();
	
	if (jOldOnLoadFunc != null) jOldOnLoadFunc(e);
	
	for (nCnt = 0; nCnt < jarrLoad.length; nCnt++)
	{
		//blindly fire  onload
		if (jarrLoad[nCnt].event == ONLOAD)
		{
			;;;if (jbDebugOn) jDebug("Onload fired for " + jarrLoad[nCnt].id);
			jSet(jarrLoad[nCnt].id, jarrLoad[nCnt].action, jarrLoad[nCnt].value, jarrLoad[nCnt].options, jarrLoad[nCnt].timer);
		}
	}
	//attach events
	for (nCnt = 0; nCnt < jarrEvents.length; nCnt++)
	{
		jAttachEvent(jarrEvents[nCnt].event, jarrEvents[nCnt].id);
	}

	if (jOldOnLoadFunc != null) jOldOnLoadFunc(e);
	
	jbInitDone = true;
	;;;if (jbDebugOn) jDebug("jOnLoad end");
};


function jOnUnLoad()
{
	for (nCnt = 0; nCnt < jarrLoad.length; nCnt++)
	{
		if (jarrLoad[nCnt].event == ONUNLOAD)
		{
			;;;if (jbDebugOn) jDebug("OnUnload fired for " + jarrLoad[nCnt].id);
			jSet(jarrLoad[nCnt].id, jarrLoad[nCnt].action, jarrLoad[nCnt].value, jarrLoad[nCnt].options, jarrLoad[nCnt].timer);
		}
	}
	;;;if (jbDebugOn) jDebug("jOnUnLoad end");	
};

;;;function _____INTERFACE________(){};

function jGet(p1, p2) 
{  
	if (typeof(p1) == "string")
	{
		return window.document.getElementById(p1);
	}
	else if (typeof(p1) == "number")
	{
		if (arguments.length == 2)
		{
			var obj = window.document.getElementById(p2);
			if (obj == null) 
			{
				return null;
			}
			switch(p1)
			{
			case TOP:
				return parseInt(obj.offsetTop);
				break;
			case LEFT:
				return parseInt(obj.offsetLeft);
				break;
			case WIDTH:
				return parseInt(obj.offsetWidth);
				break;
			case HEIGHT:
				return parseInt(obj.offsetHeight);
				break;
			default:
				return null;
			}
		}
	}
};

			
function jSet(id, action, value, options, timer, delay)
{
	//validate arguments
	if ((typeof(id) != "string") || ((typeof(action) != "number") && (typeof(action) != "function")))
	{
		;;;if (jbDebugOn) jDebug("ERROR jSet: " + id + " or " + action + " isn't a string/number/function");
		return;
	}
	
	//check "optional" arguments
	switch(arguments.length)
	{
	case 2:
		var value = "";
	case 3:
		var options = "0";
	case 4:
		var timer = 0;
	case 5:
		var delay = 0;		
	}

	//remove data from timer
	if (delay <= 0)
	{
		jKillFromTimer(id,action);
	}
	
	//let timer handle things
	if ((timer > 0) || (delay > 0))
	{
		jAddToTimer(id, action, value, options, timer, delay);
		return;
	}
	
	//finish set
	jSetEnd(id, action, value, options);
};


function jRemove(event, id, action)
{

	
};


function jOn(event, id, action, value, options, timer, delay)
{	
	var nCnt;
	
	//check arguments type: event & id
	;;;if ((typeof(event) != "number") || (typeof(id) != "string")) {if (jbDebugOn) jDebug("ERROR jOn Rejected: event and id have to be strings.");}	
	
	//check argument type: action
	;;;if ((typeof(action) != "number") && (typeof(action) != "function")) {if (jbDebugOn) jDebug("ERROR jOn Rejected: " + event + "," + id + " action has to be number or function");	}	

	//check argument: does event exist?
	switch(event)
	{
	case MOUSEOVER:
	case MOUSEOUT:
	case MOUSEDOWN:
	case MOUSEUP:
	case CLICK:
	case DBLCLICK:
		
		var bFound = false;
		//overwrite event if event + id + action are the same
		for (nCnt = 0; nCnt < jarrEvents.length; nCnt++)
		{
			if ((jarrEvents[nCnt].event == event) && (jarrEvents[nCnt].id == id) && (jarrEvents[nCnt].action == action))
			{
				jarrEvents[nCnt].value = value;
				jarrEvents[nCnt].options = options;
				jarrEvents[nCnt].timer = timer;	
				jarrEvents[nCnt].delay = delay;	
				;;;if (jbDebugOn) jDebug("jOn Adjusted Event: " + event + ", " + id + ", " + action);
				bFound = true;
			}
		}
		//else add event to event list
		if (!bFound) jarrEvents[jarrEvents.length] = new jCreateEvent(event, id, action, value, options, timer, delay);
		if (jbInitDone) jAttachEvent(event, id);
		break;
	case MOUSEMOVE:
		if (typeof(action) == "function") 
		{
			jMouseMoveFunc = action;
			document.onmousemove  = jOnMouseMove;
		}
		else document.onmousemove = null;
		break;
	case KEYDOWN:
		if (typeof(action) == "function") jKeyDownFunc = action;
		else jKeyDownFunc = null;
		break;
	case KEYUP:
		if (typeof(action) == "function") jKeyUpFunc = action;
		else  jKeyUpFunc = null;
		break;
	case KEYPRESS:
		if (typeof(action) == "function") jKeyPressFunc = action;
		else jKeyPressFunc = null;
		break;
	case ONLOAD:
	case ONDOMLOADED:
	case ONUNLOAD:
		if (jbInitDone) return;
		jarrLoad[jarrLoad.length] = new jCreateEvent(event, id, action, value, options, timer, delay);
		break;		
	default:	
		;;;if (jbDebugOn) jDebug("ERROR jOn Rejected: event '" + event + "' doesn't exist.");
		return;
	}

	;;;if (jbDebugOn) jDebug("jOn Added Event: " + event + ", " + id + ", " + action);
};

;;;function _____RUN___________(){}

if (typeof window.onload == "function") jOldOnLoadFunc = window.onload;
window.onload = jOnLoad;

if (typeof window.onunload == "function") jOldOnUnLoadFunc = window.onunload;
window.onunload = jOnUnLoad;

document.onmouseup  = jFireGlobal;
document.onmousedown  = jFireGlobal;
document.onkeydown  = jFireGlobal;
document.onkeyup  = jFireGlobal;
document.onkeypress  = jFireGlobal;

/* for Mozilla/Opera9 */
if (document.addEventListener) document.addEventListener("DOMContentLoaded", jOnDomLoaded, false);

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            jOnDomLoaded(); // call the onload handler
        }
    };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            jOnDomLoaded(); // call the onload handler
        }
    }, 10);
}

