var timeoutArray = Array();
function changeDisplayTimeout(Object, Display, Timeout) {
	timeoutArray[Object.id] = setTimeout("changeDisplay($('"+Object.id+"'), '"+Display+"')",Timeout);
}
function changeDisplay(Object, Display) {
	if(Object) {
		Object.style.display = Display;
	}
}
function changeImgDisplay(Object) {
	if(Object.getAttribute('status').toString() == 'true') {
		Object.setAttribute('status', false);
		Object.src = Object.getAttribute('esrc');
		if(Object.getAttribute('target').toString() != '') {
			changeDisplay(document.getElementById(Object.getAttribute('target')), 'none');
		}
	}
	else {
		Object.setAttribute('status', true);
		Object.src = Object.getAttribute('csrc');
		if(Object.getAttribute('target').toString() != '') {
			changeDisplay(document.getElementById(Object.getAttribute('target')), 'block');
		}
	}
}
function findPosX(Object) {
	var curleft = 0;
	if (Object && Object.offsetParent) {
		while (Object.offsetParent) {
			curleft += Object.offsetLeft;
			Object = Object.offsetParent;
		}
	} else if (Object && Object.x) curleft += Object.x;
	return curleft;
}
function findPosY(Object) {
	var curtop = 0;
	if (Object && Object.offsetParent) {
		while (Object.offsetParent) {
			curtop += Object.offsetTop;
			Object = Object.offsetParent;
		}
	} else if (Object && Object.y) curtop += Object.y;
	return curtop;
}
function setAbsolutePosition(positionObject, targetObject) {
	posX = findPosX(positionObject);
	posY = findPosY(positionObject)+positionObject.offsetHeight;
	//need posY for ArticleEditBox
	if(IE && $('fixedarea')) {
		posY = posY - findPosY($('mainarea'));
		positionObject.parentNode.appendChild(targetObject);
	}
	else if(IE && $('Fixed')) {
		//posY = posY - (findPosY($('Fixed')) + 371);
		//posX = posX - 284;
		posY = window.event.y+positionObject.offsetHeight;
		posX = window.event.x;
		positionObject.parentNode.appendChild(targetObject);
	}
	else {
		document.body.insertBefore(targetObject, document.body.firstChild);
	}
	targetObject.style.position = 'absolute';
	targetObject.style.top = posY+'px';
	targetObject.style.left = posX+'px';
	targetObject.style.zIndex = '1000';
}
var IE = (navigator.appName == 'Microsoft Internet Explorer')? true : false;
function writeDIV(Object) {
	if(Object.getAttribute('target')) {
		var divObject = $(Object.getAttribute('target'))
		//document.body.insertBefore(divObject, document.body.firstChild);
		setAbsolutePosition(Object, divObject);
		changeDisplay(divObject, 'block');
		/*
		if (divObject.currentStyle) {
			var compStyle = divObject.currentStyle;
			var runStyle = divObject.runtimeStyle;
			for (var j in compStyle) {
				try {
					var Value = compStyle.getAttribute(j);
					if(Value != '' || Value != 'undefined') {
						divObject.runtimeStyle.setAttribute(j, Value);
					}
				}
				catch(e) {}
			}
		}
		else {
			var compStyle = window.getComputedStyle(divObject, "");
		}
		*/
	}
	else {
		divName = 'DIV'+Math.random();
		divObject = document.createElement('div');
		divObject.setAttribute('id', divName);
		Object.setAttribute('target', divName);
		divObject.className = 'iframe';
		//MOD POLAK 18082006 use ProtoType Functions
		//divObject.setStyle({background: "blue"});
		divObject.style.display = 'block';
		divObject.style.position = 'absolute';
		setAbsolutePosition(Object, divObject)
		//document.body.insertBefore(divObject, document.body.firstChild);
		Iframe.loadIframe(Object);
	}
}
