/*
///////////////////////////////////////////////////////////////////////////
////////
////////  MYSQL OP J.S. AJAX EXCHANGE FUNCTIONS
////////
////////
///////////////////////////////////////////////////////////////////////////
*/

function execq(Section)
  {
	if (document.query.VAL_NUM.value == 0)
		{
			alert("A value is needed.")
			document.query.VAL_NUM.focus();
		}
		else
		{
			  ajax =  new Ajax.Updater(
				     'res_q',        // DIV id must be declared before the method was called
				     'index.php',        // URL
					 {                // options
						 method:'post',
						 postBody: 'QRY=' + document.query.QRY.value + '&VAL_NUM=' +  document.query.VAL_NUM.value  + '&Server=' + document.query.Server.value
				     });
		 }

  }




function reset_stats()
{
                          ajax =  new Ajax.Updater(
                                     'LIVE_VALUES',        // DIV id must be declared before the method was called
                                     'index.php',        // URL
                                         {                // options
                                                 method:'post',
                                                 postBody: 'Section=LIVE_VALUES&ResetStats=1' + '&Server=' + document.server_select.Server_selected.value
                                     });
}


var ajax;
var autoajax = new Array();
function refresh_section(Section,refresh_ms,params)
{


	if (refresh_ms>0)
	 {
	 autoajax[Section] =  new Ajax.PeriodicalUpdater(
         Section,        // DIV id must be declared before the method was called
         'index.php',        // URL

         {                // options
		 onComplete: function() {Element.hide(Section + '_stop'); Element.show(Section + '_start');},
		 frequency:refresh_ms,
                 method:'post',
                 postBody: 'AutoUpdate=1&Section=' + Section + '&Server=' + document.server_select.Server_selected.value + params
             });
	 }
	 else
	 {
		 ajax =  new Ajax.Updater(
		 Section,        // DIV id must be declared before the method was called
		 'index.php',        // URL
		 {                // options
			 method:'post',
			postBody: 'Section=' + Section + '&Server=' + document.server_select.Server_selected.value + params
		     });
	 }
}


function query_a2(Query,txtInfo,w_width,w_height)
{
myObserver = {
    onDestroy: function(eventName, win) {
	refresh_section(Query,0,'');
        Windows.removeObserver(this);
  }}
Windows.addObserver(myObserver);
var winpop = new Window({className: "dialog",  width:w_width, height:w_height, zIndex: 100, resizable: true, title: txtInfo, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true,destroyOnClose:true})
winpop.setAjaxContent('index.php', {                // options
                 method:'post',
                postBody: 'QRY=' + Query + '&Server=' + document.server_select.Server_selected.value
             },true,true)
winpop.setStatusBar(txtInfo);
}
