var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var direction="up"

function popupWindowOpen(id, modal, dropinEffect, closeButton){
  if (modal) disableSite();

  _closeButton = false;
  if (closeButton != null) _closeButton = closeButton;

  if (_closeButton){
    var div = document.createElement('div');
    div.style.height = 20;
    div.className = "verdana18";
    div.align = "right";
    div.innerHTML = "<div><a class = \"verdana18\" href = \"javascript: popupWindowClose('" + id + "')\" target = \"_self\">CLOSE [X]</a></div>";
    div.innerHTML += "<div style = \"background-color: #cbcbcb\"><img src=\"/images/skin/pixel.gif\" height = \"1px\" border=\"0\" vspace=\"0\" hspace=\"0\" /></div>";
    div.id = "id_close_button_" + layer;
    document.getElementById(id).insertBefore(div, document.getElementById(id).firstChild);
  }

  bouncelimit=32;
  if (dropinEffect == null) d = false;
  else d = dropinEffect;
	if (!dom&&!ie&&!ns4)
	return
	//crossobj=(dom)?document.getElementById(id).style : ie? document.all.dropin : document.dropin

  w = document.body.offsetWidth;
  h = document.body.offsetHeight;
  //alert(window.innerHeight);

  if (!FF_browser()) w2 = document.getElementById(id).style.pixelWidth;
  else {
    var w2 = document.getElementById(id).style.width;
    while (!IsNumeric(w2)) w2 = w2.substring(0, w2.length - 1);
  }

	var crossobj=document.getElementById(id).style;
  crossobj.left = Math.round(w / 2 - w2 / 2);
  crossobj.zIndex = layer;
  //alert(crossobj.top + " - " + winH + " - " + elH);
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset;
	if (d) crossobj.top=scroll_top-250+calunits;
	else {
  	if (IE_browser()) winH = document.body.parentElement.offsetHeight;
  	else winH = window.innerHeight;
    elH = document.getElementById(id).offsetHeight;

  	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
    crossobj.top=Math.round(winH / 2 - elH / 2) + scroll_top + calunits;
  }
	crossobj.visibility=(dom||ie)? "visible" : "show"
	dropstart=setInterval("dropin('" + id + "')",50)
}

function dropin(id){
	if (IE_browser()) winH = document.body.parentElement.offsetHeight;
	else winH = window.innerHeight;
  elH = document.getElementById(id).offsetHeight;

	var crossobj=document.getElementById(id).style;
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	if (parseInt(crossobj.top)<Math.round(winH / 2 - elH / 2)+scroll_top)
		crossobj.top=parseInt(crossobj.top)+40+calunits
	else{
		clearInterval(dropstart)
		//bouncestart=setInterval("bouncein('" + id + "')",50)
	}
}

function bouncein(id){
	var crossobj=document.getElementById(id).style;
	crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
	if (bouncelimit<0)
		bouncelimit+=8
		bouncelimit=bouncelimit*-1
	if (bouncelimit==0){
		clearInterval(bouncestart)
	}
}

function popupWindowClose(id){
	if (document.getElementById("id_close_button_" + layer) != null) document.getElementById(id).removeChild(document.getElementById("id_close_button_" + layer));
  if (siteDisabled()) enableSite();
	var crossobj=document.getElementById(id).style;
	crossobj.top = 0;
	crossobj.left = 0;
	if (window.bouncestart) clearInterval(bouncestart)
		crossobj.visibility="hidden";
}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}