
function checkparams() {
  /*
  if ( (document.lightbox.utente.value =='') &&  (document.lightbox.prodotto.value=='') ) {
     n_stip('Inserisci il tuo Libero ID e la relativa password','infota',x_tip,25,5);
     return false;
  }

  if ( document.autenticazione.LOGINID.value=='') {
     n_stip('Inserisci il tuo Libero ID','infota',x_tip,25,5);
     return false;
  }
  if ( document.autenticazione.PASSWORD.value=='') {
     n_stip('Inserisci la tua password','infota',x_tip,88,5);
     return false;
  } */

  return true;
}

function selectmethod() {
	pull()
	var com_userAgent=navigator.userAgent.toLowerCase();
	if ( ajax  ) {
		
		if(com_userAgent.indexOf("msie 5")!=-1)  
			return checkparams();

		if ( checkparams() ) {
			//document.getElementById('vai_img').style.display="none";
			//document.getElementById('vai_img_wait').style.display="block";

			ajax_action();
		}

		return false;
	} else {
		return checkparams();
	}
}

function selectmethod_2() {
	var com_userAgent=navigator.userAgent.toLowerCase();
	if ( ajax  ) {
		
		if(com_userAgent.indexOf("msie 5")!=-1)  
			return checkparams();

		if ( checkparams() ) {
			//document.getElementById('vai_img').style.display="none";
			//document.getElementById('vai_img_wait').style.display="block";

			remove_action();
		}

		return false;
	} else {
		return checkparams();
	}}



function ajax_action() {
   var esc_loginid = escape ( document.lightbox_d.utente.value );
   params = 'utente=' + esc_loginid; 

   var esc_password = escape ( document.lightbox_d.prodotto.value );
   params += '&prodotto=' + esc_password

   var esc_service_id = escape ( 'old_email' );
   params += '&SERVICE_ID=' + esc_service_id
           + '&AJAX=1';
 
   /* ferma le richieste doppie, mentre la prima e' in elaborazione */
   if ( status == 1 ) n_stip ('Attenzione la richiesta &egrave in fase di elaborazione!','infota',x_tip,65,2);
   else
   {

      status=1;
      ajax_call();
   }

   if ( T_out_http_var )
   {
      clearTimeout(T_out_http_var);
      T_out_http_var=setTimeout("check_T_out_http()",T_out_http);
   }
   else T_out_http_var=setTimeout("check_T_out_http()",T_out_http);
}

function remove_action() {
  var params = '';
  var parametri = '';
  var j = '';

  for (i=1; i<=3; i++)
	{
		if (document.getElementById('id_remove_'+i))
		{
			if (document.getElementById('chek_remove_'+i).checked) {
				j=1;
				parametri += document.getElementById('id_remove_'+i).value+'_';
			}
		}
	}

  
  if (j == 1)
  {
	params += 'prodotti='+parametri

   var esc_service_id = escape ( 'old_email' );
   params += '&SERVICE_ID=' + esc_service_id
           + '&AJAX=1';



   /* ferma le richieste doppie, mentre la prima e' in elaborazione */
   if ( status == 1 ) n_stip ('Attenzione la richiesta &egrave in fase di elaborazione!','infota',x_tip,65,2);
   else
   {

      status=1;
      ajax_rmv_call(params);
	  
   }

   if ( T_out_http_var )
   {
      clearTimeout(T_out_http_var);
      T_out_http_var=setTimeout("check_T_out_http()",T_out_http);
   }
   else T_out_http_var=setTimeout("check_T_out_http()",T_out_http);
  }
}

function ajax_rmv_call(params) {
	
  ajax.open('post', 'remove.php?get=params', true);
  ajax.setRequestHeader('content-type', "application/x-www-form-urlencoded");
  ajax.setRequestHeader('connection', 'close');

  ajax.onreadystatechange = function()
  {
    // verifica stato
    if (ajax.readyState === 4)
    {
      // verifica risposta da parte del server
      if (ajax.status == 200)
      {
        // operazione avvenuta con successo
        if (status == 1)
        {

          var resp = ajax.responseText;
          var result_array = new Array();
		  contenuto_lightbox();
        }
      }
      else
      {
        // errore caricamento
        avviso = 'Siamo spiacenti il servizio &egrave; momentaneamente non disponibile.';
        document.getElementById('box_err_mess').innerHTML = avviso;
        document.getElementById('vai_img').style.display = 'block';
        document.getElementById('vai_img_wait').style.display = 'none';
      }
      status = 0;
      if (T_out_http_var)
      {
        clearTimeout(T_out_http_var);
        T_out_http_var = false;
      }
    }
  }
  ajax.send(params);
}

function RimuoviLightbox() {
	var j = '';
	var parametri = '';
	params = '';

	for (i=1; i<=3; i++)
	{
		if (document.getElementById('id_remove_'+i))
		{
			if (document.getElementById('chek_remove_'+i).checked) {
				j=1;
				parametri += document.getElementById('id_remove_'+i).value+'||';
			}
		}
	}
	
	if (j)
	{
		params = 'prodotti='+parametri;

		var esc_service_id = escape ( 'old_email' );

	   params += '&SERVICE_ID=' + esc_service_id
			   + '&AJAX=1';
		
		
			status=1;
			remove_ajax_call();
			contenuto_lightbox();

			alert('t');
		 
	}
	return(false);
}

function remove_ajax_call()
{
	ajax.open('post', 'remove.php', true);
	ajax.setRequestHeader('content-type', "application/x-www-form-urlencoded");
	ajax.setRequestHeader('connection', 'close');

	ajax.onreadystatechange = function()
  {
    // verifica stato
    if (ajax.readyState === 4)
    {
      // verifica risposta da parte del server
      if (ajax.status == 200)
      {
        // operazione avvenuta con successo
        if (status == 1)
        {

          var resp = ajax.responseText;
          var result_array = new Array();
		  alert(resp);
        }
      }
      else
      {
        // errore caricamento
        avviso = 'Siamo spiacenti il servizio &egrave; momentaneamente non disponibile.';

      }
      status = 0;
      if (T_out_http_var)
      {
        clearTimeout(T_out_http_var);
        T_out_http_var = false;
      }
    }
  }
  ajax.send(params);
}


