end_opacity = 50; //end opacity, 25 = 25%, 50 = 50%, 100 = 100%, etc.
increase_opacity_by = 10; //how much to increase by each time the timeout ends
timeout = 0; //timeout in miliseconds, 0 = instant fade-out

//win = document.getElementById('thewindow');
winbackground = document.getElementById('thewindowbackground');
wincontent = document.getElementById('thewindowcontent');
wininfo = document.getElementById('thewindowinfo');
winok = document.getElementById('thewindowok');
//winyesno = document.getElementById('thewindowyesno');
cur_opacity = 100;

var timer = null;

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function updateWindow(text,type) {
	if (type=="l") {
	  wincontent.style.height = "110px";
		winok.style.display = 'none';
		//winyesno.style.display = 'block';
		}
  if (type=="i") { 
	 wincontent.style.height = "110px";
	 winok.style.display = 'block';
	 //winyesno.style.display = 'none';
	 }
	wininfo.innerHTML = text;
}

function BrowserWH()
{

 winH = window.document.body.clientHeight;
 winW = window.document.body.clientWidth;

 return [ winW , winH ];
}



function showWindow(text,type) {
  fullScreen("thewindowbackground", BrowserWH()[0], "3000");
	if (type=="l") {
	  wincontent.style.height = "110px";
		winok.style.display = 'none';
		//winyesno.style.display = 'block';
		}
  if (type=="i") { 
	 wincontent.style.height = "110px";
	 winok.style.display = 'block';
	 //winyesno.style.display = 'none';
	 }
	if(timeout > 0) {
		cur_opacity = 0;
		winbackground.style.opacity = cur_opacity / 100;
		winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";
		winbackground.style.display = 'block';
		wincontent.style.display = 'none';
		winscry = getScrollXY()[1] + 250;
		wincontent.style.top = winscry + 'px';
		winwidth = wincontent.style.width.replace("px","");
                winscrx = (BrowserWH()[0] / 2) - (winwidth / 2);
		wincontent.style.left = winscrx + 'px';
		timer = setTimeout("increase_opacity()",timeout);
                wininfo.innerHTML = text;
	}
	else {
		winbackground.style.opacity = end_opacity / 100;
		winbackground.style.filter = "alpha(opacity=" + end_opacity + ")";
                winbackground.style.display = 'block';
		wincontent.style.display = 'block';
		winscry = getScrollXY()[1] + 250;
		wincontent.style.top = winscry + 'px';
		winwidth = wincontent.style.width.replace("px","");
                winscrx = (BrowserWH()[0] / 2) - (winwidth / 2);
		wincontent.style.left = winscrx + 'px';
                wininfo.innerHTML = text;
		}
}

function increase_opacity() {
	cur_opacity += increase_opacity_by;

	winbackground.style.opacity = cur_opacity / 100;
	winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";
	
	if(cur_opacity < end_opacity) {
		timer = setTimeout("increase_opacity()",timeout);
	}
	else {
		wincontent.style.display = 'block';
	}
}

function hideWindow() {
	winbackground.style.display = 'none';
	wincontent.style.display = 'none';
}

function fullScreen(_obj, winW, winH){
document.getElementById(_obj).style.width = winW + "px";document.getElementById(_obj).style.height = winH + "px";
}

