/*
 * Created on Feb 2, 2008 by kyang
 *
 * NXADVOCATE
 * All Rights Reserved - Unauthorized Use Prohibited
 * For information contact licensing@nxadvocate.com
 * 
 */ 


function showPopupSearch (table, theLink, idTargetId, fullNameTargetId, functionCall) {
	var o=document.getElementById(theLink);
	x=AnchorPosition_getPageOffsetLeft(o);
	y=AnchorPosition_getPageOffsetTop(o);

	// display popup	
	document.getElementById('popupSearchSpan').style.left = (x+30)+'px';
	document.getElementById('popupSearchSpan').style.top = (y-40)+'px';
	document.getElementById('popupSearchSpan').style.visibility='visible';
	
	// get ids of form elements that need to need updated with search result's id and name
	var formFields = new Array();

	formFields['table'] = table;
	formFields['frmIdTargetId'] = idTargetId;
	formFields['frmFullNameTargetId'] = fullNameTargetId;
	formFields['frmFunctionCall'] = functionCall;

	return formFields;
}

function closePopupSearch () {
	document.getElementById('popupSearchSpan').style.visibility = "hidden";
}


function preProcessPopupSearch (idTargetId, fullNameTargetId, functionCall) {
	var formFields = new Array();

	formFields['frmTarget'] = document.getElementById('frmTarget').value;
	formFields['frmSearchString'] = document.getElementById('frmSearchString').value;
	formFields['frmIdTargetId'] = idTargetId;
	formFields['frmFullNameTargetId'] = fullNameTargetId;
	formFields['frmFunctionCall'] = functionCall;

	return formFields;
}


function AssignPopupSearchResult (id, idTargetId, fullName, fullNameTargetId) {
	
	if (document.getElementById(idTargetId)) {
		var theIdTarget = document.getElementById(idTargetId);
		theIdTarget.value = id;
	}
	
	if (document.getElementById(fullNameTargetId)) {
		var theNameTarget = document.getElementById(fullNameTargetId);
		theNameTarget.innerHTML = fullName;
	}
	
	closePopupSearch();
}
