// Wraps the passed in content in a red messagebox and shows the message so that it's arrow/pointer
// points to the top left corner of the control.
// The control passed in can be any DOM element.
// The content passed in can be any DOM element (most likely a layer or or span though). You can 
// control the size of the messagebox by setting the size of the passed-in control.
// The idOfMessageBox must be unique,. This value must be used when you call hideRedPopUpBox.

// NOTICE: For the pop up box to display correctly your site must have an images/redpopupbox folder with the right images in it
// (you can copy these copy from the employer site) as well as a reference to the redpopboxstyles.css 
// (again: this can be copied from the employer site);
function displayInRedPopUp(control,content, idOfMessageBox)
{
	displayInRedPopUpBoxCorrectedPosition(control,content, idOfMessageBox, 0, 0);	
}
function displayInRedPopUpBoxCorrectedPosition(control,content, idOfMessageBox, topCorrection, leftCorrection)
{
	var outerDiv=document.createElement("div");
	outerDiv.id=idOfMessageBox;

	//control.parentNode.insertBefore(outerDiv,control);
	document.body.insertBefore(outerDiv,document.body.childNodes[0]);
	
	outerDiv.style.position="absolute";

	var innerDiv=document.createElement("div");
	innerDiv.className="redpopupbox";
	innerDiv.style.position="absolute";
	innerDiv.style.color="red";
	//innerDiv.style.display="block";
	innerDiv.style.textAlign="left";	
	innerDiv.style.zIndex=251;	
	outerDiv.appendChild(innerDiv);

	var table=document.createElement("table");
	table.border="0";
	table.cellPadding="0";
	table.cellSpacing="0";
	innerDiv.appendChild(table)

	var tbody=document.createElement("tbody");
	table.appendChild(tbody);	
	
	// First row
	var tr1=document.createElement("tr");
	tbody.appendChild(tr1);
	
	var td11=document.createElement("td");
	tr1.appendChild(td11);	
	var imgtd11=document.createElement("img");
	td11.appendChild(imgtd11);
	imgtd11.setAttribute("src","/common/images/redpopupbox/tl.gif");

	var td12=document.createElement("td");
	tr1.appendChild(td12);	
	td12.className="redpopupboxtop";
	td12.setAttribute("colSpan",2);	
	
	var td13=document.createElement("td");
	tr1.appendChild(td13);	
	var imgtd13=document.createElement("img");
	td13.appendChild(imgtd13);
	imgtd13.setAttribute("src","/common/images/redpopupbox/tr.gif");

	// Second row
	var tr2=document.createElement("tr");
	tbody.appendChild(tr2);
	
	var td21=document.createElement("td");
	tr2.appendChild(td21);	
	td21.className="redpopupboxmiddleleft";
	
	var td22=document.createElement("td");
	tr2.appendChild(td22);	
	td22.setAttribute("colSpan",2);	
	td22.appendChild(content);
	var td23=document.createElement("td");
	tr2.appendChild(td23);	
	td23.className="redpopupboxmiddleright";
	
	// Third Row
	var tr3=document.createElement("tr");
	tbody.appendChild(tr3);
	
	var td31=document.createElement("td");
	tr3.appendChild(td31);	
	var imgtd31=document.createElement("img");
	td31.appendChild(imgtd31);
	imgtd31.setAttribute("src","/common/images/redpopupbox/bl.gif");

	var td32=document.createElement("td");
	tr3.appendChild(td32);	
	td32.className="redpopupboxbottom";
	var imgtd32=document.createElement("img");
	td32.appendChild(imgtd32);	
	imgtd32.setAttribute("src","/common/images/redpopupbox/bottomarrow.gif");
	
	var td33=document.createElement("td");
	tr3.appendChild(td33);	
	td33.className="redpopupboxbottom";
	td33.setAttribute("valign","top");
	
	var td34=document.createElement("td");
	tr3.appendChild(td34);	
	td34.setAttribute("valign","top");
	var imgtd34=document.createElement("img");
	td34.appendChild(imgtd34);
	imgtd34.setAttribute("src","/common/images/redpopupbox/br.gif");
		
	//innerDiv.style.left= 300;
	//innerDiv.style.top=150;
		
	// Position and size layers	
	innerDiv.style.left=findPosX(control)+leftCorrection;
	innerDiv.style.top=findPosY(control)+((-1)*innerDiv.offsetHeight)+topCorrection;
	
	//innerDiv.style.left= control.offsetLeft-20+leftCorrection;
	//innerDiv.style.top=((-1)*innerDiv.offsetHeight)+topCorrection;
	
	innerDiv.style.visibility="visible";
	
	outerDiv.style.visibility="visible";
	outerDiv.style.zIndex=250;
	
	// Add iframe behind the pop-up box so IE will hide drop downs
	
	var iframe=document.createElement("iframe");
	iframe.src="javascript:false";
	iframe.setAttribute("scrolling","no");
	iframe.setAttribute("frameborder","0");
	iframe.style.display ='block';
	iframe.style.left=innerDiv.offsetLeft;
	iframe.style.top=innerDiv.offsetTop;
	iframe.style.position="absolute";
	iframe.style.width=innerDiv.offsetWidth;
	iframe.style.height=innerDiv.offsetHeight;
	iframe.style.zIndex=249;
	iframe.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
	outerDiv.appendChild(iframe);	
}

// Removes the element (messagebox) with the passed in id form the DOM. 
function hideRedPopUpBox(idOfMessageBox)
{	
	try
	{
		messageBox=document.getElementById(idOfMessageBox);	
		messageBox.parentNode.removeChild(messageBox);	
	}
	catch(ex)
	{
	}
}
