/*********************************************************************************** // // GLOBAL SCRIPT LIBRARY // // Do not make any changes to this file // Any request should be addressed to Eugen Cretu/RO/SOBIS // // // Released date: 29.09.2005 // Maintaind by: Eugen Cretu/RO/SOBIS // ***********************************************************************************/ function min(a,b){ // No comment return ((a)<(b))?(a):(b); } function swap(a,b){ // No comment var tmp=(a); a=(b); b=(tmp); } function removeString(strSrc, strWhat){ // remove strWhat from strSrc return strSrc.replace(new RegExp(strWhat,'g'),'') } function replaceString(strSrc, strWhat, strWith){ // replace in strSrc strWhat with strWith return strSrc.replace(new RegExp(strWhat,'g'), strWith) } function urlDecode(strSrc){ // perform urldecode on the string return unescape(strSrc); } function getCookieVal (offset) { // used in getCookie function var endstr = document.cookie.indexOf (";", offset); if (endstr == -1){ endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); } function getCookie (name) { //retrieve the specified Cookie var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function setCookie (name, value) { // set a volatile Cookie var argv = setCookie.arguments; var argc = setCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + trim(escape (value)) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function setCookiePermanent (name, value) { // set a permanent Cookie var argv = setCookiePermanent.arguments; var argc = setCookiePermanent.arguments.length; var path = '/;'; var expires = new Date("December 31, 2023"); var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + trim(escape (value)) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function deleteCookie (name) { // delete a Cookie by setting expiration time to now var exp = new Date(); exp.setTime (exp.getTime() - 400000); // This cookie is history var cval = getCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } function backToView(){ //Return to the view from which you started to open or create the document // Original written by Florin Cotarlea/RO/SOBIS var url = window.location.toString().toUpperCase(); posQM = url.indexOf('?'); posNSF = url.indexOf('.NSF/'); if (posNSF != -1) { nsfPath = window.location.toString().substring(0, posNSF+ 5) // 64 = the length of view ID + doc ID // if view ID is missing is new doc if (nsfPath.length + 64 > posQM){ goBack = 1; submittedTimes = 0; posSeq = url.indexOf('SEQ'); if (posSeq != -1) submittedTimes = parseInt(url.substring(posSeq + 4, posSeq + 6)); if (url.indexOf('EDITDOCUMENT') != -1 || url.indexOf('OPENFORM' != -1)) goBack = submittedTimes + 1; history.go(-goBack); //location.href = nsfPath + getCurrentView()+'?OpenView' }else { if(getCurrentView()==''){ history.go (-1); }else{ viewID = url.substring(posNSF + 5, posNSF + 37); location.href = nsfPath + viewID + '?OpenView' } } } } function onescape(){ //When esc key is pressed the Close click event is called // Original written by Florin Cotarlea/RO/SOBIS // Changed by Eugen Cretu/RO/SOBIS var thisFunction='onescape'; try{ if(window.event.keyCode!=27){ return window.event.keyCode; } if(isEditMode()){ if(isChanged()){ var flag=window.confirm('Documentul a fost modificat. Pierdeti modificarile?'); if(flag){ backToView(); } } else{ backToView(); } } if(isReadMode()){ backToView(); } }catch(e){ window.status='Error! Function'+thisFunction+'=>'+e.description; } } function goToEditMode(){ // used in dblClick event of the form and switch the doc. in EditMode // Original written by Florin Cotarlea/RO/SOBIS // Changed by Eugen Cretu/RO/SOBIS //check if the document is in Edit mode if(getCGI('PrintMode')!=''){ //is in Print Mode return; } pos = location.toString().indexOf('?') + 1 str = location.toString().substr(pos, 12).toUpperCase() openForm = location.toString().substr(pos, 8).toUpperCase() if(str != 'EDITDOCUMENT' && openForm != "OPENFORM") location.search='?EditDocument' } function isChanged() { //Check if the data from current document/form is changed // Original written by Florin Cotarlea/RO/SOBIS // Changed by Eugen Cretu/RO/SOBIS var j=0; var elem=document.forms[0].elements; var arrInput=new Array('HIDDEN', 'FILE', 'TEXT','SELECT-ONE', 'SELECT-MULTI','TEXTAREA'); for ( var j=0; j 0){ var strDb= strPathName.substring(0, nsfIndex+4); if(strDb.charAt(0)=='/'){ return strDb.substring(1, strDb.length); }else{ return strDb; } } return ''; } function getDbPath(){ // return only the path of the current database without the file name EG ADP/2005 var strPathName=window.location.pathname; var nsfIndex=strPathName.toUpperCase().indexOf('.NSF'); if(nsfIndex>0){ var strDb= strPathName.substring(0, nsfIndex+4); return strDb.substring(1, strDb.lastIndexOf('/')) } return ''; } function getDbFile(){ // return only the file name of the current database without the path name EG Registratura.nsf var strPathName=window.location.pathname; var nsfIndex=strPathName.toUpperCase().indexOf('.NSF'); if(nsfIndex>0){ var strDb= strPathName.substring(0, nsfIndex+4); return strDb.substring(strDb.lastIndexOf('/')+1, strDb.length) } } function getDbPathN(nrComponent){ // return the nrComponent part of the pathname //EG getDbPathN(0) for /ADP/2005/Registratura.nsf will return ADP var arrayComponents=getDbPath().split('/'); if(arrayComponents.length>nrComponent){ return arrayComponents[nrComponent]; } return ''; } function getPath0(){ // return the first component of the path return getDbPathN(0) } function getPath1(){ // return the second component of the path return getDbPathN(1) } function getCurrentView(){ //return the current view name or the source view name var currentView=''; url = getUrl().toUpperCase(); posQM = url.indexOf('?'); posNSF = url.indexOf('.NSF/'); if (posNSF != -1) { //not a simple .nsf urlAction = url.substring(posNSF+ 5, url.length); if(urlAction.indexOf('?EDITDOCUMENT')>0){ urlAction=urlAction.substring(0, urlAction.indexOf('?EDITDOCUMENT')-1); if(urlAction.indexOf('/')>0){ currentView=urlAction.substring(0, urlAction.indexOf('/')); } } if(urlAction.indexOf('?OPENDOCUMENT')>0){ urlAction=urlAction.substring(0, urlAction.indexOf('?OPENDOCUMENT')-1); if(urlAction.indexOf('/')>0){ currentView=urlAction.substring(0, urlAction.indexOf('/')); } } if(urlAction.indexOf('?OPENVIEW')>0){ currentView=urlAction.substring(0, urlAction.indexOf('?OPENVIEW')); } if(urlAction.indexOf('?SEARCHVIEW')>0){ currentView=urlAction.substring(0, urlAction.indexOf('?SEARCHVIEW')); } } if(currentView!=''){ currentView=getUrl().substring(url.indexOf(currentView), url.indexOf(currentView)+currentView.length) }else{ if(urlAction.indexOf('/')>0){ currentView=getUrl().substring(url.indexOf('.NSF/')+5,url.indexOf('.NSF/')+5+urlAction.indexOf('/')) }else{ currentView=getUrl().substring(url.indexOf('.NSF/')+5,url.length) } } return currentView; } function editDocument(strDocUnid, strView, strTarget){ //open the specified document in edit mode if((typeof(strView)=='undefined') ||(strView=='')){ strView=getCurrentView(); } window.location.href = '/' + getDb() + '/' + strView +'/' + strDocUnid + '?EditDocument'; } function openDocument(strDocUnid, strView, strTarget){ //open the specified document in read mode if((typeof(strView)=='undefined') ||(strView=='')){ strView=getCurrentView(); } window.location.href='/'+getDb()+'/'+strView+'/'+strDocUnid+ "?OpenDocument" } function deleteDocument(strDocUnid, strView){ //delete the specified document if((typeof(strView)=='undefined') ||(strView=='')){ strView=getCurrentView(); } var flag=window.confirm("Doriti sa stergeti documentul?") if(flag){ var strRet=getUrl(); var strView=(strView=='')?'All':strView; window.location.href='/'+getDb()+'/'+strView+'/'+strDocUnid+ '?DeleteDocument&ReturnPage='+strRet; window.status='Documentul a fost sters!'; } } function isEditMode(){ // check if the document is in edit mode return (getUrl().toUpperCase().indexOf('?EDITDOCUMENT')>0)||(getUrl().toUpperCase().indexOf('?OPENFORM')>0); } function isReadMode(){ // check if the document is in read mode return (getUrl().toUpperCase().indexOf('?OPENDOCUMENT')>0); } function isNewDoc(){ return (getUrl().toUpperCase().indexOf('?OPENFORM')>0); } function getDocumentUniqueID(){ //retrieve the DocUnid from the url url = getUrl().toUpperCase(); posQM = url.indexOf('?'); posNSF = url.indexOf('.NSF/'); if (posNSF != -1){ //not a simple .nsf var urlAction = url.substring(posNSF+ 5, getUrl().length); var indexEdit=urlAction.indexOf('?EDITDOCUMENT'); if(indexEdit>0){ return urlAction.substring(indexEdit-32, indexEdit); } var indexOpen=urlAction.indexOf('?OPENDOCUMENT'); if(indexOpen>0){ return urlAction.substring(indexOpen-32, indexOpen); } } return ''; } function getFieldValue(fldPar){ // return the value of the specified field fldPar // fldPar can be an object or a string var strRet=""; var fld; if(typeof(fldPar)=='string'){ fld=eval('document.forms[0].'+fldPar); }else{ fld=fldPar; } if(!fld){ return ''; } if(typeof(fld)=='undefined'){ return ''; } if(typeof(fld.tagName)=='undefined'){ //poate fi array de controale if(typeof(fld.length)=='undefined'){ // nu e array return ''; }else{ // e array de controale for(var i=0;i'+e.description; } } function hideID(id){ // set the display attribute to none for the value // specified in id parameter var j=0; var thisFunction='hideID'; try{ document.getElementById(id).style.display='none' }catch(e){ window.status='Error! Function'+thisFunction+'=>'+e.description; } } function showIDs(){ // set the display attribute to visible block for the values // specified in URL in ShowID parameter // a field ShowID must reside on the form var j=0; var thisFunction='showIDs'; try{ var arrShowID=document.forms[0].ShowID; if(typeof(arrShowID.length)=='undefined'){ //only one value try{ if(arrShowID.value==''){return} document.getElementById(arrShowID.value).style.display='inline-block' }catch(e){window.status='Not Found '+arrShowID.value} }else{ for(var i=0;i'+e.description; } } function displayElements (strPrefix, isVisible) { var objElems = document.getElementsByTagName ('td'), i; strPrefix = strPrefix + '_'; for (i = 0; i < objElems.length; i++) if (objElems [i].id) if (objElems [i].id.indexOf (strPrefix) == 0) { objElems [i].style.display = isVisible ? '' : 'none'; } } function hideIDs(){ // set the display attribute to none // specified in URL in HideID parameter // a field HideID must reside on the form var j=0; var thisFunction='hideIDs'; try{ var arrShowID=document.forms[0].HideID; if(typeof(arrShowID.length)=='undefined'){ //only one value try{ document.getElementById(arrShowID.value).style.display='none' }catch(e){} }else{ for(var i=0;i'+e.description; } } function createPrintIcon(){ try{ var actnBar=document.getElementById('ActionBar'); if(actnBar!=null){ var lastTD=actnBar.rows[0].cells[actnBar.rows[0].cells.length-1]; if(lastTD!=null){ lastTD.className='clsPrintPreview'; lastTD.innerHTML=('PreviewPreview'); } } }catch(e){ } } function setCSS(){ // set the Exclamation background to the mandatory fields // mandatory fields have the validateCondition attribute defined // attach onblur and onfocus event // set the document title // Append this function to the onload event for each form var j=0; var elem=document.forms[0].elements; var arrInput=new Array('HIDDEN', 'FILE', 'TEXT'/*,'SELECT-ONE', 'SELECT-MULTI'*/,'TEXTAREA'); for ( var j=0; j 0)?'':(' mandatory')); } }// end if } } //end for k }//end for j btns = document.getElementsByTagName ('input'); for (i = 0; i < btns.length; i++) if (btns [i].className.indexOf ('button') >= 0) { btns [i].onmousedown = function () {this.className = this.className.replace (/button/g, 'buttonPressed');} btns [i].onmouseup = function () {this.className = this.className.replace (/buttonPressed/g, 'button');} } hideRefreshLinks (); setTitle(); showIDs(); hideIDs(); createPrintIcon(); //showID ('ActionBar'); try {document.getElementById ('ActionBar').style.visibility = 'visible';} catch (e) {} window.status=''; } function hideRefreshLinks () { // ascunderea spatiului suplimentar dinaintea campurilor care au Refresh fields on keyword change aHrefs = document.getElementsByTagName ('a'); for (i = 0; i < aHrefs.length; i++) if (aHrefs [i].name.indexOf ('_RefreshKW') >= 0) aHrefs [i].style.display = 'none'; } function fieldOnFocus(){ // event for fields var thisField=event.srcElement; thisField.style.background='DFEFFF'; } function fieldOnBlur(){ //event for fields var thisField=event.srcElement; thisField.style.background='#ffffff'; if(thisField.validateCondition){ if(!thisField.value){ thisField.style.backgroundImage='url(/icons/vwicn150.gif)'; thisField.style.backgroundPosition='right'; thisField.style.backgroundRepeat='no-repeat' }else{ thisField.style.background='#ffffff'; } } } function setTitle(){ if((typeof(window.frameElement)!='undefined')&&(window.frameElement!=null)){ if(window.frameElement.tagName=='IFRAME'){ return; }else{ if(top!=self){ top.document.title = document.title; //for framed documents } } }else{ if(top!=self){ top.document.title = document.title; //for framed documents } } } function getCGI(strName){ // return the value of the specified CGI variable in url if(trim(strName)==''){ return ''; } var strPath=window.location.href; if(strPath.indexOf('&')>0){ strPath=strPath.substring(strPath.indexOf('&'), strPath.length) var arrParam=strPath.split('&'); for(var k=0;k