 function showGeneralNews(lValue) {
    document.fReload.ShowGeneral.value = lValue;
    document.fReload.submit();
 }

 function showAllNewsItems(lMode,lSelection) {
   document.fReload.NewsMode.value = lMode;
   document.fReload.Selection.value = lSelection;     
   document.fReload.submit();
 }
 
 function pEnterKey() { // former KeyEvents
   if (document.fBarcode != null && document.fBarcode.Barcode.value.length >0) {
     OpacLend(document.fBarcode.Barcode.value,gObjId); // also for relocate!
   }
   else if (document.fLogin != null) {
     if (document.fLogin.Uid.value.length > 1)
       document.fLogin.submit();
   }
   else if (document.fLending != null && document.fLending.PtrCode != null && document.fLending.PtrCode.value != '') {
     runAXPortalDesk(document.fLending.PtrCode.value);
   }
   else if (document.fLending != null && document.fLending.Barcode != null && document.fLending.Barcode.value != '') {
     runAXlending();
   }
   else if (document.fReturning != null && document.fReturning.Barcode.value != '') {
     runAXreturn();
   }
   else if (document.fTabSearch != null && document.fTabSearch.qe.value.length > 0) {
      document.fTabSearch.submit();
      return false;
   }
   else if (document.fTopSearch != null && document.fTopSearch.qe.value.length > 0) {
      document.fTopSearch.qe.value = document.fSearch.qe.value;
      document.fTopSearch.submit();
   }
   else if (gSearchFocus) {
      // alert('klasjhf');
      SubmitSearch(document.fSearch.SearchMode.value,document.fSearch);
   }
 }	 	 

   function GetPortalDoc(lTarget,lId,lCSS) {
   	 if (lTarget)
   	   document.fTab.target = '_blank';	
     document.fTab.Template.value='portaldocPanel';
     document.fTab.CSS.value=lCSS;	
     document.fTab.Id.value=lId; 
     document.fTab.submit();
   }
   function showFormAction(lId) {
   	 lLink = '../modals/FormAction.php?DocId='+lId;
     wOpenLink = window.open(lLink,'NewsList','toolbar=1,Scrollbars=1,menubar=1,resizable=1,location=1,status=1,height=800,width=800,top=0,left=290');
   }	   
 
 function cbBgSaveMta(a) { // callback from rss/Portal.php
 } 
 
   function setTotCounter(lCount) {
     var hCount = document.getElementById('hCount'); // once pr. page...
     if (hCount) {
       var lText = hCount.firstChild.data;
       var lS = '';
       hCount.innerHTML = lS.concat(lText.slice(0,lText.lastIndexOf(':')+2),lCount); // always : as delimiter..
    }
  }  	   
  
  function pDeleteSearchHistory(lHistId,lRowId) {
    ASyncAjax('cbDeleteSearchHistory','DeleteHistItem','',lRowId,lHistId,0);
  }
  
 function cbDeleteSearchHistory(a) { // callback  	
     eval("var row = document.getElementById('tr"+a['tRowId']+"')");
     if (row) {
       row.style.display = 'none';
       setTotCounter(a['tCount']);
     }     
   }   	  
   
   function pDeleteAllSearchHistory() {
     if (confirm(JRumVar('deleteall'))) {
       ASyncAjax('cbDummy','DeleteAllSearchHistory','',0,0,0);
       FrmRed('../rss/Portal.php',0,'');
     }
   }	
    
   function pKeepHist(lHistId,lState) {
     // alert (lHistId +' : '+lState);
     ASyncAjax('cbDummy','KeepHist','',0,lHistId,lState);
   }	    
    
   function pTssSubscr(lSubscriptionId,lCellId,lState) {
     // alert (lSubscriptionId+' : '+lCellId+' : '+lState);
     ASyncAjax('cbTssSubscr','TssSubscr','',lCellId,lSubscriptionId,lState);
   }
   function mtERMSubscr(lSubscriptionId,lCellId,lState) {
     // alert (lSubscriptionId+' : '+lCellId+' : '+lState);
     jQuery.getJSON('../background/Ajax.php?F=mtERMSubscr&tgtId=0&SubscriptionId='+lSubscriptionId+'&State='+lState, function(json) {
     	  // x  alert(json.ERMId);
     	  document.fReload.Template.value = 'ermpickPanel';
     	  document.fReload.submit();
     });	
   }	   	
   
   function cbTssSubscr(a) { // callback
     eval("var expirecell = document.getElementById('Subscr"+a['tRowId']+"')");
     if (expirecell) {
       expirecell.innerHTML = a['tSubscrCount'];
     }  
     
   }  
   
   function pDeleteReservation(lAccountId,lCellId) {
     ASyncAjax('cbDeleteReservation','DeleteReservation','',lCellId,lAccountId,'');
   }	

   function cbDeleteReservation(a) { // 232 :: check
     eval("var row = document.getElementById('tr"+a['tRowId']+"')");
     if (row) {
       row.style.visibility = 'hidden';
       setTotCounter(a['tCount']);
     }     
   } 
   
   function pProfileSubscr(lSubscriptionId,lCellId,lState) {
     // alert (lSubscriptionId+' : '+lCellId+' : '+lState);
     ASyncAjax('cbProfileSubscr','ProfileSubscr','',lCellId,lSubscriptionId,lState);
   }	
   
   function cbProfileSubscr(a) { // callback
     setTotCounter(a['tCount']);
     eval("var expirecell = document.getElementById('Subscr"+a['tRowId']+"')");
     if (expirecell) {
       expirecell.innerHTML = a['tSubscrCount'];
     }  
     
   }  
  
  function CheckPtrSubmit(lStage,lClearForNew) { // garbage control ?
    if (document.fPtrn.UserCode.value.length > 0 && document.fPtrn.FamilyName.value.length > 0) {
      if (checkEmailSyntax(document.fPtrn.Email1.value) && checkUsrCodeSyntax(document.fPtrn.UserCode.value)) {
        document.fPtrn.FStage.value=lStage;
        document.fPtrn.ClearForNew.value=lClearForNew;
        document.fPtrn.submit();
      }
      else
          JRum(1,'emailcodeerror',5000);
    }
     else
       JRum(1,'empty_form',5000);
     return '';  
  }

function makeULHeader(lCont,lTerm,lMode) {
  // var Elm = createElm('div','HeadD','');
  var LiElm = createElm('li','','HeadD');
  if (lMode > 0)
    createTextLink(0,'',LiElm,'../main/Hits.php?List=PortalTerms&Term='+lTerm,lTerm,'Search topic','HeadP','','');
  else
    createTextElm(LiElm,lTerm);
  lCont.appendChild(LiElm);
}	

function ViewAllDocs(lFocus,lMaxRows,lTermId,lTerm) {
  ASyncAjax('cbViewAllDocs','ViewAllDocs',lTerm,lFocus,lTermId,lMaxRows);
}

function cbViewAllDocs(a) { // callback
  var i = 0;
  var lHeader = '';
  // eval("var Ebody = document.getElementById('tr"+a['tRowId']+"')");
  var Ebody = document.getElementById('Plinkmenu');
  if (Ebody) {
    removeElement('Plinkmenu','dLinkCont');	
    var ContElm = createElm('div','dLinkCont','');
    for (var x in a['rData']) {
      var UlElm = createElm('ul','','');	
      i++;
      if (a['rData'][x]['rMtaId'] == '0') {
      	makeULHeader(UlElm,a['rData'][x]['rTitle'],1);
      	lHeader = a['rData'][x]['rTitle'];
      }
      else {
        if (a['rData'][x]['rTitle'] == 'viewalldocs') {
          var LiElm = createElm('li','','moreP');
          createTextLink(0,'',LiElm,"javascript:ViewAllDocs(1,1,"+a['rData'][x]['rTermId']+",'"+lHeader+"')",a['rData'][x]['rYear'],a['rMess'],'moreP','','');
        }  
        else {
          var LiElm = createElm('li','','');	
          createTextLink(0,'',LiElm,a['rData'][x]['rLink'],a['rData'][x]['rTitle'],a['rMess'],'newsP','','');
        }  
        UlElm.appendChild(LiElm);
        
      }
      ContElm.appendChild(UlElm);  
    }
    
    if (a['rTermId'] != '0') {
      var UlElm = createElm('ul','','');	
      var LiElm = createElm('li','','moreP');     
      createTextLink(0,'',LiElm,'javascript:ViewAllDocs(0,1,0,"")',a['rMore'],a['rMess'],'moreP','','');
      UlElm.appendChild(LiElm); 
      ContElm.appendChild(UlElm);
    }  
    Ebody.appendChild(ContElm);
  }  
}

function TreePick(lMode,lTree,lFieldName) {
  var lLink ='../main/ThTree.php?Modal=1&Mode='+lMode+'&Tree='+lTree+'&FieldName='+lFieldName+'&Origin=Portal';
  var lHeight = 800;
  var lWidth = 600;
  var dialogWindow = window.open(lLink,'Tree',"height="+lHeight+",width="+lWidth+",scrollbars=yes,resizable=yes,dialog=yes,modal=yes");
}

function TreeModalReturnPortal(lMode,lFieldName,lNode) { // 228 ..
  if (lMode == 1) { // add term
    eval('var lCurrentValue = document.fSuggestion.'+lFieldName+'.value');
    if (lCurrentValue.length > 0)
      lCurrentValue = lCurrentValue+'\n';
    eval('document.fSuggestion.'+lFieldName+'.value = lCurrentValue+lNode');
  }
}

function EditStaffEditor(lId) {
  FrmRed('../rss/Portal.php',0,'MtaId#'+lId,'Template#propositionPanel');
}	

function DeleteStaffEditorItem(lId) {
  ASyncMetaData('cbDeleteStaffEditorItem','PurgeMtaId',0,lId,'','',-1);
}	

function cbDeleteStaffEditorItem(lJSON) {
  var a = eval("("+lJSON+")");
  if (a['Mess'])
    alert(a['Mess'])
  else  
    document.fReload.submit();
}  

function CoverViewPDF(lId) { // KAM
  // alert(document.fView.tgtId.value+' '+lId);
  ASyncNotice('cbReportCoverView','ReportCover',document.fView.tgtId.value,lId,0,0); 
}

function cbReportCoverView (lJSON) {
  var a = eval("("+lJSON+")");
  // alert(a.toSource());
  if (a['Template'] > 0)
    setTimeout("window.open('"+a['File']+"','"+a['Name']+"','Menubar=yes,Scrollbars=yes,width=600,Height=575,resizable,screenX=0,screenY=0')",1500);	
}	

////////////////////////
//   SITEPORTALDEF    //
//      add. 179      //
////////////////////////
function changePFrameField(lId,lFocus) {
 // alert(lId+' :: '+lFocus);
  ASyncAjax('cbchangePFrameField','PortalFrameField','',lId,lFocus,'');			  
}

function cbchangePFrameField(a) { // callback   	
   document.fReload.submit();
}

function changePFrameRights(lId,lFocus) {
  // alert(lId+' :: '+lFocus);
  ASyncAjax('cbDummy','changePFrameRights','',lId,lFocus,'');			  
}

function changePFrameFeed(lId,lFocus) {
  ASyncAjax('cbDummy','changePFrameFeed','',lId,lFocus,'');			  
}
function changePFrameBlog(lId,lFocus) {
	// alert(lId+' '+lFocus);
  ASyncAjax('cbDummy','changePFrameBlog','',lId,lFocus,'');
}

   
function JQFeed(tgtId,lId) {
jQuery.getJSON('../background/AjaxFunctions.php?F=ReadFeed&'+tgtId+'&Id='+lId, function(json) {
	for (var x in json) {
		Elm = document.getElementById('feed'+x);
		if (json[x].GUID && json[x].GUID.indexOf('picasaweb.google.com') > 1) {// image feed picasa
          createImgGalery(Elm,0,'ImgUl',json[x]);
       }
       else if(json[x][0].GUID && json[x][0].GUID.indexOf('www.google.com/calendar/feeds') > 1) {
         createCalendar('feed'+x,'dInfo',json[x],json[x][0]['Today']);
       }
       else { // normal feed
         createList(Elm,0,'HeadD',json[x]);
       }
  }     
	   
});	
}	   
   
  function CheckPtrReqSubmit(lStage,lClearForNew) { // garbage control ?
    if (document.fPtrn.RqPurpose.value > 0 && document.fPtrn.RqProject.value.length > 0 && document.fPtrn.RqDescription.value.length > 0) {
      if (checkEmailSyntax(document.fPtrn.Email1.value) && checkUsrCodeSyntax(document.fPtrn.UserCode.value)) {
        document.fPtrn.FStage.value=lStage;
        document.fPtrn.ClearForNew.value=lClearForNew;
        document.fPtrn.submit();
      }
      else
          JRum(1,'emailcodeerror',5000);
    }
     else
       JRum(1,'oblig_missing',5000);
     return '';
  }
  
