// Creates a lightbox panel with the html passed to it
//
// Note: The following prerequisites must already be loaded:
//   /yahoo-dom-event/yahoo-dom-event.js
//   /dragdrop/dragdrop-min.js
//   /container/container-min.js


// shouldn't need to change these:
var contentPadding = 40;
var closeHeight = 20; // height of the close button (in pixels)
var current_panel2; // only one panel at a time!
var anchorElm;

function openLightBox2(
  htmlX,          //html to render within the panel
  widthX,
  heightX,
  ommitClose,     //ommit the "close" button?
  ommitARefClose, //ommit the <a></a> tags encapsulating the div? (this allows you to close the lightbox by clicking on any element within the div)
  headerX,					//html for the header (ommit header if empty)
  x,							//if x AND y are set, then we use these coordinates instead of "auto centering" (x will still auto-center though)
  y
  ) {
  close_lightbox2();
  if (!widthX || widthX == '') {
  	widthX='640';
  }
  if (!heightX || heightX == '') {
  	heightX='480';
  }
	//YAHOO.namespace("example.containerLB");
	function init_lb2(htmlX) {
	  if (x && x != null && y && y !=null) {
	    anchorElm=document.createElement('div');
	    anchorElm.id='hidden_attachpoint2';
	    anchorElm.style.position = 'absolute';
	    anchorElm.style.display='block';
	    anchorElm.style.width=widthX+'px';
	    anchorElm.style.height=heightX+'px';
	    anchorElm.style.zIndex='-9999';
	    //anchorElm.style.backgroundColor='#CCC';
	    //anchorElm.style.color='#CCC';
	    //anchorElm.style.border='1px solid #000';
	    anchorElm.style.top=y+'px';
	    anchorElm.style.left='50%';
		  anchorElm.style.marginLeft= ((-1 * (parseInt(widthX)/2))+x)+'px';
	    document.body.appendChild(anchorElm);
	  }
    var myelm=document.createElement('div');
	  myelm.id='ol_panel2'; 
	  myelm.innerHTML=
		    '<div id="hd2" class="hd">'+(headerX ? headerX : '')+'</div>'+
		    '<div id="bd2" class="bd" style="display:block;height:'+((parseInt(heightX)-contentPadding)-(ommitClose && ommitClose == '1' ? 0 : closeHeight))+'px;width:'+widthX+'px">'+(ommitARefClose && ommitARefClose == '1' ? '' : '<a href="javascript:close_lightbox2();">')+htmlX+(ommitARefClose && ommitARefClose == '1' ? '' : '</a>')+'</div>'+
		    (ommitClose && ommitClose == '1' ? '' : '<div id="ft" class="ft" style="height:'+closeHeight+'px;width:'+widthX+'px"><input type="button" value="Close" onclick="javascript:close_lightbox2();"></div>');
   	document.body.appendChild(myelm);
	  current_panel2 = new YAHOO.widget.Panel('ol_panel2',
	   { width : widthX+"px",
	     height: heightX+"px",
	     zindex: "99999",
		   fixedcenter : (anchorElm && x != null && y != null ? false : true),
		   //monitorresize : true,
		   visible : true,
		   draggable: false,
		   modal: true,
		   close: false,
		   context: (anchorElm && x != null && y != null ? [anchorElm,'tl','tl'] : [null,null,null] ),
		   constraintoviewport : (anchorElm && x != null && y != null ? false : true)
  	} );
		current_panel2.render();
		//current_panel2.showMacGeckoScrollbars();
	}
	init_lb2(htmlX);  	
}

function close_lightbox2() {
	if (current_panel2) {
    current_panel2.hide();	
  }
  var done = document.getElementById('ol_panel2');
  if (done) {
    done.parentNode.removeChild(done);
  	current_panel2 = null;
  }  
  var done2 = document.getElementById('hidden_attachpoint2');
  if (done2) {
    done2.parentNode.removeChild(done2);
  }  
  done=null;
  done2=null;
  anchorElm=null;
}

