$(function()
{
//fCheckObbligatori();
//$('#nominativo').focus();
$(document).bind('keydown', 'Ctrl+n', function()
{
$('#frmQuote textarea').lorem({ type: 'paragraphs',amount:'4',ptags:false});
$('#frmQuote input[type=checkbox]').attr('checked',true);
$('#nominativo').val('Lorem Ipsum');
$('#indirizzo').val('Via Lorem Ipsum, 10');
$('#codicefiscale').val('00000000000');
$('#telefono').val('+39 000 00000000');
$('#email').val('lorem@ipsum.it');
$('#url').val('http://www.loremipsum.it');
fCheckObbligatori();
});
$(document).bind('keydown', 'Ctrl+k', function()
{
$('#frmQuote input[type!=submit]').val('');
$('#frmQuote textarea').html('');
$('#frmQuote input[type=checkbox]').attr('checked',false);
fCheckObbligatori();
});
});
function fCheckObbligatori( pintSubmit )
{
if ( pintSubmit > 0 ) { $('#oPreload').show(); $('#submitBut').hide(); $('#submitLoad').show(); }
var blnReturn = true;
var strReturn = '';
$('#errorLog').html('');
//--- nominativo
if( ! $('#nominativo').val() )
{
blnReturn = false;
$('.lblNominativo').addClass('errore');
$('#errorLog').html('Enter the Name field');
//$('#nominativo').focus();
}
else $('.lblNominativo').removeClass('errore');
//--- indirizzo
if( blnReturn && ! $('#indirizzo').val() )
{
blnReturn = false;
$('.lblIndirizzo').addClass('errore');
$('#errorLog').html('Enter the Address field');
//$('#indirizzo').focus();
}
else $('.lblIndirizzo').removeClass('errore');
//--- codicefiscale
if( blnReturn && ! $('#codicefiscale').val() )
{
blnReturn = false;
$('.lblCodiceFiscale').addClass('errore');
$('#errorLog').html('Enter the Tax code field');
//$('#codicefiscale').focus();
}
else $('.lblCodiceFiscale').removeClass('errore');
//--- email
if ( blnReturn && ! $('#email').val() )
{
blnReturn = false;
$('.lblEmail').addClass('errore');
$('#errorLog').html('Enter the Email field');
//$('#email').focus();
}
else $('.lblEmail').removeClass('errore');
//--- descrizione
if ( blnReturn && ! $('#descrizione').val() )
{
blnReturn = false;
$('.lblDescrizione').addClass('errore');
$('#errorLog').html('Enter the Description field');
//$('#descrizione').focus();
}
else $('.lblDescrizione').removeClass('errore');
//--- privacy
if ( blnReturn && ( $('#privacy').attr('checked') != null && ! $('#privacy').attr('checked') ) )
{
blnReturn = false;
$('#errorLog').html('Mandatory acceptance.');
}
if ( blnReturn && $('#email').val() )
{
//$('#lblEmail').removeClass('errore').addClass('conferma').html('
');
//--- Ajax : inizio
$.ajax({
url: 'include/ajax/checkEmail.php'
, data: 'command=checkEmail&pstrEmail=' + $('#email').val()
, success: function(data)
{
// Ritorno : Inizio
update = data.split('|');
if( update[0] == 'checkEmail' )
{
if( update[1] == 1 )
$('.lblEmail').removeClass('errore');
else
{
blnReturn = false;
$('.lblEmail').addClass('errore');
$('#errorLog').html("The email address is incorrect");
}
if ( pintSubmit > 0 )
if ( ! blnReturn ) { $('#oPreload').fadeOut(); $('#submitLoad').hide(); $('#submitBut').show(); $("html,body").animate({scrollTop: 0}, 1500, "bounceout"); }
else
{
//$('#frmQuote').submit();
//--- Ajax : inizio
$.ajax({
type: "POST"
, url: 'include/ajax/sendPreventivo.php'
, data: 'command=sendPreventivo'
+'&pstrNominativo=' + $('#nominativo').val()
+'&pstrIndirizzo=' + $('#indirizzo').val()
+'&pstrCodiceFiscale=' + $('#codicefiscale').val()
+'&pstrTelefono=' + $('#telefono').val()
+'&pstrEmail=' + $('#email').val()
+'&pstrDescrizione=' + $('#descrizione').val()
+'&pstrSitoWeb=' + ( $('#sitowebsi').attr('checked') ? 'Si' : 'No' )
+'&pstrUrl=' + $('#url').val()
+'&pstrNote=' + $('#note').val()
+'&pstrCopy=' + ( $('#copy').attr('checked') ? 'send' : '' )
+'&pstrPrivacy=' + ( $('#privacy').attr('checked') ? 'accept' : '' )
, success: function(data)
{
// Ritorno : Inizio
update = data.split('|');
if( update[0] == 'sendPreventivo' )
{
if( update[1] == 1 )
location.href = 'quote_thanks.php?copy='+( $('#copy').attr('checked') ? 'send' : '' );
else location.href = 'quote.php';
}
// Ritorno : Fine
}
});
//--- Ajax : fine
}
}
// Ritorno : Fine
}
});
//--- Ajax : inizio
}
else
{
blnReturn = false;
if( pintSubmit > 0 ) { $('#oPreload').fadeOut(); $('#submitLoad').hide(); $('#submitBut').show(); $("html,body").animate({scrollTop: 0}, 1500, "bounceout"); }
}
return false;
}
function fEvidenziaPrivacy()
{
$('#box_privacy').hide().fadeIn();
if( ! $('#privacy').attr('checked') )
{
blnReturn = false;
$('#lblPrivacy').html('Mandatory acceptance.');
}
else $('#lblPrivacy').html('');
}