/**
 * this function will bring up a calendar window to select a given date
 * @param obj an object that is used to place the pop up window
 * @param target the variable that is to be set, e.g. myform.myelement.value
 */
function drawCalendar(obj, target) {
	myWindow = window.open("/includes/calendar.jsp?formTarget=" + target, "tinyWindow", 
		"width=300,height=300, left=" + (findPosX(obj) - 100 + window.screenLeft) + ", top=" + (findPosY(obj) - 100 + window.screenTop + 
		"screenX=" + (findPosX(obj) - 100 + window.screenLeft) + ", screenY=" + (findPosY(obj) - 100 + window.screenTop))); 

	return myWindow;
}

/**
 * this function will bring up a selection window to choose a resource
 * @param obj an object that is used to place the pop up window
 * @param target the variable that is to be set, e.g. myform.myelement.value
 * @param resourceID the resource that the tree will display from
 * @param mode how the resource will be returned, options are LINK or ID

<form name=test>
<input type=text name="myfield" readonly size=20 maxlength=100>
			<a href="javascript:win = drawResourceSelection(this, 'test.myfield.value', <%=hdrResourceID%>, 'LINK'); win.focus();"><img border=0 src='/images/lists/ModuleID_30.gif'></a></td>
</form>

 */
function drawResourceSelection(obj, target, resourceID, mode) {
	myWindow = window.open("/includes/resourceSelection.jsp?resourceID=" + resourceID + "&formTarget=" + target + "&resourceSelectMode=" + mode, "tinyWindow", 
		"toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=450, left=" + (findPosX(obj) - 100 + window.screenLeft) + ", top=" + (findPosY(obj) - 100 + window.screenTop + 
		"screenX=" + (findPosX(obj) - 100 + window.screenLeft) + ", screenY=" + (findPosY(obj) - 100 + window.screenTop))); 

	return myWindow;
}

/**
 * this function will bring up a selection window to choose a database field
 * @param obj an object that is used to place the pop up window
 * @param target the variable that is to be set, e.g. myform.myelement.value
 * @param resourceID the resource that the tree will display from

<form name=test>
<input type=text name="myfield" readonly size=20 maxlength=100>
			<a href="javascript:win = drawResourceSelection(this, 'test.myfield.value', <%=hdrResourceID%>); win.focus();"><img border=0 src='/images/lists/ModuleID_30.gif'></a></td>
</form>

 */
function drawDBFieldSelection(obj, target, resourceID) {
	myWindow = window.open("/includes/tableFieldSelection.jsp?resourceID=" + resourceID + "&formTarget=" + target, "tinyWindow", 
		"toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=450, left=" + (findPosX(obj) - 100 + window.screenLeft) + ", top=" + (findPosY(obj) - 100 + window.screenTop + 
		"screenX=" + (findPosX(obj) - 100 + window.screenLeft) + ", screenY=" + (findPosY(obj) - 100 + window.screenTop))); 

	return myWindow;
}

/**
 * launches a window to display the image that is passed in
 * @param url the url to the image that is to be displayed
 * @param width the width of the window
 * @param height the height of the window
 */
function displayImage(obj, url, width, height) {
	myWindow = window.open("/modules/utility/imageDisplay.jsp?image=" + url, "", 
		"toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height + ", left=" + (findPosX(obj) - 100 + window.screenLeft) + ", top=" + (findPosY(obj) - 100 + window.screenTop + 
		"screenX=" + (findPosX(obj) - 100 + window.screenLeft) + ", screenY=" + (findPosY(obj) - 100 + window.screenTop))); 
}

function swapImage(imageName, image) {
    document.images[imageName].src = image.src;
}


function popUp(URL, params) {
    day = new Date();
    id = day.getTime();
    window.open(URL + "?" + params, "", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=550,left=0,top=0");
}

