function w3gCloseCallMe() {
 new Effect.Morph('richiamami', {
  style: { bottom: '-212px' }, duration: 0.150
 });
}

function w3gOpenCallMe() {
 new Effect.Morph('richiamami', {
   style: { bottom: '-2px' }, duration: 0.150
  });
}

function w3gValidateFormCallMe() {
 var findError=false;
 var nome=$('w3gCallMeNome');
 if (nome.value=="") {
  $('richiamami_errore_nome').update('Il campo nome non puņ essere vuoto');
  findError=true;
 } else $('richiamami_errore_nome').update('');
 
 var telefono=$('w3gCallMeTelefono');
 if (telefono.value=="") {
  $('richiamami_errore_telefono').update('Il campo telefono non puņ essere vuoto');
  findError=true;
 } else $('richiamami_errore_telefono').update('');
 
 var richiamamiValue = $('richiamami_quando_value_hidden').value;
 if (richiamamiValue=='') {
  $('richiamami_errore_quando').update('Selezionare quando si desidera essere richiamati');
  findError=true;
 } else $('richiamami_errore_quando').update('');
 
 var fasciaOrariaValue = $('fascia_oraria_value_hidden').value;
 if (fasciaOrariaValue=='') {
  $('richiamami_errore_fascia_oraria').update('Selezionare la fascia oraria');
  findError=true;
 } else $('richiamami_errore_fascia_oraria').update('');
 // se ci sono stati errori di validazione del form esci
 if (findError) return false;
 
 var note="";
 note+="<tr><td class='table_name'>TELEFONO</td><td class='table_value'>"+telefono.value+"</td></tr>";
 note+="<tr><td class='table_name'>QUANDO RICHIAMARE</td><td class='table_value'>"+$('richiamami_quando_value_hidden').value+"</td></tr>";
 note+="<tr><td class='table_name'>FASCIA ORARIA</td><td class='table_value'>"+$('fascia_oraria_value_hidden').value+"</td></tr>";
 $('note').value=note;
 
 new Ajax.Request('/vitaweb/contactSend.do', {
  method: 'post',
  parameters: $('w3gFormCallMe').serialize(true)
  }); 
 $('richiamami_form').style.display="none";
 $('richiamami_confirmed').style.display="block";
}

function w3gOpenCloseSelect(idSelect) { 
 var elem=$(idSelect+'_values');
 if (elem.style.display=="none") elem.style.display="block";
 else elem.style.display="none";
}

function w3gSetSelectValue(idSelect,selectValue) {
 $(idSelect+'_value_hidden').value = selectValue;
 $(idSelect+'_value').innerHTML = selectValue;
 $(idSelect+'_values').style.display="none"; 
}

onloadAddFunction(w3gInitializeCallMe);

function w3gInitializeCallMe() {
 try {
 $('richiamami_trigger').observe('click', w3gOpenCallMe);
 $('close').observe('click', w3gCloseCallMe);
 
 var w3gIEversion;
 if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
  w3gIEversion=new Number(RegExp.$1) // capture x.x portion and store as a number
  if (w3gIEversion<7) {
   Event.observe(window,'scroll', function() {
    w3gShowHideOverSelect('richiamami');
    w3gShowHideOverSelect('richiamami_trigger');
   }); 
   $('richiamami_trigger').observe('click', function() {
    $('richiamami').style.setExpression('top', "((0 - richiamami.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' )");
    w3gShowHideOverSelect('richiamami');
    w3gShowHideOverSelect('richiamami_trigger');
   });
   $('close').observe('click', function() {
    $('richiamami').style.setExpression('top', "(( 212 - richiamami.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' )");
    w3gShowHideOverSelect('richiamami');
    w3gShowHideOverSelect('richiamami_trigger');
   });
  }
 }

 document.body.appendChild($('w3gFormCallMe'));
 if (w3gIEversion<7) {
  var newlink = document.createElement('link');
  newlink.setAttribute('type', 'text/css');
  newlink.setAttribute('rel', 'stylesheet');
  newlink.setAttribute('href', '/vitaweb/media/show?21982');
  document.body.appendChild(newlink);
 }
 $('w3gFormCallMe').style.display="block";
 } catch (e) {}
}

function w3gShowHideOverSelect(elemId) {
 var elem = $(elemId);
 selectArr=$$("select");
 for (i=0; i<selectArr.length; i++) {
  var element2=selectArr[i];
  if (elem.isOver(element2)) {
   element2.isOverlapped=elem;
   element2.style.visibility='hidden';
  } 
  else if (element2.isOverlapped==elem) {
   element2.style.visibility='visible'; 
  }
 }		
}