
///////////////////////////////////////////////////////////////////
// Global Handler for spinner
//
///////////////////////////////////////////////////////////////////
 var myGlobalHandlers = {
   onCreate: function(){
     Element.show('systemWorking');
   },
   
   onComplete: function() {
     if(Ajax.activeRequestCount == 0){
       Element.hide('systemWorking');
     }
   }
 };
 Ajax.Responders.register(myGlobalHandlers);


///////////////////////////////////////////////////////////////////
// getHelp
//
///////////////////////////////////////////////////////////////////
 function getHelp(file,rating,allFileCount,fileCountId) {
   var url = 'webservices/helpServer.php';
   var pars = 'file='+file;
   var fileIdPrefix = 'fileId-';

   var myAjax = new Ajax.Updater(
   {success: 'helpViewer'},
   url,
       { method: 'get',
	 parameters: pars,
	 onFailure: reportError,
	 evalScripts: true
       }
   );

   // Clear all file navigation styles
   for(i=0;i<allFileCount;i++) {
//    Element.setStyle(fileIdPrefix+i,{background:'white',color:'gray'});
   }

   // Clear all smart list styles
   for(i=1;i<10;i++) {
 //   Element.setStyle('smartList-'+i,{background:'white',color:'gray'});
   }

   // Highlight current style
  // Element.setStyle(fileIdPrefix+fileCountId,{background:'orange',color:'white'});

   // Show filter Dialog
   //filterDialog(file);
 }

///////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////
 function getSmartList(rating,allFileCount) {
   var url = 'webservices/discoveryServer.php';
   var pars = 'mode=SmartList&rating='+rating;
   
   var myAjax = new Ajax.Updater(
   {success: 'results'},
   url,
       { method: 'get',
	 parameters: pars,
	 onFailure: reportError,
	 evalScripts: true
       }
   );

   // Clear all file navigation styles
   for(i=0;i<allFileCount;i++) {
    Element.setStyle('fileId-'+i,{background:'white',color:'gray'});
   }

   // Clear all smart list styles
   for(i=1;i<10;i++) {
    Element.setStyle('smartList-'+i,{background:'white',color:'gray'});
   }

   // Highlight current style
   Element.setStyle('smartList-'+rating,{background:'orange',color:'white'});
 }

///////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////
function editRating(rating,compoundId,file,divId) {
  var url = 'webservices/discoveryRate.php';
  var pars = 'xmlFile='+file+'&rating='+rating+'&compoundId='+compoundId+'&divId='+divId;
  var myAjax = new Ajax.Updater(
  {success: divId},
  url,
      { method: 'get',
	 parameters: pars,
	 onFailure: reportError
      }
   );
}


///////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////
function filterDialog(file) {
   var url = 'webservices/discoveryFilterDialog.php';
   var pars = 'xmlFile='+file;

   var myAjax = new Ajax.Updater(
   {success: 'filterDialog'},
   url,
       { method: 'get',
	 parameters: pars,
	 onFailure: reportError,
	 evalScripts: true
       }
   );
}
