//--------------------------------------------------
// copyright 2009 - MBendi Information Services
//
// Updated: 12.May.2009 - SM
//  - add new functions to support new geographic lookups
//--------------------------------------------------
function hideElId(sEl) {document.getElementById(sEl).style.display='none'}
function showElId(sEl) {document.getElementById(sEl).style.display=''}
function fkeyLookup(strHiddenElemID, strURL, strParms, formElem, strTargetDiv, strCallerElem) {
var strLinkParms = strParms;
var fkeyElem = document.getElementById(strHiddenElemID);
if (fkeyElem.value != '') strLinkParms += '&SID=' + fkeyElem.value;
xmlhttpRequest('G', strURL, strLinkParms, formElem, strTargetDiv);
document.getElementById(strCallerElem).style.display = 'none';
}
function setFKeyFld(strFFldID, strFKeyID, strFKeyTxt) {var fkeyElem = document.getElementById('FFld'+strFFldID);
fkeyElem.value = strFKeyID;
fkeyElem = document.getElementById('FFldText'+strFFldID);
fkeyElem.innerHTML = strFKeyTxt;
fkeyElem = document.getElementById('FFldButn'+strFFldID);
if (strFKeyID == '') {fkeyElem.value = 'Select'} else {fkeyElem.value = 'Change'};
fkeyElem = document.getElementById('FFldClear'+strFFldID);
if (fkeyElem) { if (strFKeyID == '') {fkeyElem.style.display = 'none'} else {fkeyElem.style.display = ''}};
}
function chngFKeyFld(strFFldID, strFKeyID, strFKeyTxt) {
setFKeyFld(strFFldID, strFKeyID, strFKeyTxt);
return fkeyCloseLookup(strFFldID);
}
function depFkeyLookup(strMajorKeyElemID, strMinorKeyElemID, strURL, strParms, formElem, strTargetDiv, strCallerElem) {
var strLinkParms = strParms;
var minorKeyElem = document.getElementById(strMinorKeyElemID);
if (minorKeyElem.value != '') strLinkParms += '&SID=' + minorKeyElem.value;
var majorKeyElem = document.getElementById(strMajorKeyElemID);
if (majorKeyElem.value != '') strLinkParms += '&MID=' + majorKeyElem.value;
xmlhttpRequest('G', strURL, strLinkParms, formElem, strTargetDiv);
document.getElementById(strCallerElem).style.display = 'none';
}
function chngDepFKeyFlds(strMajorKeyFFldID, strMajorKeyVal, strMinorKeyFFldID, strMinorKeyVal, strDisplayTxt) {
var cyidElem = document.getElementById('FFld'+strMajorKeyFFldID);
cyidElem.value = strMajorKeyVal;
chngFKeyFld(strMinorKeyFFldID, strMinorKeyVal, strDisplayTxt);
var fkeyElem = document.getElementById('FFldButn'+strMinorKeyFFldID);
if (strMajorKeyVal == '') {fkeyElem.value = 'Select'} else {fkeyElem.value = 'Change'};
fkeyElem = document.getElementById('FFldClear'+strMinorKeyFFldID);
if (fkeyElem) { if (strMajorKeyVal == '') {fkeyElem.style.display = 'none'} else {fkeyElem.style.display = ''}};
}
function fkeyCloseLookup(strFFldID) {document.getElementById('FFldCaller'+strFFldID).style.display = ''
return emptyElementHTML('htmlFKeySearch'+strFFldID);
}

preloadCrsListImages('/pics/plus.gif','/pics/minus.gif');

function showItemDetail(strElemName, strFldID, strRecID) {
var strLink = "javascript:hideItemDetail('"+strElemName+"','"+strFldID+"','"+strRecID+"')";
var strHTML = '<a href="'+strLink+'"><img src="/pics/minus.gif" alt="hide details" border="0"></a>';
document.getElementById(strElemName).innerHTML = strHTML;
document.getElementById('RowDetail'+strFldID+'R'+strRecID).style.display = '';
}
function hideItemDetail(strElemName, strFldID, strRecID) {
var strLink = "javascript:showItemDetail('"+strElemName+"','"+strFldID+"','"+strRecID+"')";
var strHTML = '<a href="'+strLink+'"><img src="/pics/plus.gif" alt="show details" border="0"></a>'
document.getElementById(strElemName).innerHTML = strHTML;
document.getElementById('RowDetail'+strFldID+'R'+strRecID).style.display = 'none';
}

var blnFkeyAWinOpen = false;var winFkeyAdd;
function openFKeyAddWindo(strURL,strW,strH,strL,strT) {
if (blnFkeyAWinOpen) { winFkeyAdd.close() }
winFkeyAdd = open(strURL,'FKeyAddEntry','scrollbars=yes,resizable=no,menu=no,toolbar=no,location=no,width='+strW+',height='+strH+',left='+strL+',top='+strT);
blnFkeyAWinOpen = true;
return false;
}
var blnPlaceAWinOpen = false;var winPlaceAdd;
function openPlaceAddWindo(strURL,strW,strH,strL,strT) {
if (blnPlaceAWinOpen) { winPlaceAdd.close() }
winPlaceAdd = open(strURL,'PlaceAddEntry','scrollbars=yes,resizable=no,menu=no,toolbar=no,location=no,width='+strW+',height='+strH+',left='+strL+',top='+strT);
blnPlaceAWinOpen = true;
return false;
}
function showCommCatgLvl(formElem, strURL, strPLvl, strPID, strClientID, strFldID) {
var strTargetDiv='CommCatgL'+strPLvl;
var sParms='C='+strClientID+'&PID='+strPID+'&FID='+strFldID;
xmlhttpRequest('G', strURL, sParms, formElem, strTargetDiv);
}
function setCommCatgLvl(formElem, strURL, strTargetLvl, strPID, strClientID, strFldID, strPElem) {
var strTargetDiv='CommCatgL'+strTargetLvl;
if (strPID == '') {
document.getElementById(strTargetDiv).innerHTML = '';
if (strPElem != '') {var valueElem = document.getElementById(strPElem);
setFKeyFld(strFldID,valueElem.value,valueElem.options[valueElem.selectedIndex].text)} else {setFKeyFld(strFldID,'','<i>not selected yet</i>')}
} else {setFKeyFld(strFldID,formElem.value,formElem.options[formElem.selectedIndex].text);
if (strURL != '') showCommCatgLvl(formElem, strURL, strTargetLvl, strPID, strClientID, strFldID);}
}
function showLookupLvl(formElem, strTargetDiv, strURL, strClientID, strLvlID, strLvlVal, strFldID) {
var sParms='C='+strClientID+'&LVLI='+strLvlID+'&LVLV='+strLvlVal+'&FID='+strFldID;
xmlhttpRequest('G', strURL, sParms, formElem, strTargetDiv);
}
function setLookupLvlSelect(formElem, strTargetDiv, strURL, strClientID, strLvlID, strLvlVal, strFldID, strPElem) {
var blnClearTarget = false;var valueElem = formElem;var ilen = strLvlVal.length;
if (ilen == 0) {blnClearTarget = true;if (strPElem != '') valueElem = document.getElementById(strPElem);}
setFKeyFld(strFldID,valueElem.value,valueElem.options[valueElem.selectedIndex].text);
if (blnClearTarget) {document.getElementById(strTargetDiv).innerHTML = '';} else {
if (strURL != '') showLookupLvl(formElem, strTargetDiv, strURL, strClientID, strLvlID, strLvlVal, strFldID);}
}
function checkLookupLvlSelect(formElem, strTargetDiv, strURL, strClientID, strLvlID, strLvlVal, strFldID, strOKbutnID) {
if (strLvlVal == '') {document.getElementById(strTargetDiv).innerHTML = '';
if (strOKbutnID != '') document.getElementById(strOKbutnID).style.display = 'none';
} else {if (strURL != '') {var sParms='C='+strClientID+'&LVLI='+strLvlID+'&LVLV='+strLvlVal+'&FID='+strFldID;
xmlhttpRequest('P', strURL, sParms, formElem, strTargetDiv);
if (strOKbutnID != '') document.getElementById(strOKbutnID).style.display = '';}}
}
var newFKeyText;
function pickLookupLvlSelect(strTargetFFldID, strSrceFFldID) {
var valueElem = document.getElementById(strSrceFFldID);
newFKeyText = '';
getSfixTxt(strSrceFFldID);
return chngFKeyFld(strTargetFFldID,valueElem.value,valueElem.options[valueElem.selectedIndex].text + newFKeyText);
}
function getSfixTxt(strCurSelFID) {
var elParentPntr = document.getElementById(strCurSelFID + 'P');
var strParSelFID = elParentPntr.value
if (strParSelFID == '') return false;
var elParent = document.getElementById(strParSelFID);
if (elParent) {newFKeyText = newFKeyText + '<br/>' + elParent.options[elParent.selectedIndex].text;
getSfixTxt(strParSelFID)}
}
