var sito="\/to\/th\/";
function loading(contenitore) {
  $(contenitore).style.display='inline';
  $(contenitore).innerHTML=$('loading').innerHTML;
}

function unloading(contenitore) {
  $(contenitore).innerHTML='';
}
function effetto(contenitore) {
        new Effect.Highlight(contenitore,{duration:1, from:0.3, to: 1,startcolor: '#bbccaa',endcolor: '#ffffff'});
}
function controlla_pagina_rss(){
  if ($('news')) {
  }  else  {
    $('rss').style.display='inline';
    updater_standard('rss','news', ''); 
  };
}
function controlla_pagina_login(){
  if ($('login')) {
    updater_standard('primo_dettaglio','control_panel', ''); 
    updater_standard('secondo_dettaglio','vetrina', ''); 
    updater_standard('contenuto','presentazione', ''); 
    updater_standard('rss','news', ''); 
  }
}
function updater_standard(a,b,c,d) {
c=unescape(c);
 if (b.indexOf('http')) {
 var sito="\/to\/th\/";
 } else {
 var sito="";
 };
$(a).style.display='inline';
$(a).style.background_color='#fff';
// alert($(a).getStyle('display'))

if (d==undefined) { d='0'; }
    if (d=='1') {
    new Ajax.Updater(a,sito + b, {method:'post',postBody:c,evalScripts:true,success:a, asynchronous:false});
    } else {
     new Ajax.Updater(a,sito + b, {method:'post',postBody:c,evalScripts:true,success:a, asynchronous:true});
     }
}
      
function cestino(parametri,pagina) {
// alert(parametri);
updater_standard('rss',pagina, parametri,'1'); 
updater_standard('primo_dettaglio','control_panel', '','1');
}
function aumenta(quantityname,valore_attuale,sessionid,varquantity,process) {
  valore_attuale++;
  var url='mv_nextpage=ord/basket&mv_session_id=' + sessionid + '&mv_todo=refresh&mv_ip=2&' +  quantityname + '=' + valore_attuale + '&' + varquantity;
  updater_standard('primo_dettaglio','control_panel', ''); 
  updater_standard('rss',process, url); 
  updater_standard('primo_dettaglio','control_panel', ''); 
}
function diminuisci(quantityname,valore_attuale,sessionid,varquantity,process) {
  valore_attuale--;
  var url='mv_nextpage=ord/basket&mv_session_id=' + sessionid + '&mv_todo=refresh&mv_ip=2&' +  quantityname + '=' + valore_attuale + '&' + varquantity;
  updater_standard('primo_dettaglio','control_panel', ''); 
  updater_standard('rss',process, url); 
  updater_standard('primo_dettaglio','control_panel', ''); 
}
  function apri_menu_due(variabile,livello,ildiv) {
    controlla_pagina_rss();
    controlla_pagina_login();
    if (livello == '0') {
      updater_standard('lresources','menu_secondo_livello', 'primo_livello=' + variabile);
      updater_standard('contenuto','presentazione', '');
      updater_standard('secondo_dettaglio','vetrina', '');
    }
    else {

      updater_standard('lresources','menu_secondo_livello',   'primo_livello=' + variabile + '&secondo_livello=' + livello );
      updater_standard('secondo_dettaglio','vetrina', 'livello=' + livello);
      updater_standard('contenuto','presentazione', '');
  //    updater_standard(ildiv,'menu_terzo',  'livello=' + livello);
    };
  }
  function apri_menu_tre(variabile,livello,urlo,pagina,ildiv) {
      updater_standard('lresources','menu_secondo_livello',   'primo_livello=' + variabile + '&secondo_livello=' + livello);
      updater_standard('secondo_dettaglio','vetrina', 'livello=' + livello);
      updater_standard('contenuto',pagina,  urlo + '&livello=' + livello);
  }



function carrello_in_cart(url) {
  $('rss').style.display='inline';
  // url='[scratch ajax_form]' + document.getElementById('[item-code]').innerHTML;
  updater_standard('rss','order', url,'1'); 
  updater_standard('primo_dettaglio','control_panel', '','1');
}
function link_secondo_livello(pagina, form, categoria) { 
  controlla_pagina_login();
  updater_standard('contenuto',pagina, form);
  updater_standard('vetrina','dettaglio_voce_menu', 'categoria=' + categoria);
  controlla_pagina_rss();
}





function centra_verticale() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
     myWidth = document.documentElement.clientWidth;
     myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
     //IE 4 compatible
     myWidth = document.body.clientWidth;
     myHeight = document.body.clientHeight;
  }
  marginepx="";
  if (myHeight > 700) {
    var margine=0;
    margine=(myHeight-700)/2;
    marginepx= margine + 'px';
  }
  if (marginepx!="") {
    $('the_body').style.marginTop=marginepx;
  }
}

function compra_flypage(parametri_form,codice,storia) {
  updater_standard('rss','order', parametri_form + $(codice).innerHTML);
  updater_standard('contenuto',storia, '');
}

function apri_flypage(codice) {
  $('rss').innerHTML='';
  updater_standard('contenuto',codice, '')
}

function dettaglio_ordini(ordine) {
  $('primo_dettaglio').style.display='inline';
  $('secondo_dettaglio').style.display='inline';
  $('contenuto').style.display='inline';
  $('rss').style.display='inline';
  updater_standard('primo_dettaglio','control_panel',''); 
  if (ordine != '') {
  updater_standard('secondo_dettaglio','query/order_detail', 'settore=1&ordine='+ ordine); 
  updater_standard('contenuto','query/order_detail', 'settore=2&ordine='+ ordine); 
  updater_standard('rss','query/order_detail', 'settore=3&ordine='+ ordine); 
  } else {
  updater_standard('secondo_dettaglio','vetrina',  ''); 
  updater_standard('contenuto','query/check_orders', ''); 
  controlla_pagina_rss();
  }
 
}
function lost_password(fase) {
  if (fase !='2') {
  $('primo_dettaglio').style.display='inline';
  $('secondo_dettaglio').style.display='inline';
  $('contenuto').style.display='inline';
  $('rss').style.display='inline';
  updater_standard('primo_dettaglio','control_panel', ''); 
  updater_standard('secondo_dettaglio','vetrina', ''); 
  updater_standard('contenuto','lost_password', ''); 
  controlla_pagina_rss();
  } else {
  parametri='fase=2&email=' + $('email').value;
  updater_standard('contenuto','lost_password', parametri); 
  }
} 
function pagina_login() {

  updater_standard('secondo_dettaglio','login',  ''); 
  $('contenuto').innerHTML='';
  $('contenuto').style.display='none';
  $('rss').innerHTML='';
  $('rss').style.display='none';
}
function controlla_login() {
if ($('mv_username').value=='' || $('mv_username').value=='username' || $('mv_password').value=='' || $('mv_password').value=='password') {
  alert('inserire un identificativo utente valido oppure procedere con la creazione di un nuovo utente premendo il tasto: \'Nuovo Utente\'')
} else { 
  url='mv_click=Login&';
  url+='mv_todo=return&';
  url+='mv_nextpage=account&';
  url+='mv_cookie_password=0&';
  url+='mv_check=Accedi&';
  url+='mv_failpage=nopass&';
  url+='mv_successpage=benvenuto&';
  url+='mv_username=' + $('mv_username').value + '&';
  url+='mv_password=' + $('mv_password').value; 

  updater_standard('contenuto','process', url); 
  updater_standard('secondo_dettaglio','vetrina', ''); 
  updater_standard('primo_dettaglio','control_panel', ''); 
  }
}
function ordina(idsessione,pagamento) {
  var url='';
  url+='mv_shipmode=default&';
  url+='mv_session_id=' + idsessione;
  url+='mv_doit=refresh&';
  url+='mv_order_profile=bonifico&';
  url+='mv_nextpage=ord%2Fcheckout&';
  url+='mv_order_route=log+main+copy_user&';
  url+='mv_check=Save_database&';
  url+='mv_click=&';
  url+='mv_click=Compra&';
  url+='payment_method=' + pagamento + '&';
  url+='mv_payment=' + pagamento + '&';
  url+='po_number=&'
  url+='email_copy=1&';
  url+='mv_todo=submit';

  updater_standard('contenuto','process', url ); 
  unloading('secondo_dettaglio');
  unloading('rss');
}





function registrati() {
  var msg='';
  if ($('mv_username_new').value.length < 6  ) {
    msg=msg + 'inserire un nome utente di almeno 6 caratteri \n\n'; 
  }
  if ($('mv_password_new').value.length < 6 ) {
    msg=msg + 'inserire una password di almeno 6 caratteri \n\n'; 
  }
  if ($('mv_verify_new').value.length < 6 ) {
    msg=msg + 'inserire una password di verifica di almeno 6 caratteri \n\n'; 
  }

  if ($('mv_verify_new').value !=  $('mv_password_new').value) {
    msg=msg + 'inserire password e password di verifica identiche \n\n'; 
  }
   if (msg.length > 10) {
    alert(msg);
} else { 
  url='mv_click=NewAccount&';
  url+='mv_todo=return&';
  url+='mv_nextpage=account&';
  url+='mv_cookie_password=0&';
  url+='mv_failpage=login&';
  url+='mv_successpage=account&';
  url+='function=new_account&';
  url+='mv_order_profile=account_change&';
  url+='mv_username=' + $('mv_username_new').value + '&';
  url+='mv_password=' + $('mv_password_new').value + '&'; 
  url+='mv_verify=' + $('mv_verify_new').value; 
// mv_click=NewAccount&mv_failpage=ord%2Fmulti&mv_successpage=ord%2Fcountry&mv_nextpage=ord%2Fcountry&mv_todo=return&mv_username=aaaaa&mv_password=aaaaaa&mv_verify=aaaaaa
// mv_click=NewAccount&mv_doit=return&function=new_account&mv_nextpage=ord%2Fbasket&mv_username=abcabcabc&mv_password=abcabcabc&mv_verify=abcabcabc
 // alert(url);
  $('contenuto').style.display='inline';
 $('secondo_dettaglio').innerHTML='';
  updater_standard('secondo_dettaglio','process', url ); 
  updater_standard('primo_dettaglio','control_panel', ''); 
  }

  // 
  // mv_click=NewAccount&
  // mv_check=NewAccount&
  // mv_successpage=account&
  // mv_username=puccino&
  // mv_password=rossini&
  // mv_verify=rossini
}
function reset_home_page() {
  updater_standard('lresources','slideshow', ''); 
  updater_standard('primo_dettaglio','control_panel', ''); 
  updater_standard('secondo_dettaglio','vetrina', ''); 
  updater_standard('contenuto','presentazione', ''); 
  updater_standard('rss','news', ''); 
}
function controlla_contattaci() {
    var msg='';
    if (!$('email').value || $('email').value.length <=7) {
      msg="Inserire un indirizzo di mail valido \n ";
    }
    if (!$('altro').value || $('altro').value.length <=5) {
      msg+="Inserire un testo da inviare come messaggio \n ";
    }
    if (msg.length >1) {
      alert(msg);
    } else {
       mail=$('email');
       altro=$('altro');
       parametri='fase=2&email='+ mail.value + '&altro=' + altro.value;
       updater_standard('contenuto','contattaci', parametri );
    }
}
function logout() {
  updater_standard('contenuto','logout', ''); 
  updater_standard('secondo_dettaglio','vetrina', ''); 
  $('contenuto').style.display='inline';
}
function account() {
  $('contenuto').innerHTML='';
 //  $('contenuto').style.display='none';
  $('rss').innerHTML='';
 // $('rss').style.display='none';
  updater_standard('secondo_dettaglio','account', ''); 
  updater_standard('primo_dettaglio','control_panel', ''); 
}


function descrizione() {
    $('descrizione').style.display='inline';
    $('scheda_tecnica').style.display='none';
    $('immagini').style.display='none';
}
function scheda_tecnica() {
    $('scheda_tecnica').style.display='inline';
    $('descrizione').style.display='none';
    $('immagini').style.display='none';
}
function immagini() {
    $('immagini').style.display='inline';
    $('descrizione').style.display='none';
    $('scheda_tecnica').style.display='none';
}
// inserimento('a');

function inserimento(campo) {
  $('contatore').value='0';
  if ($('fname').value.length < 2 ) { $('fname').style.backgroundColor='#daa'; } else { $('fname').style.backgroundColor='#aea'; $('contatore').value++; };
  if ($('lname').value.length < 2 ) { $('lname').style.backgroundColor='#daa'; } else { $('lname').style.backgroundColor='#aea';$('contatore').value++;};
  if ($('addressuno').value.length < 2 ) { $('addressuno').style.backgroundColor='#daa'; } else { $('addressuno').style.backgroundColor='#aea'; $('contatore').value++;};
  if ($('city').value.length < 2 ) { $('city').style.backgroundColor='#daa'; } else { $('city').style.backgroundColor='#aea'; $('contatore').value++;};
  if ($('zip').value.length < 5 ) { $('zip').style.backgroundColor='#daa'; } else { $('zip').style.backgroundColor='#aea'; $('contatore').value++;};
  if ($('country').value.length < 2 ) { $('country').style.backgroundColor='#daa'; } else { $('country').style.backgroundColor='#aea'; $('contatore').value++;};
  // if ($('state').value.length < 5 ) { $('state').style.backgroundColor='#daa'; } else { $('state').style.backgroundColor='#aea'; $('contatore').value++;};
  if ($('phone_day').value.length < 5 ) { $('phone_day').style.backgroundColor='#daa'; } else { $('phone_day').style.backgroundColor='#aea'; $('contatore').value++;};
  controlla_mail(); 
  ok_tasto_registra();
}
function ok_tasto_registra() {
  if ($('contatore').value > 7) {
    $('tasto_ok').style.display='inline';
  } else {
    $('tasto_ok').style.display='none';
  }
}

function controlla_mail() {
  var msg='';
  var emailStr=$('email').value;
  if ($('email').value.length < 7) {
    msg=msg+'\n non e\' stato inserito correttamente il campo Email (' + $('email').value + ')';
  } else {
    var emailPat=/^(.+)@(.+)$/;
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
    var validChars="\[^\\s" + specialChars + "\]";
    var quotedUser="(\"[^\"]*\")";
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom=validChars + '+';
    var word="(" + atom + "|" + quotedUser + ")";
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

    var matchArray=emailStr.match(emailPat);
    if (matchArray==null) {
       msg=msg+"\nL'indirizzo di email sembra non essere corretto controllare la presenza di @ e punti."
    }
    var user=matchArray[1]
    var domain=matchArray[2]
    if (user.match(userPat)==null) {
      // user is not valid
      msg=msg+"\nL'indirizzo di email ha lo nome utente non scritto correttamente"}
      var IPArray=domain.match(ipDomainPat)
      if (IPArray!=null) {
        // this is an IP address
          for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
                alert("Destination IP address is invalid!")
            }
          }
        return true
      }
      var domainArray=domain.match(domainPat)
      if (domainArray==null) {
       msg=msg+"\nL'indirizzo di email &egrave; scritto con un dominio non corretto"
      }
      var atomPat=new RegExp(atom,"g")
      var domArr=domain.match(atomPat)
      var len=domArr.length
      if (domArr[domArr.length-1].length<2 || 
         domArr[domArr.length-1].length>3) {
        msg=msg+"\nL'indirizzo di email dovrebbe terminare con un dominio di almeno tre lettere e un identificativo di stato di almeno 2!"
      }

      if (len<2) {
        msg=msg+"\nL'indirizzo di email sembra non essere completo di un dominio!"
      }
    }
  if (msg.length > 0)  {  
    $('email').style.backgroundColor='#daa';
    $('contatore').value='0';
    if ($('fname').value.length < 2 ) { $('fname').style.backgroundColor='#daa'; } else { $('fname').style.backgroundColor='#aea'; $('contatore').value++; };
    if ($('lname').value.length < 2 ) { $('lname').style.backgroundColor='#daa'; } else { $('lname').style.backgroundColor='#aea';$('contatore').value++;};
    if ($('addressuno').value.length < 2 ) { $('addressuno').style.backgroundColor='#daa'; } else { $('addressuno').style.backgroundColor='#aea'; $('contatore').value++;};
    if ($('city').value.length < 2 ) { $('city').style.backgroundColor='#daa'; } else { $('city').style.backgroundColor='#aea'; $('contatore').value++;};
    if ($('zip').value.length < 5 ) { $('zip').style.backgroundColor='#daa'; } else { $('zip').style.backgroundColor='#aea'; $('contatore').value++;};
    if ($('country').value.length < 2 ) { $('country').style.backgroundColor='#daa'; } else { $('country').style.backgroundColor='#aea'; $('contatore').value++;};
    // if ($('state').value.length < 5 ) { $('state').style.backgroundColor='#daa'; } else { $('state').style.backgroundColor='#aea'; $('contatore').value++;};
    if ($('phone_day').value.length < 5 ) { $('phone_day').style.backgroundColor='#daa'; } else { $('phone_day').style.backgroundColor='#aea'; $('contatore').value++;};
    ok_tasto_registra();
  } else {
    $('email').style.backgroundColor='#aea';
    $('contatore').value++;
  if ($('contatore').value > 7) {
    $('tasto_ok').style.display='inline';
  } else {
    $('tasto_ok').style.display='none';
  }
  }
}
function fatturazione2() {
    $('anagrafica').style.display='none';
    $('fatturazione').style.display='inline';
    $('conferma').style.display='none';

    $('anagrafica1').style.backgroundColor= '#96cd24';
    $('anagrafica2').style.backgroundColor= '#96cd24';
    $('anagrafica3').style.backgroundColor= '#96cd24';
    $('anagrafica4').style.backgroundColor= '#96cd24';
    $('anagrafica5').style.backgroundColor= '#96cd24';

    $('fatturazione1').style.backgroundColor= '#D0F0FB';
    $('fatturazione2').style.backgroundColor= '#D0F0FB';
    $('fatturazione3').style.backgroundColor= '#D0F0FB';
    $('fatturazione4').style.backgroundColor= '#D0F0FB';
    $('fatturazione5').style.backgroundColor= '#D0F0FB';

    $('conferma1').style.backgroundColor= '#96cd24';
    $('conferma2').style.backgroundColor= '#96cd24';
    $('conferma3').style.backgroundColor= '#96cd24';
    $('conferma4').style.backgroundColor= '#96cd24';
    $('conferma5').style.backgroundColor= '#96cd24';

    $('anagrafica1').style.color= '#FFFFFF';
    $('anagrafica2').style.color= '#FFFFFF';
    $('anagrafica3').style.color= '#FFFFFF';
    $('anagrafica4').style.color= '#FFFFFF';
    $('anagrafica5').style.color= '#FFFFFF';

    $('fatturazione1').style.color= '#527173';
    $('fatturazione2').style.color= '#527173';
    $('fatturazione3').style.color= '#527173';
    $('fatturazione4').style.color= '#527173';
    $('fatturazione5').style.color= '#527173';

    $('conferma1').style.color= '#FFFFFF';
    $('conferma2').style.color= '#FFFFFF';
    $('conferma3').style.color= '#FFFFFF';
    $('conferma4').style.color= '#FFFFFF';
    $('conferma5').style.color= '#FFFFFF';



}
function conferma2() {
    $('anagrafica').style.display='none';
    $('fatturazione').style.display='none';
    $('conferma').style.display='inline';

    $('anagrafica1').style.backgroundColor= '#96cd24';
    $('anagrafica2').style.backgroundColor= '#96cd24';
    $('anagrafica3').style.backgroundColor= '#96cd24';
    $('anagrafica4').style.backgroundColor= '#96cd24';
    $('anagrafica5').style.backgroundColor= '#96cd24';

    $('fatturazione1').style.backgroundColor= '#96cd24';
    $('fatturazione2').style.backgroundColor= '#96cd24';
    $('fatturazione3').style.backgroundColor= '#96cd24';
    $('fatturazione4').style.backgroundColor= '#96cd24';
    $('fatturazione5').style.backgroundColor= '#96cd24';

    $('conferma1').style.backgroundColor= '#D0F0FB';
    $('conferma2').style.backgroundColor= '#D0F0FB';
    $('conferma3').style.backgroundColor= '#D0F0FB';
    $('conferma4').style.backgroundColor= '#D0F0FB';
    $('conferma5').style.backgroundColor= '#D0F0FB';

    $('anagrafica1').style.color= '#FFFFFF';
    $('anagrafica2').style.color= '#FFFFFF';
    $('anagrafica3').style.color= '#FFFFFF';
    $('anagrafica4').style.color= '#FFFFFF';
    $('anagrafica5').style.color= '#FFFFFF';

    $('fatturazione1').style.color= '#FFFFFF';
    $('fatturazione2').style.color= '#FFFFFF';
    $('fatturazione3').style.color= '#FFFFFF';
    $('fatturazione4').style.color= '#FFFFFF';
    $('fatturazione5').style.color= '#FFFFFF';

    $('conferma1').style.color= '#527173';
    $('conferma2').style.color= '#527173';
    $('conferma3').style.color= '#527173';
    $('conferma4').style.color= '#527173';
    $('conferma5').style.color= '#527173';


}
function anagrafica2() {
    $('anagrafica').style.display='inline';
    $('fatturazione').style.display='none';
    $('conferma').style.display='none';
    $('anagrafica1').style.backgroundColor= '#D0F0FB';
    $('anagrafica2').style.backgroundColor= '#D0F0FB';
    $('anagrafica3').style.backgroundColor= '#D0F0FB';
    $('anagrafica4').style.backgroundColor= '#D0F0FB';
    $('anagrafica5').style.backgroundColor= '#D0F0FB';

    $('fatturazione1').style.backgroundColor= '#96cd24';
    $('fatturazione2').style.backgroundColor= '#96cd24';
    $('fatturazione3').style.backgroundColor= '#96cd24';
    $('fatturazione4').style.backgroundColor= '#96cd24';
    $('fatturazione5').style.backgroundColor= '#96cd24';

    $('conferma1').style.backgroundColor= '#96cd24';
    $('conferma2').style.backgroundColor= '#96cd24';
    $('conferma3').style.backgroundColor= '#96cd24';
    $('conferma4').style.backgroundColor= '#96cd24';
    $('conferma5').style.backgroundColor= '#96cd24';

    $('anagrafica1').style.color= '#527173';
    $('anagrafica2').style.color= '#527173';
    $('anagrafica3').style.color= '#527173';
    $('anagrafica4').style.color= '#527173';
    $('anagrafica5').style.color= '#527173';

    $('fatturazione1').style.color= '#FFFFFF';
    $('fatturazione2').style.color= '#FFFFFF';
    $('fatturazione3').style.color= '#FFFFFF';
    $('fatturazione4').style.color= '#FFFFFF';
    $('fatturazione5').style.color= '#FFFFFF';

    $('conferma1').style.color= '#FFFFFF';
    $('conferma2').style.color= '#FFFFFF';
    $('conferma3').style.color= '#FFFFFF';
    $('conferma4').style.color= '#FFFFFF';
    $('conferma5').style.color= '#FFFFFF';

}
function inserimento_anagrafica(sessionid,mv_username, mv_password, mv_verify) {
var url='';
url=url + '&mv_doit=return';
url=url + '&mv_click=Save_database';
url=url + '&function=new_account';
url=url + '&mv_session_id=' + sessionid;
url=url + '&mv_order_profile=account_change';
url=url + '&mv_todo=return';
url=url + '&mv_nextpage=benvenuto';
url=url + '&mv_check=Save_database';
url=url + '&mv_successpage=contatti';
if (mv_password.length >0) {

updater_standard('contenuto','finta', 'nuovo_utente=1'); 
url=  url + '&mv_username=' + mv_username;
url=  url + '&mv_password=' + mv_password;
url=  url + '&mv_verify=' + mv_verify;
} else {
url=  url + '&mv_username=' + mv_username;
// url=  url + '&mv_password=' + $('mv_password.value');
// url=  url + '&mv_verify=' + $('mv_verify').value;

}
url=  url + '&fname=' + $('fname').value;
url=  url + '&lname=' + $('lname').value;
url=  url + '&address1=' + $('addressuno').value;
url=  url + '&city=' + $('city').value;
url=  url + '&state=' + $('state').value;
url=  url + '&zip=' + $('zip').value;
url=  url + '&email=' + $('email').value;
url=  url + '&country=' + $('country').value;
url=  url + '&phone_day=' + $('phone_day').value;
url=  url + '&phone_night=' + $('phone_night').value;
url=  url + '&payment_method=credit';
url=  url + '&company=' + $('company').value;
url=  url + '&b_nickname=' + $('b_nickname').value;
url=  url + '&b_fname=' + $('b_fname').value;
url=  url + '&b_lname=' + $('b_lname').value;
url=  url + '&b_address1=' + $('b_addressuno').value;
url=  url + '&b_city=' + $('b_city').value;
url=  url + '&b_state=' + $('b_state').value;
url=  url + '&b_zip=' + $('b_zip').value;
url=  url + '&b_country=' + $('b_country').value;

updater_standard('primo_dettaglio','control_panel', ''); 
updater_standard('secondo_dettaglio','vetrina', ''); 
$('contenuto').style.display='inline';
updater_standard('contenuto','process', url); 
}

/*

fine zona anagrafica

*/
function vuota() {

}
  var handlerFunc = function(t) {
    $('contenuto').innerHTML=(t.responseText);
  }

  var errFunc = function(t) {
    alert('Error ' + t.status + ' -- ' + t.statusText);
  }

  function funzione(div,span,livello,spand) {
   $(div).innerHTML='';
   elements=getElementsByClassName(document, span);
   elementsd=getElementsByClassName(document, spand);
   var testo='';
    for (i=0; i < elements.length; i++) {
     l=i+1;
      testo += '<div id=\"panel' + l + '\" class=\"accordion\">';
      testo += '<div id=\"panel' + l + 'Header\" class=\"accordionTabTitleBar\">';
      testo += elementsd[i].innerHTML ;
      testo += '<\/div>';
      testo += '<div id=\"panel' + l + 'Content\" class=\"accordionTabContentBox\">';
      testo += elements[i].innerHTML ;
      testo += '<\/div>';
      testo += '<\/div>';

//            $(div).innerHTML +=elements[i].innerHTML;
    }
    if (div != 'secondo_dettaglio') {
      $(div).innerHTML= testo;
      new Rico.Accordion( 'lresources', {         expandedBg          : '#D0F0FB', hoverBg             : '#D0F0FB', collapsedBg         : '#D0F0FB', expandedTextColor   : '#0A1237', expandedFontWeight  : 'bold', hoverTextColor      : '#000227', collapsedTextColor  : '#0a1237', collapsedFontWeight : 'normal', hoverTextColor      : '#9aa2b7', borderColor         : '', panelHeight         : 150, onHideTab           : null, onShowTab           : null, onLoadShowTab       : 0} ); 
    }
//    if (div == 'secondo_dettaglio') {

//      $(div).innerHTML= testo;
//      new Rico.Accordion( 'secondo_dettaglio', {         expandedBg          : '#D0F0FB', hoverBg             : '#D0F0FB', collapsedBg         : '#D0F0FB', expandedTextColor   : '#0A1237', expandedFontWeight  : 'bold', hoverTextColor      : '#000227', collapsedTextColor  : '#0a1237', collapsedFontWeight : 'normal', hoverTextColor      : '#9aa2b7', borderColor         : '', panelHeight         : 60, onHideTab           : null, onShowTab           : null, onLoadShowTab       : 0 } ); 
//    }
  }

function getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
function Slideshow(slideshow, timeout) {
  this.slides = [];
  var nl = $(slideshow).getElementsByTagName('div');
  for (var i = 0; i < nl.length; i++) {
    if (Element.hasClassName(nl[i], 'slide')) {
      this.slides.push(nl[i]);
    }
  }
  this.timeout = timeout;
  this.current = 0;
 
  for (var i = 0; i < this.slides.length; i++) {
    this.slides[i].style.zIndex = this.slides.length - i;
  }
 
  Element.show(slideshow);
  setTimeout((function(){this.next();}).bind(this), this.timeout + 850);
}
Slideshow.prototype = {
  next: function() {
    for (var i = 0; i < this.slides.length - 1; i++) {
      var slide = this.slides[(this.current + i) % this.slides.length];
      slide.style.zIndex = this.slides.length - i;
    }
 
    Effect.Fade(this.slides[this.current], {
      afterFinish: function(effect) {
        effect.element.style.zIndex = 0;
        Element.show(effect.element);
        Element.setOpacity(effect.element, 1);
      }
    });
    
    this.current = (this.current + 1) % this.slides.length;
    setTimeout((function(){this.next();}).bind(this), this.timeout + 850);
  }
}

