$(document).ready(function() {
    $(".topMenuAction").click( function() {
        if ($("#openCloseIdentifier").is(":hidden")) {
            $("#slider").animate({ 
                marginLeft: "193px"
                }, 500 );
            $("#topMenuImage").html('<img src="images/contattirapidi.png"/>');
            $("#openCloseIdentifier").show();
        } else {
            $("#slider").animate({ 
                marginLeft: "-65px"
                }, 500 );
            $("#topMenuImage").html('<img src="images/contattirapidi.png"/>');
            $("#openCloseIdentifier").hide();
        }
    });  
});

// JavaScript Document

// script modulo informazioni //
function checkFields(theForm)
{

  if (theForm.nome.value == "")
  {
    alert("Inserire un valore per il campo \"Nome\".");
    theForm.nome.focus();
    return (false);
  }
  if (theForm.email.value == "")
  {
    alert("Inserire un valore per il campo \"E-Mail\".");
    theForm.email.focus();
    return (false);
  }
  if (theForm.email.value.length < 6)
  {
    alert("Inserire un indirizzo e-mail valido.");
    theForm.email.focus();
    return (false);
  }
  else if (theForm.email.value.indexOf("@")==-1)
  {
    alert("Inserire un indirizzo e-mail valido.");
    theForm.email.focus();
    return (false);
  }
  else if (theForm.email.value.indexOf(".")==-1)
  {
    alert("Inserire un indirizzo e-mail valido.");
    theForm.email.focus();
    return (false);
  }
  if (theForm.note.value == "")
  {
    alert("Compilare il campo \"Messaggio\".");
    theForm.note.focus();
    return (false);
  }
  if (theForm.privacy.checked == false)
  {
    alert("E' necessario autorizzare il trattamento dei dati personali per poter proseguire.");
    theForm.privacy.focus();
    return (false);
  }

  if (!fwCheckForm(6,"Itm_8_00","Il codice inserito non e' corretto!",0,"")) { fwMostraCaptcha("Itm_8_00"); return false; }

  
  return (true);
}

function fwCaptchaLayer(sName) {return document.getElementById?document.getElementById(sName) : document.all?document.all[sName] : "";}

function fwCaptchaUrl(sUrl) {
var xmlHttp; var sResult; try {
xmlHttp=new XMLHttpRequest(); }
catch (e) {
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) {
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) {
alert("Your browser does not support AJAX!"); return false; }}
}
xmlHttp.open('GET', sUrl, false); xmlHttp.send(null); while (xmlHttp.readyState != 4); if (xmlHttp.status == 200) {
sResult = xmlHttp.responseText; }
else {
sResult = "-1"; }
return sResult; }


function fwCheckForm(iType, sID, sAlert, iCount, sUrl) {
var sError = ""; switch (iType) {
case 0:
if (fwCaptchaLayer(sID).value == "")
sError = sID; break; case 1:
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (fwCaptchaLayer(sID).value == "" || !filter.test(fwCaptchaLayer(sID).value))
sError = sID; break; case 2:
if (fwCaptchaLayer(sID + "_d").selectedIndex == 0 || fwCaptchaLayer(sID + "_m").selectedIndex == 0 || fwCaptchaLayer(sID + "_y").value == "")
sError = sID + "_y"; break; case 3:
if (fwCaptchaLayer(sID).selectedIndex == 0)
sError = sID; break; case 4:
var bValid = false; while(iCount-- && !bValid)
if (fwCaptchaLayer(sID + (iCount+1)).checked == true)
bValid = true; if(!bValid)
sError = sID + "1"; break; case 5:
if (fwCaptchaUrl(sUrl+'?chk='+sID+'&ans='+ escape(fwCaptchaLayer(sID).value)) != '0')
sError = sID; break; case 6:
if (fwCaptchaUrl('captcha/imcaptcha.php?action=check&code='+fwCaptchaLayer(sID+'_cpf').value+'&ans='+fwCaptchaLayer(sID+'_cpv').value) != '0')
sError = sID+'_cpv'; break; }
if(sError != "") {
alert(sAlert); fwCaptchaLayer(sError).focus(); return (false); }
return (true); }

function fwMostraCaptcha(sName) {
var sCode = ""; var i; var sChar; for (i=0; i<5; i++) {
do
sChar = parseInt(Math.random()*9); while (sCode.indexOf(sChar) > -1)
sCode = sCode+sChar; }
fwCaptchaLayer(sName+"_cpf").value=sCode; fwCaptchaLayer(sName+"_cpn").src="captcha/imcaptcha.php?action=show&code="+sCode; }


