function aggiornariga(dominio){
        document.getElementById(dominio).style.display="none";
      //  document.getElementById("prosegui_off").style.display="none";
}


function turnOffButton(){
        document.getElementById("prosegui_on").style.display="none";
        document.getElementById("prosegui_off").style.display="inline";
	}
function turnOnButton(){
        document.getElementById("prosegui_on").style.display="inline";
        document.getElementById("prosegui_off").style.display="none";
}   
				

function getObj(name) {
		  if (document.getElementById)
		  	return document.getElementById(name);
		  else if (document.all)
				return document.all[name];
		  else if (document.layers)
		   	return document.layers[name];
		}
function isGecko()  {
	var ua = navigator.userAgent.substring(0,11)
	if(ua=='Mozilla/5.0')  {
	return true;
	}
	else {
	return false;
	}
}
function CheckAllclienti() {
  for (var i = 0; i < document.clienti.elements.length; i++) {
    if(document.clienti.elements[i].type == 'checkbox'){
      document.clienti.elements[i].checked =         !(document.clienti.elements[i].checked);
    }
  }
}

/*** PRELOADING IMMAGINI ***/
var preload = new Array();
preload[0] = new Image; 
preload[0].src = '/cp/images/display/loading.gif';
preload[1] = new Image; 
preload[1].src = '/cp/images/display/info.png';
preload[2] = new Image;
preload[2].src = '/cp/images/display/confirm.png';

function progressOn() { document.getElementById('waitDiv').style.visibility = 'visible';  }
function progressOff() { document.getElementById('waitDiv').style.visibility = 'hidden';  }
function daricalcolareko() { 
document.getElementById('conferma').style.visibility = 'hidden';
document.getElementById('totale').innerHTML = 'Ricalcola';
}
function daricalcolare() {
     document.getElementById('conferma').style.visibility = 'hidden';
     document.getElementById('totale').innerHTML = '<input type=submit name=ricalcola value="Ricalcola" class="inputsubmit"> (Le opzioni sono cambiate)';
}
			

/* Login/Logout */
var showLogin = null;
var showDiofaus = null;
var showSearch = null;
var showCarrello = null;
var showPassword = null;


function doAddfunds(form) {
    email = form.email.value
        byemail = form.byemail.value;
    bysms = form.bysms.value;
        wa = form.wa.value;
        if(email.length < 1 ) {
                $('loginresult').innerHTML = 'Inserire una mail valida ed un metodo di ricezione';
                showLogin.adapt();
        }
        
        else
        {
                var request = new Ajaxcustom('transaction');
                request.data.push('email=' + escape(email));
                request.data.push('byemail=' + escape(byemail));
                request.data.push('bysms=' + escape(bysms));
                request.data.push('wa=' + escape(wa));
                
                request.method = 'post';
                request.onload = function(text) {
                $('loginresult').innerHTML = text;
                showLogin.adapt();
                };
                request.send();
        }
        return false;
}

function addfunds(waid,nome) {
        if(! $('login')) {
                var login = d.createElement('div');
                login.id = 'login';
                login.innerHTML = '<div class="outer">' +
                        
                        '<form id="loginform"  method="post" onsubmit="return doAddfunds(this);">'+
                        '       <div class="left">' + nome +
                        '       <br/>' +        
                        '       ricevi la password <input type="checkbox" name="byemail" id="byemail" /> via email ' +
                        '       <input type="checkbox" name="bysms" id="bysms" /> via sms' +
                        '       <input type="hidden" name="wa" id="wa" value="<?=$wa;?>" /></div>' +
                        '       <div class="right">' +
                        '       <input type="text" name="email" id="email" /><br />' +
                        '       <input type="submit" class="inputsubmit" value="Recupera &gt;" />' +
                        '       </div> </form>' +
                        '       <div class="clearer"></div>' +
                        '       <div class="waitDiv"></div>' +
                        '       <div id="loginresult"></div>' +
                        '</div>';
                $('layout').insertBefore(login,$('main'));
                showLogin = new fx.Height('login', { duration: 500 });
                showLogin.hide();
        }
        
        
        if(showFriends) showFriends.hide();
        if(showPreferences) showPreferences.hide();
        if(showSearch) showSearch.hide();
        showLogin.toggle();
}

function doLogin(form) {
    email = form.email.value
        byemail = form.byemail.value;
    bysms = form.bysms.value;
        wa = form.wa.value;
        if(email.length < 1 ) {
                $('loginresult').innerHTML = 'Inserire una mail valida ed un metodo di ricezione';
                showLogin.adapt();
        }
        
        else
        {
                var request = new Ajaxcustom('/gestioneutenti/rp.php');
                request.data.push('email=' + escape(email));
                request.data.push('byemail=' + escape(byemail));
                request.data.push('bysms=' + escape(bysms));
                request.data.push('wa=' + escape(wa));
                
                request.method = 'post';
                request.onload = function(text) {
                $('loginresult').innerHTML = text;
                showLogin.adapt();
                };
                request.send();
        }
        return false;
}

function login() {
        if(! $('login')) {
                var login = d.createElement('div');
                login.id = 'login';
                login.innerHTML = '<div class="outer">' +
                        
                        '<form id="loginform"  method="post" onsubmit="return doLogin(this);">'+
                        '       <div class="left">' +
                        '       Inserisci la mail di registrazione e <br/>' +   
                        '       ricevi la password <input type="checkbox" name="byemail" id="byemail" /> via email ' +
                        '       <input type="checkbox" name="bysms" id="bysms" /> via sms' +
                        '       <input type="hidden" name="wa" id="wa" value="<?=$wa;?>" /></div>' +
                        '       <div class="right">' +
                        '       <input type="text" name="email" id="email" /><br />' +
                        '       <input type="submit" value="Recupera &gt;" />' +
                        '       </div> </form>' +
                        '       <div class="clearer"></div>' +
                        '       <div class="waitDiv"></div>' +
                        '       <div id="loginresult"></div>' +
                        '</div>';
                $('layout').insertBefore(login,$('main'));
                showLogin = new fx.Height('login', { duration: 500 });
                showLogin.hide();
        }
        
        
        if(showFriends) showFriends.hide();
        if(showPreferences) showPreferences.hide();
        if(showSearch) showSearch.hide();
        showLogin.toggle();
}

function ricerca() {
var ricerca = d.getElementById('ricerca');
        ricerca.id = 'ricerca';
        document.getElementById('ricerca').style.visibility = 'visible'; 
        document.getElementById('ricerca').style.display = 'block'; 
    var showRicerca = new fx.Height('ricerca', { duration: 500 });
        showRicerca.toggle();
}
function ricercaOff() {
var ricerca = d.getElementById('ricerca');
        ricerca.id = 'ricerca';
    var showRicerca = new fx.Height('ricerca', { duration: 500 });
        showRicerca.hide();
}
function legenda() {
var legenda = d.getElementById('legenda');
        legenda.id = 'legenda';
        document.getElementById('legenda').style.visibility = 'visible'; 
        document.getElementById('legenda').style.display = 'block'; 
    var showLegenda = new fx.Height('legenda', { duration: 500 });
        showLegenda.toggle();
}
function legendaOff() {
var legenda = d.getElementById('legenda');
        legenda.id = 'legenda';
    var showLegenda = new fx.Height('legenda', { duration: 500 });
        showLegenda.hide();
}



////////////////  GLOBAL TOOPTIP CONFIGURATION  /////////////////////
var ttAbove       = false;        // tooltip above mousepointer? Alternative: true
var ttBgColor     = "#ffffff";
var ttBgImg       = "";           // path to background image;
var ttBorderColor = "#cccccc";
var ttBorderWidth = 1;
var ttDelay       = 5;          // time span until tooltip shows up [milliseconds]
var ttFontColor   = "#000066";
var ttFontFace    = "arial,helvetica,sans-serif";
var ttFontSize    = "11px";
var ttFontWeight  = "normal";     // alternative: "bold";
var ttLeft        = false;        // tooltip on the left of the mouse? Alternative: true
var ttOffsetX     = 12;           // horizontal offset of left-top corner from mousepointer
var ttOffsetY     = 15;           // vertical offset                   "
var ttOpacity     = 80;          // opacity of tooltip in percent (must be integer between 0 and 100)
var ttPadding     = 3;            // spacing between border and content
var ttShadowColor = "";
var ttShadowWidth = 0;
var ttStatic      = false;        // tooltip NOT move with the mouse? Alternative: true
var ttSticky      = false;        // do NOT hide tooltip on mouseout? Alternative: true
var ttTemp        = 0;            // time span after which the tooltip disappears; 0 (zero) means "infinite timespan"
var ttTextAlign   = "left";
var ttTitleColor  = "#ffffff";    // color of caption text
var ttWidth       = 100;
////////////////////  END OF TOOLTIP CONFIG  ////////////////////////

var showCart = null;
var showListino = null;

function refreshcarrelloajax() {
        if(! $('carrelloajax')) {
                var carrelloajax = d.createElement('div');
                carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
                $('layout').insertBefore(carrelloajax,$('main'));
                }
                var request = new Ajaxcustom('/nic/carrelloajax.php');
        

                request.onload = function(content) {
                        $('carrelloajax').innerHTML = content;
                        showCart = new fx.Height('carrelloajax', { duration: 500 });
                        showCart.hide();
                        showCart.toggle();
                }
                request.send();
                //return false;
        
        if(showLogin) showLogin.hide();
        if(showSearch) showSearch.hide();
        if(showPreferences) showPreferences.hide();
        //if(showCart) showCart.toggle();
}
/*
function refreshcarrelloajaxconparametri(test) {
        if(! $('carrelloajax')) {
                var carrelloajax = d.createElement('div');
                carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
                $('layout').insertBefore(carrelloajax,$('main'));
                }
                var request = new Ajax('/nic/carrelloajax.php?'+ test);
                request.onload = function(content) {
                        $('carrelloajax').innerHTML = content;
                        showCart = new fx.Height('carrelloajax', { duration: 500 });
                        showCart.hide();
                        showCart.toggle();
                }
                request.send();        
        if(showLogin) showLogin.hide();
        if(showSearch) showSearch.hide();
        if(showPreferences) showPreferences.hide();
        //if(showCart) showCart.toggle();
}
*/
function refreshcarrelloajaxconparametri(test) {
if(! $('layout')) {
var eu=true;
if(! $('carrelloajax')) {
      var carrelloajax = d.createElement('div');
      carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
      $('main2').insertBefore(carrelloajax,$('main'));
      } } else {
var eu=false;
if(! $('carrelloajax')) {
      var carrelloajax = d.createElement('div');
            carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
	          $('layout').insertBefore(carrelloajax,$('main'));
		        }
      }
      if (eu) {
      var request = new Ajaxcustom('/nic/carrelloajaxeu.php?eu='+eu+'&'+test);
      } else {
 var request = new Ajaxcustom('/nic/carrelloajax.php?eu='+eu+'&'+test);
      }
     request.onload = function(content) {
      $('carrelloajax').innerHTML = content;
      showCart = new fx.Height('carrelloajax', { duration: 500 });
      showCart.hide();
      showCart.toggle();
       }
       request.send();
       if(showLogin) showLogin.hide();
       if(showSearch) showSearch.hide();
       if(showPreferences) showPreferences.hide();
       //if(showCart) showCart.toggle();
}

function refreshcarrelloajaxconparametricallback(test,diofa) {
if(! $('layout')) {
var eu=true;
if(! $('carrelloajax')) {
      var carrelloajax = d.createElement('div');
      carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
      $('main2').insertBefore(carrelloajax,$('main'));
      } } else {
var eu=false;
if(! $('carrelloajax')) {
      var carrelloajax = d.createElement('div');
            carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
                  $('layout').insertBefore(carrelloajax,$('main'));
                        }
      }
      if (eu) {
      var request = new Ajaxcustom('/nic/carrelloajaxeu.php?eu='+eu+'&'+test);
      } else {
 var request = new Ajaxcustom('/nic/carrelloajax.php?eu='+eu+'&'+test);
      }
     request.onload = function(content) {
      $('carrelloajax').innerHTML = content;
      showCart = new fx.Height('carrelloajax', { duration: 500 });
      showCart.hide();
  //    showCart.toggle();
       }
       request.send();
       if(showLogin) showLogin.hide();
       if(showSearch) showSearch.hide();
       if(showPreferences) showPreferences.hide();
       //if(showCart) showCart.toggle();

//alert('cristianotiozzo.com');

var arraydomini = new Array();
var d= new Array();
       var arraydominivalori = new Array();
       arraydomini = diofa.split("!");
       if (arraydomini.length>0){
       for (i=0;i<(arraydomini.length-1);i++) {
       //arrayopzionivalori[i]=document.getElementById(arrayopzioni[i]).value;
      // alert( arrayopzioni[i] );
arraydominivalori = arraydomini[i].split(":");	

dominio_=arraydominivalori[0];
d=dominio_.split("|");
dominio=d[1];
nuovascadenza=arraydominivalori[1];
if ($('riga_'+dominio)) {  
$('riga_'+dominio).removeClassName('selected');
$('riga_'+dominio).removeClassName('unfocused');
$('data_'+dominio).innerHTML = nuovascadenza;
}
	  
};
//opzionivalori=arrayopzionivalori.join(":");	
	  // alert( opzionivalori );  
}



//$('cristianotiozzo.com').removeClassName('selected');
//$('cristianotiozzo.com').removeClassName('unfocused');

//document.getElementById('cristianfenzi.org').style.display="none";

//mostracarrelloajax();
}





function refreshcarrelloajaxconparametriopfront(test) {
if(! $('carrelloajax')) {
      var carrelloajax = d.createElement('div');
         carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
  $('main2').insertBefore(carrelloajax,$('main'));
 // $('layout').insertBefore(carrelloajax,$('main'));
  //$('layout').insertBefore(carrelloajax,$('main'));
}       
    var request = new Ajaxcustom('/nic/carrelloajaxeu.php?'+ test);
    request.onload = function(content) {
    $('carrelloajax').innerHTML = content;
    showCart = new fx.Opacity('carrelloajax', { duration: 500 });
    showCart.hide();
    showCart.toggle();
    }
    request.send();
    if(showLogin) showLogin.hide();
    if(showSearch) showSearch.hide();
    if(showPreferences) showPreferences.hide();
    //if(showCart) showCart.toggle();
    }      
function refreshcarrelloajaxconparametriop(test) {
if(! $('carrelloajax')) {
   var carrelloajax = d.createElement('div');
       carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
   $('layout').insertBefore(carrelloajax,$('main'));
   }       
   var request = new Ajaxcustom('/nic/carrelloajax.php?'+ test);
   request.onload = function(content) {
   $('carrelloajax').innerHTML = content;
   showCart = new fx.Opacity('carrelloajax', { duration: 500 });
   showCart.hide();
   showCart.toggle();
   }
   request.send();
   if(showLogin) showLogin.hide();
   if(showSearch) showSearch.hide();
   if(showPreferences) showPreferences.hide();
   //if(showCart) showCart.toggle();
}
									
function mostracarrelloajax() {
    if(! $('carrelloajax')) {
            var carrelloajax = d.createElement('div');
              carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
                $('layout').insertBefore(carrelloajax,$('main'));
		var request = new Ajaxcustom('/nic/carrelloajax.php');
                request.onload = function(content) {
                        $('carrelloajax').innerHTML = content;
                        showCart = new fx.Height('carrelloajax', { duration: 500 });
                        showCart.hide();
                        showCart.toggle();
                }
                request.send();
        }
        if(showLogin) showLogin.hide();
        if(showSearch) showSearch.hide();
        if(showPreferences) showPreferences.hide();
        if(showCart) showCart.toggle();
}

function mostralistinoajax() {

if(! $('listinoajax')) {
var listinoajax = d.createElement('div');
listinoajax.id = 'listinoajax'; listinoajax.style.background = 'white';
if(!$('layout')) {
$('main2').insertBefore(listinoajax,$('main'));
} else {
$('layout').insertBefore(listinoajax,$('main'));
}
var request = new Ajaxcustom('listinoajax.php');
      request.onload = function(content) {
      $('listinoajax').innerHTML = content;
      showListino = new fx.Height('listinoajax', { duration: 500 });
      showListino.hide();
      showListino.toggle();
}
request.send();
}
 if(showLogin) showLogin.hide();
 if(showSearch) showSearch.hide();
 if(showCart) showCart.hide();
 if(showListino) showListino.toggle();
}
																  
function mostracarrelloajaxfront() {
	if(! $('carrelloajax')) {
var carrelloajax = d.createElement('div');
carrelloajax.id = 'carrelloajax'; carrelloajax.style.background = 'white';
	$('main2').insertBefore(carrelloajax,$('main'));
					
var request = new Ajaxcustom('/nic/carrelloajaxeu.php');
							

	request.onload = function(content) {
$('carrelloajax').innerHTML = content;
showCart = new fx.Height('carrelloajax', { duration: 500 });
showCart.hide();
showCart.toggle();
	}
request.send();
}
if(showLogin) showLogin.hide();
if(shownewLogin) shownewLogin.hide();
if(showSearch) showSearch.hide();
if(showPreferences) showPreferences.hide();
if(showCart) showCart.toggle();
}
																									

function testftp(div1,div2,username,password) {
        if(! $('ftp'+div1)) {
                var c = d.createElement('div');
                c.id = 'ftp'+div1; c.style.background = 'white';
                $(div1).insertBefore(c,$(div2));
                }
                var request = new Ajaxcustom('/admin/ajax/testftp.php?user='+username+'&pass='+password+'&diofa=1');


                request.onload = function(content) {
                        $('ftp'+div1).innerHTML = content;
                        showDiofaus = new fx.Height('ftp'+div1, { duration: 500 });
                        showDiofaus.hide();
                        showDiofaus.toggle();
                }
                request.send();

        if(showDiofaus) showDiofaus.toggle();
}


function diofaus(div1,div2,inizio,fine,colore,name,listiddiofa) {
        if(! $('c'+div1)) {
                var c = d.createElement('div');
                c.id = 'c'+div1; c.style.background = 'white';
                $(div1).insertBefore(c,$(div2));
                }
                var request = new Ajaxcustom('/admin/ajax/addpagamento.php?data='+inizio+'&fine='+fine+'&colore='+colore+'&name='+name+'&listiddiofa='+listiddiofa+'&diofa=1');


                request.onload = function(content) {
                        $('c'+div1).innerHTML = content;
                        showDiofaus = new fx.Height('c'+div1, { duration: 500 });
                        showDiofaus.hide();
                        showDiofaus.toggle();
                }
                request.send();
        
        if(showDiofaus) showDiofaus.toggle();
}

function diofausedit(div1,div2,inizio,fine,colore,name,listiddiofa) {
    if(! $('c'+div1)) {
       var c = d.createElement('div');
           c.id = 'c'+div1; c.style.background = 'white';
           $(div1).insertBefore(c,$(div2));
           }
           var request = new Ajaxcustom('/admin/ajax/editpagamento.php?data='+inizio+'&fine='+fine+'&colore='+colore+'&name='+name+'&listiddiofa='+listiddiofa);
               request.onload = function(content) {
              $('c'+div1).innerHTML = content;
               showDiofaus = new fx.Height('c'+div1, { duration: 500 });
               showDiofaus.hide();
               showDiofaus.toggle();
   }
   request.send();
   if(showDiofaus) showDiofaus.toggle();
  }


