function browserHeight(){
  bHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    bHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'    
    bHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    bHeight = document.body.clientHeight;
  }
  return bHeight;
}

function browserWidth(){
  bWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    bWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'    
    bWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    bWidth = document.body.clientWidth;
  }
  return bWidth;
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function showOverlay(boxWidth,boxHeight,boxContent){
	if(boxWidth == null){
		boxWidth = '300';
	}
	if(boxHeight == null){
		boxHeight = '100';
	}
	try{		
		var over = document.getElementById('over');
		over.style.width = '100%';
		
		var box = document.getElementById('box');
		box.style.display = 'inline';
		box.style.visibility = 'visible';	
		box.style.width = boxWidth + 'px';
		box.style.height = boxHeight + 'px';
		box.innerHTML = boxContent;
		//center the box
		var divtop = (browserHeight() /2) - (boxHeight / 2);
		if(divtop < 10){
			divtop = 10;
		}
		
		box.style.top = divtop + 'px';
		box.style.left = (document.body.clientWidth / 2) - (boxWidth /2) + 'px'
		setOpacity(box,100);
		
		 if(window.scrollMaxY > browserHeight()){
			  var bHeight = window.scrollMaxY + browserHeight();
		  }else{
			  var bHeight = browserHeight();
		  }
		over.style.height = bHeight + 'px';
		over.style.display = 'block';
		over.style.visibility = 'visible';	

		setOpacity(over,60);		
	}
	catch(e){
//		alert(e);
	}
}

function hideOverlay(){
	try{
		var over = document.getElementById('over');
		var box = document.getElementById('box');
		setOpacity(over,0);
		setOpacity(box,0);
		box.style.border = '1px solid #000';
		window.setTimeout('hideOverlayTimeout()',100);
	}
	catch(e){
//		alert(e);
	}
}

function hideOverlayTimeout(){
	var over = document.getElementById('over');
	over.style.display = 'none';
	over.style.visibility = 'hidden';
	var box = document.getElementById('box');
	box.style.display = 'none';
	box.style.visibility = 'hidden';
}
