@section('javascript_sweepstake')
var addDiv = $('#adddataestrazione');
var i = $('#adddataestrazione p').size() + 1;
$("input[name='concorsoconestrazione']").click(function()
{
if ($(this).prop('checked'))
{
$("#hasDrawing").show("fast");
$("#drawing-msg").html("");
}
else
{
$("#hasDrawing").hide("fast");
$("#drawing-msg").html("
× Attenzione Se si sono specificate delle date di estrazione, occorre cancellarle una ad una. Non è sufficiente deselezionare questa casella . Premere il pulsante sottostante per cancellare tutte le estrazioni eventualmente inserite
Cancella le estrazioni
" );
}
})
$(document).on('click', '#delete-drawing', function()
{
var field = $("#adddataestrazione");
var obj = field.children('p');
var found = false;
if (obj && obj.length)
{
obj.remove();
found = true;
}
if (found)
alert("Tutte le estrazioni sono state cancellate.");
});
$(document).on('click', '#remNew', function() {
if( i > 1 ) {
$(this).parents('p').remove();
i--;
}
return false;
});
$(document).on('click', '#addNew', function() {
$(' + x
').appendTo(addDiv);
i++;
return false;
});
$(document).on('focus', '.dataestrazione', function(event)
{
var idname = $(this).attr('id');
var num = idname.substr(6,9);
event.preventDefault();
var inizioconcorso = $("#startdate").val();
var fineconcorso = $("#enddate").val();
var anno = inizioconcorso.substr(6,4);
var mese = parseInt(inizioconcorso.substr(3,2))-1; /* month: from 0 to 11! */
var day = inizioconcorso.substr(0,2);
var fineanno = fineconcorso.substr(6,4);
var finemese = parseInt(fineconcorso.substr(3,2))-1; /* month: from 0 to 11! */
var fineday = fineconcorso.substr(0,2);
$(this).datepicker('destroy'); /* destroying the previous object */
$(this).datepicker({firstDay: 1, dateFormat: 'dd-mm-yy', monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'], minDate: new Date(anno,mese,day), maxDate: new Date(fineanno,finemese,fineday),
onSelect: function() {
var sel = "#p_a_"+num;
var dalladata = $(this).next();
var alladata = $(this).next().next();
$(this).next().datepicker('destroy');
$(this).next().next().datepicker('destroy');
$(this).next().datepicker({firstDay: 1, monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'], dateFormat: 'dd-mm-yy'});
var maxDate = $(this).datepicker('getDate');
alladata.datepicker({firstDay: 1, dateFormat: 'dd-mm-yy'});
alladata.datepicker('setDate', maxDate);
alladata.datepicker('option', 'maxDate', maxDate);
alladata.datepicker('option', 'minDate', new Date(anno,mese,day));
alladata.datepicker('refresh');
dalladata.datepicker('setDate', maxDate);
dalladata.datepicker('option', 'maxDate', maxDate);
dalladata.datepicker('option', 'minDate', new Date(anno,mese,day));
dalladata.datepicker('refresh')}});
});
$(document).on('mouseover', '.dataestrazione', function(event)
{
$(this).tooltip('show');
});
$(document).on('mouseover', '.datainizioestrazione', function(event)
{
$(this).tooltip('show');
});
$(document).on('mouseover', '.datafineestrazione', function(event)
{
$(this).tooltip('show');
var minDate = $(this).prev().datepicker('getDate');
$(this).datepicker('option','minDate', minDate);
$(this).datepicker('refresh');
});
$('#enddate').datepicker({firstDay: 1, monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'], dateFormat: 'dd-mm-yy', minDate: new Date({{substr($startdate,0,4)}},{{substr($startdate,5,2)}}-1,{{substr($startdate,8,2)}})});
@stop