var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);

var curModal = {};

function openModal(div_id, w, h, dclass)
{
	if (typeof dclass == 'undefined' ) dclass = 'mbox';
	
	dx = document.getElementById("mbox_bg") == null ? document.createElement('div') : document.getElementById("mbox_bg");
	dx.setAttribute("id","mbox_bg");
	dx.setAttribute("inner_id",div_id);
	dx.style.position = "absolute";
	dx.style.top = "0px";
	dx.style.left = "0px";
	dx.style.width = "100%";
	dx.style.height = "100%";
	dx.style.backgroundColor = "#000000";	
	dx.style.display = "block";
	
	dx.style.zIndex = 998;
	document.body.appendChild(dx);

	if (b_version.indexOf("MSIE ") >= 0) {
		l = (screen.availWidth - w) / 2;
		t = ((screen.availHeight - h) / 2) - 100;	
		dx.style.height = screen.availHeight;
		dx.style.filter ="Alpha(opacity=80)";
		dx.style.width = screen.availWidth;
	}
	else
	{
		l = (window.innerWidth - w) / 2;
		t = (window.innerHeight - h) / 2;	
		dx.style.opacity = 0.8;
	}

	//t = 10;
	d = document.getElementById(div_id);
	d.style.position = "absolute";
	d.style.top = t + "px";
	d.style.left = l + "px";
	d.style.width = w + "px";
	d.style.height = h + "px";
	d.style.zIndex = 999;
	//d.style.display= (d.style.display != "block") ? "block" : "none";
	d.style.display=  "block";
	d.className = dclass;

	// this is a temporary hack
	window.scrollTo(0,0);
	if (b_version.indexOf("MSIE ") >= 0)
		window.onscroll = prevent_scrolling;
	else
		document.onscroll = prevent_scrolling;
		
	curModal.div_id = div_id;
	curModal.w = w;
	curModal.h = h;
	curModal.dclass = dclass;
}

function closeModal()
{
	dx = document.getElementById("mbox_bg");
	div_id = dx.getAttribute("inner_id");
	d = document.getElementById(div_id);
	d.style.display = "none";
	dx.style.display = "none";
	if (b_version.indexOf("MSIE ") >= 0) {
		window.onscroll = null;
	}
	else
		document.onscroll = null;	
		
	curModal = {};
}


function prevent_scrolling()
{
	window.scrollTo(0,0);
}
