var dialogOpen = false;

//MINIMUMS FOR DIALOG
var minDialogWidth=300;
var minDialogHeight=100;
var minDialogWindowPadWidth=100;
var minDialogWindowPadHeight=100;
var tid;
var auxRightPaneOpen = false;

function auxPaneRight_Close()
{
	var m = document.getElementById('auxRightPane');
	if(m != null)
	{
		auxRightPaneOpen = false;
		m.style.width = '1px';
		m.innerHTML = ''
		pageResize();
	}
}

function auxPaneRight_Open()
{
	var m = document.getElementById('auxRightPane');
	if(m != null)
	{
		//m.style.display='table-cell'
		auxRightPaneOpen = true;
		m.style.width = '260px';
		executeRequest('vg','','',false,false);
		pageResize();
	}
}

function auxPaneRight_Toggle()
{
	if(auxRightPaneOpen)
	{
		auxPaneRight_Close();
		auxRightPaneOpen = false;
	}
	else
	{
		auxPaneRight_Open();
		auxRightPaneOpen = true;
	}
}

function sizeDialogDelayed()
{
	//if(tid)	window.clearTimeout(tid);

	var m = document.getElementById('dialogPane');
	if(m && m.childNodes && m.childNodes.length > 0)
	{
		var child = m.childNodes[0];
		//alert(child.id)
		//alert("size=" + child.offsetWidth + ","+child.offsetHeight)
		sizeDialog(null, child.offsetWidth, child.offsetHeight);
		openDialog();
	}
}

// Resize content area of dialog box
function sizeDialog(contentID, width, height)
{
	  
	  // OVERLOADING TO SEE IF DISPLAY IS CALLED
	 //var reposition = (arguments[3]==null) ? true : arguments[3];
	 //var sizeFromContent = (arguments[2]==null) ? true : arguments[2]
	   
	  //resize from a content object, not static w/h input
	  if (contentID != null && contentID.length != 0)
	  {
		  
		  var contentObj = getObjectFromID(contentID);
		  
		  if (contentObj != null)
		  {
			  width=contentObj.offsetWidth;
			  height=contentObj.offsetHeight;
		  }
	  }
	  else
	  {
		//width = width + 30;  
		height += 30  
	  }
	  
		  
	                                                           
	// Maximum size allowed by the Dialog should be 
	// Screen width - 200px
	// Screen height - 200px;
	var dialog = getObjectFromID('dialogWindow');
	var dialogMid = getObjectFromID('dialogMid');
	var dialogPane = getObjectFromID('dialogPane');
	var dialogMidRight = getObjectFromID('dialogMidRight');
	var dialogHeader = getObjectFromID('dialogHeader');
	var dialogHeaderPane = getObjectFromID('dialogHeaderPane');
	var dialogFooter = getObjectFromID('dialogFooter');
	var dialogFooterRepeat = getObjectFromID('dialogFooterRepeat');

	if(width){} else {width = 400};
	if(height){} else {height = 400};
	
	// TEST WHAT THE NEW WIDTH AND HEIGHT OF BOUNDING BOX WILL BE
	var overallOffsetWidth=width-dialogPane.offsetWidth;
	var overallOffsetHeight=height-dialogPane.offsetHeight+10;

	// MAX MIN TESTS
	if (overallOffsetWidth+dialog.offsetWidth > GetWidth()-(minDialogWindowPadWidth*2))
	{
		overallOffsetWidth = GetWidth()-minDialogWindowPadWidth-dialog.offsetWidth;
	}
	else if (overallOffsetWidth+dialog.offsetWidth < minDialogWidth) // minimum size
	{
		overallOffsetWidth = minDialogWidth-dialog.offsetWidth;
	}
	
	// MAX MIN TEST
	if (overallOffsetHeight+dialog.offsetHeight > GetHeight()-(minDialogWindowPadHeight*2))
	{
		overallOffsetHeight = GetHeight()-minDialogWindowPadHeight-dialog.offsetHeight;
	}
	else if (overallOffsetHeight+dialog.offsetHeight < minDialogHeight) // minimum size
	{
		overallOffsetHeight = minDialogWidth-dialog.offsetHeight;
	}
	
	// NOW RESET DIV
	// MAIN DIALOG WINDOW
	dialog.style.width = dialog.offsetWidth+overallOffsetWidth+'px';
	dialog.style.height = dialog.offsetHeight+overallOffsetHeight+'px';
	// HEADER REPEAT
	dialogHeaderPane.style.width = dialogHeaderPane.offsetWidth+overallOffsetWidth+'px';
	// CONTENT AREA
	dialogMid.style.height = dialogMid.offsetHeight+overallOffsetHeight+'px';
	dialogPane.style.width = dialogPane.offsetWidth+overallOffsetWidth+'px';
	// FOOTER
	dialogFooterRepeat.style.width = dialogFooterRepeat.offsetWidth+overallOffsetWidth+'px';
	
	// for some reason this is required for safari
	// must refresh the buffer??
	dialog.style.display='none';
	dialog.style.display='';

	
	
	/*if (reposition)
	{
    	// refresh the position;
    	openDialog();
	}*/

}

function openDialog() {
	
	
	
	var containerID = (arguments[0]==null) ? null : arguments[0];
	var width = (arguments[1]==null) ? minDialogWidth : arguments[1];
	var height = (arguments[2]==null) ? minDialogHeight : arguments[2];
	var resize = (arguments[3]==null) ? true : arguments[3];

	
	
	if (containerID != null && containerID.length != 0)
		sizeDialog(containerID, width, height); // from layoutRenderer.js
	
	//resize from a content object, not static w/h input
	// need this for the reg/login pages
	 /* if (containerID != null && containerID.length != 0)
	  {
		  
		  var contentObj = getObjectFromID(containerID);
		  
		  if (contentObj != null)
		  {
			  width=contentObj.offsetWidth;
			  height=contentObj.offsetHeight;
			  alert(width+" "+height);
		  }
	  }*/
	
	
	var modalBG = getObjectFromID('dialogBG');
	var dialog = getObjectFromID('dialogWindow');
	var dialogContent = getObjectFromID('dialogPane');
	/* reposition modal background */
	modalBG.style.left = '0px';
	modalBG.style.top = '0px';
	modalBG.style.width = GetWidth() + 'px';
	modalBG.style.height = GetHeight() + 'px';
	/* reposition dialogue Box */
	dialog.style.left = (GetWidth() / 2) - (dialog.offsetWidth / 2) + 'px';
	dialog.style.top = (GetHeight() / 2) - (dialog.offsetHeight / 2) + 'px';
	/* REMOVE FOR PRODUCTION */
	/*
	 * dialogContent.innerHTML='<a href="#"
	 * onClick="executeRequestWithPop(\'\',\'\',\'\',true)">close</a>';
	 */
	dialogOpen = true;
	
	//tid = window.setTimeout(function(){sizeDialogDelayed()}, 500);
}

function closeDialog() {
	dialogOpen = false;
	var modalBG = getObjectFromID('dialogBG');
	var dialog = getObjectFromID('dialogWindow');
	var dialogContent = getObjectFromID('dialogPane');
	dialogContent.innerHTML = null
	/* reposition modal background */
	modalBG.style.left = -modalBG.offsetWidth - 1000 + 'px';
	/* reposition dialogue Box */
	dialog.style.left = -dialog.offsetWidth - 1000 + 'px';
	/* dialogContent.innerHTML=''; */

	// minDialogWidth, minDialogHeight are pulled from layoutRenderer
	// as the default min width and min height
	sizeDialog(null, minDialogWidth, minDialogHeight);
}





/***********************************************************/
/***********************************************************/
/***********************************************************/
/*
 *  Popout Dialogue (rebranding, etc)
 */
/***********************************************************/
/***********************************************************/

// will hold the timeout for showing / hiding window
var PD_Delay = 500; // milliseconds
var PD_Offsety = 0;
var PD_Maxheight = 300;
var PD_OpenPDList = new Array();
var PD_OpenPDList_timeout = new Array();



function PD_AddToOpenAList(asName)
{
	PD_OpenPDList.push(asName);
	PD_SetTimeout(asName);
}


function PD_RemoveFromOpenAList(asName)
{
	
	PD_KillTimeout(asName);
	PD_OpenPDList_timeout[asName] = null;
	
	for(var i=0;i<PD_OpenPDList.length;i++)
	{
		if(PD_OpenPDList[i] == asName)
		{
			PD_OpenPDList.splice(i,1);
			//alert('sz=' + PD_OpenASList.length) 
			return;
		}
	}
}


function PD_SetTimeout(asName)
{
	PD_OpenPDList_timeout[asName] = window.setTimeout(function(){PD_ClosePD(asName);}, 500);
}

function PD_KillTimeout(asName)
{
	window.clearTimeout(PD_OpenPDList_timeout[asName]);
}


function PD_OnButtonClick(asName)
{
	//alert('AS_OnButtonClick ' + asName)
	PD_KillTimeout(asName);
	PD_OpenPD(asName);
	return true;
}



function PD_ClosePD(asName)
{
	//this.killTimeout();
	
	var partnerShadow = document.getElementById(asName + '_shadow');
	partnerShadow.className = "rebrandOvershadow";
	
	PD_RemoveFromOpenAList(asName)
	
	var divcontainer = document.getElementById("rebrand_window_show_Tabs");
	divcontainer.style.right = "-2000px";
	divcontainer.style.top = "-2000px";

	//var ele = _bsn.DOM.getElement(asName + '_divcontainer');
	//_bsn.DOM.removeElement(asName + '_divcontainer');
	//if (ele)
	//{
	//	var fade = new _bsn.Fader(ele,1,0,250,function () { _bsn.DOM.removeElement(asName + '_divcontainer') });
	//}
	//var hli = _bsn.DOM.getElement(asName + "_hli");
	//hli.value = '-1'
}


function PD_OpenPD(asName)
{
	//alert('AS_CreateList');

	// get rid of old list
	// and clear the list removal timeout
	//
	var divcontainerId = asName + '_divcontainer';
	
	
	var partnerShadow = document.getElementById(asName + '_shadow');
	partnerShadow.className = "rebrandOvershadowHover";
	
	/*
	
	
	//AS_ClearSuggestions(asName);

	//var request = "AS_DoAjaxRequest('" + asName + "')"
	//TODOwindow.clearTimeout(request);
	
	//var sInput = document.getElementById(asName + '_anchor').value
	
	// create holding div
	//
	var divcontainer = _bsn.DOM.createElement("div", {id:divcontainerId, className:"rebrand_window"});
	//var div = _bsn.DOM.createElement("div", {id:divcontainerId, className:"autosuggestlist"});
	// add list to container
	
	var tablecontainer = _bsn.DOM.createElement("table", {className:"rebrand_table"});
	tablecontainer.setAttribute("cellPadding","0");
	tablecontainer.setAttribute("cellSpacing","0");
	tablecontainer.setAttribute("border","0");
	var tablebody = _bsn.DOM.createElement("tbody");
	tablebody.setAttribute("cellPadding","0");
	tablebody.setAttribute("cellSpacing","0");
	
	var tablebody2 = _bsn.DOM.createElement("tbody");
	//divcontainer.appendChild(tablecontainer);
	//divcontainer.appendChild(div);
	
	// TOP
	var tablerow = _bsn.DOM.createElement("tr");
	var tl = _bsn.DOM.createElement("td", {className:"rebrand_tl"});
	var top = _bsn.DOM.createElement("td", {className:"rebrand_t"});
	var tr = _bsn.DOM.createElement("td", {className:"rebrand_tr"});
	tablerow.appendChild(tl);
	tablerow.appendChild(top);
	tablerow.appendChild(tr);
	tablebody.appendChild(tablerow);

	// HEADER
	tablerow2 =  _bsn.DOM.createElement("tr");
	var hl = _bsn.DOM.createElement("td", {className:"rebrand_header_l"});
	var head = _bsn.DOM.createElement("td", {id:"rebrandHeaderPane",className:"rebrand_header"});
	var hr = _bsn.DOM.createElement("td", {className:"rebrand_header_r"});
	
	tablerow2.appendChild(hl);
	tablerow2.appendChild(head);
	tablerow2.appendChild(hr);
	tablebody.appendChild(tablerow2);

	// HEADERBOTTOM
	tablerow3 =  _bsn.DOM.createElement("tr");
	var tablecol1 = _bsn.DOM.createElement("td");
	tablecol1.setAttribute("colSpan","3");
	tablecol1.setAttribute("width","100%");
	var tablecontainer12 = _bsn.DOM.createElement("table");
	tablecontainer12.setAttribute("cellPadding","0");
	tablecontainer12.setAttribute("cellSpacing","0");
	tablecontainer12.setAttribute("width","100%");
	var tablerow12 =   _bsn.DOM.createElement("tr");
	var hbl = _bsn.DOM.createElement("td", {className:"rebrand_header_bl"});
	var headb = _bsn.DOM.createElement("td", {id:"rebrandHeaderTabs", className:"rebrand_header_b"});
	var hbr = _bsn.DOM.createElement("td", {className:"rebrand_header_br"});
	tablerow12.appendChild(hbl);
	tablerow12.appendChild(headb);
	tablerow12.appendChild(hbr);
	tablebody2.appendChild(tablerow12);
	tablecontainer12.appendChild(tablebody2);
	tablecol1.appendChild(tablecontainer12);
	tablerow3.appendChild(tablecol1);
	tablebody.appendChild(tablerow3);

	// CONTENT
	tablebody2 = _bsn.DOM.createElement("tbody");
	var tablerow4 =  _bsn.DOM.createElement("tr");
	var tablecol2 = _bsn.DOM.createElement("td");
	tablecol2.setAttribute("colSpan","3");
	tablecol2.setAttribute("width","100%");
	var tablecontainer22 = _bsn.DOM.createElement("table");
	tablecontainer22.setAttribute("cellPadding","0");
	tablecontainer22.setAttribute("cellSpacing","0");
	tablecontainer22.setAttribute("border","0");
	tablecontainer22.setAttribute("width","100%");
	var tablerow22 =   _bsn.DOM.createElement("tr");
	var content_l = _bsn.DOM.createElement("td", {className:"rebrand_content_l"});
	var content = _bsn.DOM.createElement("td", {className:"rebrand_content"});
	var content_r = _bsn.DOM.createElement("td", {className:"rebrand_content_r"});
	var contentContainer = _bsn.DOM.createElement("div", {id:"rebrandContentPane", className:"rebrandContentPanel"});
	content.appendChild(contentContainer);
	tablerow22.appendChild(content_l);
	tablerow22.appendChild(content);
	tablerow22.appendChild(content_r);
	tablebody2.appendChild(tablerow22);
	tablecontainer22.appendChild(tablebody2);
	tablecol2.appendChild(tablecontainer22);
	tablerow4.appendChild(tablecol2);
	tablebody.appendChild(tablerow4);

	// BOTTOM
	var tablerow5 =  _bsn.DOM.createElement("tr");
	var bl = _bsn.DOM.createElement("td", {className:"rebrand_bottom_l"});
	var bottom = _bsn.DOM.createElement("td", {className:"rebrand_bottom"});
	var br = _bsn.DOM.createElement("td", {className:"rebrand_bottom_r"});
	tablerow5.appendChild(bl);
	tablerow5.appendChild(bottom);
	tablerow5.appendChild(br);
	tablebody.appendChild(tablerow5);
	
	tablecontainer.appendChild(tablebody);
	
	var divcontainerHeight = 0;
*/

	// create and populate ul
	
	// get position of target textfield
	// position holding div below it
	// set width of holding div to width of field
	//
	var divcontainer = document.getElementById("rebrand_window_show_Tabs");
	var partnerContainer = document.getElementById(asName + '_anchor');
	//alert(partnerContainer)
	var pos = _bsn.DOM.getPos(partnerContainer);
	var posy = YAHOO.util.Dom.getY(partnerContainer);
	//alert(posy)
	var posx = YAHOO.util.Dom.getX(partnerContainer);
	//alert(posx)
	//alert(GetWidth())
	//alert(partnerContainer.offsetWidth)
	//divcontainer.style.right 		= GetWidth() + 4 - partnerContainer.offsetWidth - posx + "px";
	//divcontainer.style.right 		= posx + partnerContainer.offsetWidth + "px";
	divcontainer.style.left = posx + partnerContainer.offsetWidth - divcontainer.offsetWidth + "px";
	//alert(divcontainer.style.right)
	divcontainer.style.top 		= ( posy + partnerContainer.offsetHeight + AS_Offsety - 14) + "px";
	//alert(divcontainer.style.top)
	
	// set mouseover functions for div
	// when mouse pointer leaves div, set a timeout to remove the list after an interval
	// when mouse enters div, kill the timeout so the list won't be removed
	//
	divcontainer.onmouseover = function(){PD_RemoveFromOpenAList(asName);}
	divcontainer.onmouseout = function(){PD_AddToOpenAList(asName);}


	// add DIV to document
	//
	//document.getElementsByTagName("body")[0].appendChild(divcontainer);
	
	//executeRequest("*", "", "");
	
}


/***********************************************************/
/***********************************************************/
/***********************************************************/
/*
 *  List Popout Dialogue [QUICKPANEL] (rebranding, etc)
 */
/***********************************************************/
/***********************************************************/

// will hold the timeout for showing / hiding window
var LPD_Delay_out = 500; // milliseconds
var LPD_Delay_on = 1500; // milliseconds
var LPD_Delay_Repos_on = 500; // milliseconds
var LPD_Offsety = 0;
var LPD_Maxheight = 300;
var LPD_OpenPDList = new Array();
var LPD_OpenPDList_timeout = new Array();
var LPD_OpenPDList_timeon = new Array();
var LPD_OpenPDList_isshow = new Array();
var LPD_HoverHandler = new Array();
var LPD_HoverParameter = new Array();
var LPD_PrevRowClass='';
var LPD_HoverPause = new Array();
var LPD_HoverPause_bol = false;


var mouseX;
var mouseY;
var elementXRight;



function LPD_AddToOpenAList(asName)
{
	LPD_OpenPDList.push(asName);
	LPD_SetTimeout(asName);
}


function LPD_RemoveFromOpenAList(asName)
{
	
	LPD_KillTimeout(asName);
	LPD_OpenPDList_timeout[asName] = null;
	
	for(var i=0;i<LPD_OpenPDList.length;i++)
	{
		if(LPD_OpenPDList[i] == asName)
		{
			LPD_OpenPDList.splice(i,1);
			//alert('sz=' + LPD_OpenASList.length) 
			return;
		}
	}
}

function LPD_CheckIfInAList(asName)
{
	for(var i=0;i<LPD_OpenPDList.length;i++)
	{
		if(LPD_OpenPDList[i] == asName)
		{ 
			return true;
		}
	}
	
	return false;
}


function LPD_SetTimeout(asName)
{
	LPD_OpenPDList_timeout[asName] = window.setTimeout(function(){LPD_ClosePD(asName);}, LPD_Delay_out);
}

function LPD_KillTimeout(asName)
{
	window.clearTimeout(LPD_OpenPDList_timeout[asName]);
	LPD_OpenPDList_timeon[asName] = null; // make sure you clear the time-on timeout.
}

function LPD_SetTimeon(asName)
{
	//if (LPD_OpenPDList_timeon[asName] == null)
		LPD_OpenPDList_timeon[asName] = window.setTimeout(function(){LPD_OpenPD(asName);}, LPD_Delay_on);
}

function LPD_SetTimeReposon(asName)
{
	//if (LPD_OpenPDList_timeon[asName] == null)
		LPD_OpenPDList_timeon[asName] = window.setTimeout(function(){LPD_SetLocation(asName);}, LPD_Delay_Repos_on);
}

function LPD_KillTimeon(asName)
{
	window.clearTimeout(LPD_OpenPDList_timeon[asName]);
	LPD_OpenPDList_timeon[asName] = null; // make sure you clear the time-on timeout.
}

function LPD_Pause(asName, listItem, runHover)
{
	//LPD_HoverPause[asName] = true;
	LPD_HoverPause_bol = true;
	LPD_OnListOut(asName, listItem, runHover);
	return true;
}

function LPD_UnPause(asName)
{
	LPD_HoverPause_bol = false;
	//LPD_HoverPause[asName] = null;
	return true;
}


function LPD_OnListOver(asName, listItem, runHover, hoverHandler, parameters)
{
	LPD_PrevRowClass = listItem.className;
	listItem.className = 'listRowOver';
	
	// ENSURE NOT PAUSED!
	if (runHover && !LPD_HoverPause_bol)
	{
		var curTop;
		var curLeft;
		var curWidth;
		var scrollT = 0;
		var gotScroll=false;
		//THIS ALLOWS US TO FIND THE LOCATION OF THE CURRENT ROW
		if (listItem.offsetParent) {
			
			curTop = listItem.offsetTop;
			curLeft = listItem.offsetLeft;
			curWidth = listItem.offsetWidth;
			scrollT = listItem.scrollTop;
			
			while(listItem.offsetParent!=null) {
				objParent = listItem.offsetParent;
				scrollT += objParent.scrollTop;
				curTop += objParent.offsetTop;
				curLeft += objParent.offsetLeft;
				listItem = objParent;
			}
		}
		mouseY = curTop + 8 - scrollT;// middle of cell
		// get the Y location of the right edge of the element
		// Will use this for positioning the quickPanel
		elementXRight = curLeft + curWidth;

		LPD_HoverHandler[asName] = hoverHandler;
		LPD_HoverParameter[asName] = parameters;

		if (!LPD_OpenPDList_isshow[asName])
		{
			// WE WANT TO CREATE NEW, BECAUSE IT DOES NOT YET EXIST
			LPD_KillTimeout(asName);
			LPD_SetTimeon(asName);
		}
		else
		{
			// IT EXISTS, SO SET TO NEW LOCATION AND RE-RENDER DATA
			LPD_KillTimeout(asName);
			LPD_SetTimeReposon(asName);
		}
	}
	
	return true;
}

function LPD_OnListOut(asName, listItem, runHover)
{
	listItem.className = 'listRowOver';
	listItem.className = LPD_PrevRowClass;
	
	
	if (runHover)
	{
		if (LPD_OpenPDList_isshow[asName])
			LPD_SetTimeout(asName);
		LPD_KillTimeon(asName);
		
	}
	
	return true;
}



function LPD_ClosePD(asName)
{
	//this.killTimeout();
	//alert(asName+'close');
	LPD_OpenPDList_isshow[asName] = false;
	//return true;
	
	/*var partnerShadow = document.getElementById(asName + '_shadow');
	partnerShadow.className = "rebrandOvershadow";*/
	
	LPD_RemoveFromOpenAList(asName)
	
	var ele = _bsn.DOM.getElement(asName + '_divcontainer');
	_bsn.DOM.removeElement(asName + '_divcontainer');
	//if (ele)
	//{
	//	var fade = new _bsn.Fader(ele,1,0,250,function () { _bsn.DOM.removeElement(asName + '_divcontainer') });
	//}
	var hli = _bsn.DOM.getElement(asName + "_hli");
	hli.value = '-1'
}


function LPD_OpenPD(asName)
{
	//alert(asName+'open');
	LPD_OpenPDList_isshow[asName] = true;
	//return true;

	// get rid of old list
	// and clear the list removal timeout
	//
	var divcontainerId = asName + '_divcontainer';
	
	
	/*var partnerShadow = document.getElementById(asName + '_shadow');
	partnerShadow.className = "rebrandOvershadowHover";*/
	
	
	// create holding div
	//
	var divcontainer = _bsn.DOM.createElement("div", {id:divcontainerId, className:"quickPanelWindow"});
	//var div = _bsn.DOM.createElement("div", {id:divcontainerId, className:"autosuggestlist"});
	// add list to container
	
	var tablecontainer = _bsn.DOM.createElement("table");
	tablecontainer.setAttribute("cellPadding","0");
	tablecontainer.setAttribute("cellSpacing","0");
	tablecontainer.setAttribute("border","0");
	var tablebody = _bsn.DOM.createElement("tbody");
	tablebody.setAttribute("cellPadding","0");
	tablebody.setAttribute("cellSpacing","0");
		
	// TOP
	var tablerow = _bsn.DOM.createElement("tr");
	var tl = _bsn.DOM.createElement("td", {className:"quickPanelHeadL"});
	var top = _bsn.DOM.createElement("td", {className:"quickPanelHead"});
	var tr = _bsn.DOM.createElement("td", {className:"quickPanelHeadR"});
	var div_spacer = _bsn.DOM.createElement("div");
	tl.appendChild(div_spacer);
	tr.appendChild(div_spacer);
	tablerow.appendChild(tl);
	tablerow.appendChild(top);
	tablerow.appendChild(tr);
	tablebody.appendChild(tablerow);
	
	// CONTENT
	var tablerow2 = _bsn.DOM.createElement("tr");
	var midFull = _bsn.DOM.createElement("td", {className:"quickPanelMidFull"});
	midFull.setAttribute("colSpan","3");
	var tableContentFull = _bsn.DOM.createElement("table", {className:"quickPanelMidFullTbl"});
	tableContentFull.setAttribute("cellPadding","0");
	tableContentFull.setAttribute("cellSpacing","0");
	tableContentFull.setAttribute("border","0");
	var tablebodyContent = _bsn.DOM.createElement("tbody");
	tablebodyContent.setAttribute("cellPadding","0");
	tablebodyContent.setAttribute("cellSpacing","0");
	
	var tablerowFull = _bsn.DOM.createElement("tr");
	var ml = _bsn.DOM.createElement("td", {className:"quickPanelMidL"});
	var mid = _bsn.DOM.createElement("td", {className:"quickPanelMid"});
	var mr = _bsn.DOM.createElement("td", {className:"quickPanelMidR"});
	var pLeft = _bsn.DOM.createElement("div", {id:asName+"_lpoint",className:"leftPointer"});

	/*var ml = _bsn.DOM.createElement("td", {className:"quickPanelMidL"});
	var mid = _bsn.DOM.createElement("td", {className:"quickPanelMid"});
	var mr = _bsn.DOM.createElement("td", {className:"quickPanelMidR"});*/
	
	ml.appendChild(pLeft);
	tablerowFull.appendChild(ml);
	tablerowFull.appendChild(mid);
	tablerowFull.appendChild(mr);
	tablebodyContent.appendChild(tablerowFull);
	tableContentFull.appendChild(tablebodyContent);
	midFull.appendChild(tableContentFull);
	tablerow2.appendChild(midFull);
	tablebody.appendChild(tablerow2);
	
	
	/*ml.appendChild(pLeft);
	tablerow2.appendChild(ml);
	tablerow2.appendChild(mid);
	tablerow2.appendChild(mr);
	tablebody.appendChild(tablerow2);*/

	// BOTTOM
	var tablerow3 =  _bsn.DOM.createElement("tr");
	var bl = _bsn.DOM.createElement("td", {className:"quickPanelFootL"});
	var bottom = _bsn.DOM.createElement("td", {className:"quickPanelFoot"});
	var br = _bsn.DOM.createElement("td", {className:"quickPanelFootR"});
	tablerow3.appendChild(bl);
	tablerow3.appendChild(bottom);
	tablerow3.appendChild(br);
	tablebody.appendChild(tablerow3);
	
	tablecontainer.appendChild(tablebody);
	
	var divcontainerHeight = 0;

	// create and populate ul
	/*var ul = _bsn.DOM.createElement("ul", {id:asName + "_as_ul"});
		
	var aHtml = "<li>Hello there</li>";
	
	ul.innerHTML += aHtml;
	
	mid.appendChild(ul);*/
	
	var cnt = _bsn.DOM.createElement("div", {id:"hoverPane"});
	cnt.style.width="100%";
	cnt.style.height="100%";
	mid.appendChild(cnt)
	
	//alert('cnt=' + cnt.id)
	/*
	cnt.innerHTML = asName;
	if(LPD_HoverHandler)
	{
		cnt.innerHTML += " 1 ";
		if(LPD_HoverHandler[asName])
		{
			cnt.innerHTML += " 2 " + LPD_HoverHandler[asName];
		}
	}
	mid.appendChild(cnt);
    */
    
    //alert(LPD_HoverParameter[asName])
    
	divcontainer.appendChild(tablecontainer);

	//var q = document.getElementById('hoverPane');
	//alert('hpa=' + q)

	
	
	
	// set mouseover functions for div
	// when mouse pointer leaves div, set a timeout to remove the list after an interval
	// when mouse enters div, kill the timeout so the list won't be removed
	//
	divcontainer.onmouseover = function(){LPD_RemoveFromOpenAList(asName);}
	divcontainer.onmouseout = function(){LPD_AddToOpenAList(asName);}


	// add DIV to document
	//
	document.getElementsByTagName("body")[0].appendChild(divcontainer);
	
	LPD_SetLocation(asName);
}

function LPD_SetLocation(asName)
{
	var holdHeight = 0;
	holdHeight = getObjectFromID("hoverPane").offsetHeight;
	getObjectFromID("hoverPane").innerHTML = "<div style=\"float:left;height:"+(holdHeight==0?20:holdHeight)+"px;width:5px;\">&nbsp;</div>"; // CLEAR CONTENTS SO NO PROPEGATION OF DATA
	executeRequest(LPD_HoverHandler[asName], "Hover", LPD_HoverParameter[asName], false, false);
	
	
	var divcontainer =  getObjectFromID(asName + '_divcontainer');
	var divpointer = getObjectFromID(asName+"_lpoint");
	
	// X Positioning
	if ((elementXRight + divcontainer.offsetWidth) > GetWidth())
	{
		divcontainer.style.left = (GetWidth()-divcontainer.offsetWidth)+"px";
	}
	else
	{
		divcontainer.style.left = elementXRight-10+"px";
	}
	// Y Positioning
	if ((mouseY-20+divcontainer.offsetHeight) > GetHeight())
	{
		// DON'T FORGET ABOUT scrollTop!
		divcontainer.style.top = GetHeight()-divcontainer.offsetHeight+"px";
		divpointer.style.top = 8+((mouseY-20)-(GetHeight()-divcontainer.offsetHeight))+"px";
		//alert((GetHeight()-divcontainer.offsetHeight)+' '+(mouseY-20));
	}
	else
	{
		divpointer.style.top = "8px";
		divcontainer.style.top = mouseY-20+'px';
	}
}

