var mwOverlayID = 'page_overlay';
var mwOverlayOpacity = '0.2';
var mwTopCorrection = 80;
var mwLeftCorrection = 0;

var currentSelectedRow = "";
function showModalWindow(id){

	var el=document.getElementById(id);
	showOverLay();
	
	//el.style.position='relative';
	el.style.display='block';
		//alert(el.getAttribute("class"));

	/*mwTop = wScrollTop + (winHeight / 2 - el.offsetHeight / 2);
	mwTop = (mwTop > 0) ? mwTop : 0; // Prevent negative value.
	mwLeft = wScrollLeft + (winWidth / 2  - el.offsetWidth / 2);
	mwLeft = (mwLeft > 0) ? mwLeft : 0; // Prevent negative value.
	
	el.style.top=mwTop;
	el.style.left=mwLeft;
	
	alert('mwTop:'+mwTop+' mwLeft:'+mwLeft+' wScrollTop:'+wScrollTop+' wScrollLeft:'+wScrollLeft);
	alert('el.height:'+el.offsetHeight);*/
	
}

function showOverLayForProgress(){
	showOverLayInternal('page_overlay_progress');
}
function hideOverLayForProgress(){
	var ov=document.getElementById('page_overlay_progress');
	ov.style.display='none';
}
function showOverLay(){
	showOverLayInternal(mwOverlayID);
}
function showOverLayInternal(divID){
	var ov=document.getElementById(divID);
	/*if(!ov){
		document.write("<div id='"+mwOverlayID+"'></div>");
	}*/
	 // Get some dimensions we need
    var winWidth = window.innerWidth;
    var winHeight = window.innerHeigth;
    var wScrollTop = document.body.offsetTop;
    var wScrollLeft =document.body.offsetLeft;
    var docHeight = Math.max(document.body.clientWidth,document.body.scrollWidth,window.innerWidth) < 600 ? "600px" : Math.max(document.body.clientWidth,document.body.scrollWidth,window.innerWidth)+"px";
	
	var mwid = Math.max(document.body.clientWidth,  document.body.scrollWidth);
	var mhei = Math.max(document.body.clientHeight, document.body.scrollHeight);
	//alert(document.body.clientWidth + '     '+ document.body.scrollWidth );
	//alert('wdt:'+Math.max(document.body.clientWidth,document.body.scrollWidth, window.innerWidth)+' '+document.body.clientWidth+' '+window.innerWidth);
	ov.style.width= mwid < 600 ? "600px" : mwid +"px";	
	ov.style.height= mhei < 600 ? "600px" : mhei+"px";	
	//ov.style.opacity='0.2';
	ov.style.display='inline';
}

function closeModal(id){
	var el=document.getElementById(id);
	var ov=document.getElementById('page_overlay');
	el.style.display='none';
	ov.style.display='none';
	hideOverLayForProgress();
}

function closeDialog(id){
	var dlg=document.getElementById(id);
	dlg.innerHTML='';
	closeModal(id);
	hideOverLayForProgress();
}