/*
-----------------------------------------------------------------------
POP Generic Controls - Client Script (ver 1.0)
-----------------------------------------------------------------------
*/
var _cnt = 0;
var storedDbObj;
var __onloadCache = new Array();
var __onkeyupCache = new Array();
var __onkeydownCache = new Array();

function __io()
{
	var a, b, c, i;
	c = document.all;
	for(i=0 ;i<c.length; i++)
	{
		if(typeof(c[i]) == "object"){
			if(_cnt > 1000)
			{
				try{c[i].style.position = 'absolute';}catch(e){};
			}
			try{c[i].style.top = getTop(c[i])}catch(e){};
			try{c[i].style.left = getLeft(c[i])}catch(e){};
		}
	}
	_cnt++;
	setTimeout("__io()", 500);
}

function getTop(o){
	return (o.offsetTop + 0.01)
}

function getLeft(o){
	return (o.offsetLeft + 0.01)
}

function __checkVal()
{
	if(document.readyState== "complete")
	{
		clearTimeout("__checkVal")
		setTimeout("__io()", 50);
	}else{
		setTimeout("__checkVal()", 1000);
	}
}

function getTime()
{
	var oDate = new Date();
	var day, month, year, hours, minutes, seconds, milliseconds;
	day = oDate.getDate().toString();
	if(day.length<2){day = "0" + day};
	month = oDate.getMonth().toString();
	if(month.length<2){ month = "0" + month;}
	year = oDate.getFullYear().toString();
	hours = oDate.getHours().toString();
	minutes = oDate.getMinutes().toString();
	seconds = oDate.getSeconds().toString();
	milliseconds = oDate.getMilliseconds();
	var s =  year + "-" + month + "-" + day + " " + hours + ":" + minutes;
	return s;
}

function getDate()
{
	var oDate = new Date();
	var day, month, year, hours, minutes, seconds, milliseconds;
	day = oDate.getDate().toString();
	if(day.length<2){day = "0" + day};
	month = oDate.getMonth().toString();
	if(month.length<2){ month = "0" + month;}
	year = oDate.getFullYear().toString();
	hours = oDate.getHours().toString();
	minutes = oDate.getMinutes().toString();
	seconds = oDate.getSeconds().toString();
	milliseconds = oDate.getMilliseconds();
	var s =  year + "-" + month + "-" + day;
	return s;
}

function trace(obj)
{
	var dnwin;
	var str = "";
	var i;
	str = "<h3>JAVASCRIPT DEBUG WIN (Ver 1.2)</h3>\r<table border=1>\r";
	str += "<tr bgcolor='#CCCCCC'>\r<td>object:</td>\r<td>value:</td>\r<td>type:</td>\r<td>view:</td>\r</tr>\r";
	if(typeof(obj) == "object")
	{	
		for(i in obj)
		{
			if(typeof(obj[i]) == "object")
			{
				str += "<tr>\r<td>" + i + "</td>\r<td>" + (obj[i]) + "</td>\r<td>" + typeof(i) + "</td>\r<td>\r<input type='button' value='view' onclick='dbnewwin(storedDbObj[" + i + "])'/>\r</td>\r</tr>\r";
			}
			else
			{
				str += "<tr>\r<td>" + i + "</td>\r<td>" + obj[i] + "</td>\r<td>" + typeof(i) + "</td>\r<td>NULL</td>\r</tr>\r";
			}
		}	
	}
	else
	{
	
		str += "<tr>\r<td></td>\r<td>" + obj + "</td>\r<td>" + typeof(obj) + "</td>\r<td></td>\r</tr>\r";
	}
	str += "</table>\r<input type='button' value='close' onclick='window.close()'/>";
	dbwin = window.open("","nwin");
	dbwin.dbnewwin = this.dbnewwin;
	dbwin.document.write(str);
	dbwin.storedDbObj = obj;
}
/*
body onLoad Event Cache
*/
function appendBodyOnload(str){
	var s, i, e;
	__onloadCache[__onloadCache.length] = str;
	if(document.body.onload){
		s = document.body.onload.toString();
		i = s.indexOf("function anonymous()")
		e = s.lastIndexOf("}")
		if(i > -1 && e > -1)
		{
			s = s.substring(i+20, e)
			i = s.indexOf("{")
			s = s.substring(i+1 , s.length)
			__onloadCache[__onloadCache.length] = s;
		}
	}
	document.body.onload = execOnLoadCache;
}

function execOnLoadCache()
{
	var i;
	for(i=0; i<__onloadCache.length; i++)
	{
		eval(__onloadCache[i]);
	}
}

/*
onKeyDown Cache
*/

function appendOnKeyDown(str){
	var s, i, e;
	__onkeydownCache[__onkeydownCache.length] = str;
	if(document.body.onkeydown)
	{
		s = document.body.onkeydown.toString();
		i = s.indexOf("function anonymous()");
		e = s.lastIndexOf("}");
		if(i > -1 && e > -1)
		{
			s = s.substring(i+20, e);
			i = s.indexOf("{");
			s = s.substring(i+1 , s.length);
			__onkeydownCache[__onkeydownCache.length] = s;
		}
	}
	document.onkeydown = execOnKeyDownCache;
}

function execOnKeyDownCache()
{
	var i;
	for(i=0; i<__onkeydownCache.length; i++)
	{
		eval(__onkeydownCache[i]);
	}
}

/*
onKeyUp Cache
*/
function appendOnKeyUp(str){
	var s, i, e;
	__onkeyupCache[__onkeyupCache.length] = str;
	if(document.body.onkeyup){
		s = document.body.onkeyup.toString();
		i = s.indexOf("function anonymous()");
		e = s.lastIndexOf("}");
		if(i > -1 && e > -1)
		{
			s = s.substring(i+20, e);
			i = s.indexOf("{");
			s = s.substring(i+1 , s.length);
			__onkeyupCache[__onkeyupCache.length] = s;
		}
	}
	document.onkeyup = execOnKeyUpCache;
}

function execOnKeyUpCache()
{
	var i;
	for(i=0; i<__onkeyupCache.length; i++)
	{
		eval(__onkeyupCache[i]);
	}
}

/*
-----------------------------------------------------------------------
updated: 18.11.2003
-----------------------------------------------------------------------
*/



