var id_message_d1 = null;
var id_message_d2 = null;

id_message_center = function() {
	this.valign = "100px";
	this.align = "center";
};


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 { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    if (self.innerHeight) {    // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }


    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
    return arrayPageSize;
}

function id_message_box(params) {
	//alert("id_message_box");
	if (!params) return false;

	obj = params["obj"];
	message = params["message"];
	width = params["width"];
	if (params["height"]) height = params["height"];
	else height = false;
	if (params["bg_opacity"]) bg_opacity = params["bg_opacity"];
	else bg_opacity = 50;
	

	if (!width) {
		width='300';
	}
	
	ps = getPageSize();

	if (!params['noBGLayer']) {
		d2 = document.createElement("div");
		d2.style.filter = "alpha(opacity="+bg_opacity+")";
		d2.style.mozOpacity = "0."+bg_opacity;
		d2.style.opacity = "0."+bg_opacity;
		d2.style.backgroundColor = "#000000";
		d2.style.position = "absolute";
		d2.style.top = "0px";
		d2.style.left = "0px";
		d2.style.width = ps[0]+"px";
		d2.style.height = ps[1]+"px";
		document.body.appendChild(d2);
	} else d2 = null;
	
	d = document.createElement("div");
	d.style.clip.top = "0px";
	d.style.clip.left = "0px";
	d.style.clip.right = "100px";
	d.style.clip.bottom = "440px";
	d.innerHTML = message;
	d.style.display = "block";
	d.style.position = "absolute";
	if (!obj.valign) d.style.top = obj.offsetTop+20+"px";
	else d.style.top = obj.valign;
	if (!obj.align) d.style.left = obj.offsetLeft+20+"px";
	else {
		if (obj.align=="center") {
			d.style.left = Math.round((ps[0]-width)/2)+"px";
		} else d.style.left = obj.align;
	}
	d.style.padding = "5px";
	d.className = 'id_message_box';
	if (height) d.style.height = height;

	document.body.appendChild(d);

	id_message_d1 = d;
	id_message_d2 = d2;

}

function id_message(obj,title,message,width) {

	this.prototype=new id_message_box({
			"obj":obj,
			"message":"<div class='id_message_title_box' style='display: block;'><table cellpadding='0' cellspacing='0' width='"+width+"'><tr><td align='left' class='id_message_title'>"+title+"</td><td align='right'><a class='id_message_bezaras' style='float: right;' href='javascript:id_message_remove();' >Bezárás</a></td></tr></table></div><div style='padding-top: 5px;' class='id_message_body'>"+message+"</div>",
			"width":width
		});

}

function id_message_remove() {
	if (id_message_d1!=null) document.body.removeChild(id_message_d1);
	if (id_message_d2!=null) document.body.removeChild(id_message_d2);
}
