function shadow(type) {
	if (type == "show") {
		$('shadow').style.display = "block";
	}
	else if (type == "hide") {
		$('shadow').style.display = "none";
	}
	else if ($("shadow").style.display=="none") {
		$('shadow').style.display = "block";
	}
	else {
		$('shadow').style.display = "none";
	}
}

function flap(what) {
	if ($(what).style.display=="none") {
		$(what).style.display="block";
	}
	else {
		$(what).style.display="none";
	}
}

function flapclose(what) {
	$(what).style.display="none";
}

function flapopen(what) {
	$(what).style.display="block";
}

function closeLayer() {
	flapclose("working");
	shadow("hide");
}

function center_div(id,width) {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	$(id).style.display = "none";
	$(id).style.left=((arrayPageSize[2]-width) / 2)+"px";
	$(id).style.top=(arrayPageScroll[1]+150)+"px";
}

function center_div_x(id,width,height) {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	$(id).style.display = "none";
	$(id).style.left=((arrayPageSize[2]-width) / 2)+"px";
	$(id).style.top=(arrayPageScroll[1]+ height)+"px";
}

function confirmit(confirmtext) {
	if (confirm(confirmtext))
		return true;
	else
		return false;
}

function confirmform(form,confirmtext) {
	if(confirm(confirmtext))
		document.forms[form].submit();
}

function getremark(type,message) {
	return "<p class=\""+type+"\"><strong>"+message+"</strong></p>"; 
}

function $(id) {
	return document.getElementById(id);
}

function getRect(oElement) {
	var nLeft	= 0;
	var nTop	= 0;
	var nWidth	= oElement.offsetWidth;
	var nHeight	= oElement.offsetHeight;

	while(oElement != null) {
		nTop += oElement.offsetTop;
		nLeft += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	};
	return({
    	'left'		: nLeft,
    	'top'		: nTop,
    	'width'		: nWidth,
    	'height'	: nHeight
    	});
}

function getPageSize() {
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
		if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

		if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPageScroll() {
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body){
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}