/* PopulateSearchForm()
 * Take the value from either salary grade or group and put it in a hidden input value, 
 * so we can search the field the data is stored in instead of the dummy domain list field.
 */
function PopulateSearchForm(elem, name)
{		
	ClearFormItems(elem, name);
	
	for(var a=0; a < elem.length; a++)
	{
		if(elem.options[a].selected == true)
		{
			if(elem.options[a].value != "-1")
			{
				var popped = false;
						
				for(var b=0; b < elem.form.elements.length; b++)
				{
					if(elem.form.elements[b].name == name)
					{
						// An element with this name exists. Check to see if it is empty.
						if(elem.form.elements[b].value.length < 1)
						{
							// This element is empty so we can populate with this value.
							elem.form.elements[b].value = elem.options[a].value;
							popped = true;
						}
					}
				}	
			
				if(popped != true)
				{
					// This value has no been populated yet, so we need to create a new element.
					var input = document.createElement("input");
					
					if(! document.all)
					{
						input.setAttribute("type", "hidden");
						input.setAttribute("name", name);
						input.setAttribute("id", name);					
						input.setAttribute("value", elem.options[a].value);					
					}
					else
					{
						input.type = "hidden";
						input.name = name;
						input.id = name;
						input.value = elem.options[a].value;
					}
					
					elem.form.appendChild(input);
				}		
			}
		}
	}
}


/* ClearFormItems()
 * Remove the values from the items we may need to populate.
 */
function ClearFormItems(elem, name)
{
	for(var i=0; i < elem.form.elements.length; i++)
	{
		if(elem.form.elements[i].name == name)
		{
			elem.form.elements[i].value = "";
		}
	}	
}


/* ClearSearchCriteria()
 * Clear the select boxes for salary grade and group that are related to the dummy domain
 * list fields.
 */
function ClearSearchCriteria(frm)
{
	frm.elements["com.peopleclick.cp.formdata.FLD_JOB_SEARCH_SALARY_GRADE"].selectedIndex = 0;
	frm.elements["com.peopleclick.cp.formdata.FLD_JOB_SEARCH_GROUP"].selectedIndex = 0;	
}


////////////////////////////////////////////////////////////////////////////////
// GENERIC (NON)WINDOW POPUP
////////////////////////////////////////////////////////////////////////////////

/*
	Creates a temporary display message that overlays any content on the page.
	Message disappears when the mouse leaves the message window. Display properties
	of the window are defined in the css class "pc-rtg-infoWindowPopup".
	
	@in p_refObj: object that anchors, or positions the message window
	@in p_msg: display message - may contain HTML
*/
function displayInfoWindowPopup(p_refObj, p_msg) {
	var oWindow = getInfoWindowFrame();
	var oBillBoard = getInfoWindowDiv(oWindow);
	
	oBillBoard.innerHTML = p_msg;
	
	// repositioning before the popup is displayed for those browsers that don't 
	// allow element repositioning with the display on
	//alert(dqbCalculateOffset(p_refObj, "offsetLeft", 0));
	oWindow.style.left = oBillBoard.style.left = dqbCalculateOffset(p_refObj, "offsetLeft", -215);
	oWindow.style.top = oBillBoard.style.top = dqbCalculateOffset(p_refObj, "offsetTop", 0);
	oWindow.style.width = oBillBoard.offsetWidth;
	oWindow.style.height = oBillBoard.offsetHeight;
	oWindow.style.zindex = 1000;
	
	oWindow.style.display = oBillBoard.style.display = "";
	
	if(oWindow.style.pixelWidth == 0) {
	// resizing for those browsers that render elements without size until they are displayed
		oWindow.style.width = oBillBoard.offsetWidth;
		oWindow.style.height = oBillBoard.offsetHeight;
	}
}
