function fprezzo(str, dec_point) {
l = 'it';
if (typeof dec_point != 'undefined' && dec_point == ',') {
l = 'en';
}
return (Number(str) / 100).toLocaleString(l, { minimumFractionDigits: 2 });
}
/** PLACEHOLDER SUPPORT */
// This adds 'placeholder' to the items listed in the jQuery .support object.
$(function () {
jQuery.support.placeholder = false;
if ('placeholder' in document.createElement('input')) jQuery.support.placeholder = true;
});
// This adds placeholder support to browsers that wouldn't otherwise support it.
$(function () {
if (!jQuery.support.placeholder) {
var active = document.activeElement;
$(':text').focus(function () {
if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function () {
if (!(!$(this).attr('placeholder')) && $(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
}).change(function () {
if ($(this).attr('placeholder') != '' && $(this).val() != $(this).attr('placeholder')) {
$(this).removeClass('hasPlaceholder');
}
});
$(':text').blur();
$(active).focus();
$('form').submit(function (e) {
$(':text.hasPlaceholder').each(function () { $(this).val(''); });
});
}
});
/** LINGUE **/
function changeLang(lang_action, trad_urls, lang_code) {
$('#Lang').attr('action', lang_action);
if (trad_urls && $('#Lang input[name="Language"]').length == 1)
$('#Lang input[name="Language"]').val(lang_code);
$('#Lang').submit();
}
function changeLanguage(lingua) {
document.Lang.Language.value = lingua;
document.Lang.submit();
}
function changeCountryLang(lang_action, trad_urls, lang_code, ctry_code) {
$('#Lang').attr('action', lang_action);
if (trad_urls && $('#Lang input[name="Language"]').length == 1) {
$('#Lang input[name="Language"]').val(lang_code);
} else {
$('#Lang').append("");
}
if ($('#Lang input[name="Country"]').length == 1) {
$('#Lang input[name="Country"]').val(ctry_code);
} else {
$('#Lang').append("");
}
$('#Lang').submit();
}
/** SIDEBAR **/
function setSideBarPosition() {
if (vivaversion == 2) return;
if ($(window).width() < (72 * 2 + 1030)) {
$('.sticky').addClass('sticky-inline');
$('.sticky ul').removeClass('list-unstyled').addClass('list-inline');
}
else {
$('.sticky').removeClass('sticky-inline');
$('.sticky ul').addClass('list-unstyled').removeClass('list-inline');
}
}
/** COOKIE DISCLAIMER **/
function getCookie(cn) {
var n = cn + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1);
if (c.indexOf(n) == 0) return c.substring(n.length, c.length);
}
return false;
}
function setcookie(cn, date) {
var o = '';
var d = new Date();
date = typeof date !== 'undefined' ? date : false;
if (date) {
if (cn.days && cn.days > 0)
d.setTime(d.getTime() + (cn.days * 24 * 60 * 60 * 1000));
else
if (cn.hours && cn.hours > 0)
d.setTime(d.getTime() + (cn.hours * 60 * 60 * 1000));
else // caso default 1 giorno
d.setTime(d.getTime() + (24 * 60 * 60 * 1000));
o += "; expires=" + d.toUTCString();
}
o += "; path=" + cn.path;
document.cookie = escape(cn.name) + "=" + escape(d.getTime()) + o;
}
/** COUNTDOWN CARRELLO **/
function updateCountDown() {
if ($('#countdownHeader').length) {
// se esiste il div che contiene il contatore
var te = $('#countdownHeader').data('timeend') * 1000;
var ts = $('#countdownHeader').data('timestart') * 1000;
if (te == 0)
// se il timeout e' giunto dalla sessione nascondo il contatore (caso svuotamento)
$('#countdownHeader').hide();
else {
// mostro il countdown dell'header
$('#countdownHeader').show();
if ($(".countdown, #countdown").length)
// se non sono nel vedi carrello non ho questo secondo countdown
$('.countdown, #countdown').countdown({
timeend: te,
timestart: ts,
timeDivision: ['M', 'S'],
msgGood: '.countdownOK, #countdownOK',
msgBad: '.countdownKO, #countdownKO'
});
$('#countdownHeader').countdown({
timeend: te,
timestart: ts,
timeDivision: ['M', 'S'],
callBack: function () {
if ($('#cart_modal').length) {
toggleModal('#cart_modal');
$('#cart_modal').on('hidden.bs.modal', function (e) {
window.location.href = '/index.php?nvpg[sell]&cmd=visualizzaCarrello';
})
}
}
});
}
}
}
function updateBasketCountDown(timestart, timeend) {
if ($(".countdown").length) {
if ($('.header-cart .timer').length) {
$('.countdown').addClass('countdownHolder').html($('.header-cart .timer').html());
$('.countdownSummary').html($('.header-cart .timer').html());
}
setTimeout(updateBasketCountDown, 1000);
}
}
//VERIFICA CARRELLO
function checkRegolamentoBasket($alert) {
if ($('#checkRegolamento').length && !$('#checkRegolamento').prop('checked')) {
if ($alert) Alert.show(frasi.carrello['checkRegolamento']);
$('#checkRegolamentoMsg').html(frasi.carrello['required']);
$('#checkRegolamentoMsg').show();
return false;
}
return true;
}
/** CONTRASTO **/
function getContrast(bg) {
//Se e' trasparente cambio
if (bg == 'transparent') bg = 'rgba(0, 0, 0, 0)';
// la stringa e' formata da 3 numeri separati da ", " e da una numero(eventualmente con un decimale) che e' il canale alfa (che non mi serve)
var rgb = bg.match(/^rgb(?:a)?\((\d+),\s*(\d+),\s*(\d+)(,\s*(.+))?\)$/);
// http://www.w3.org/TR/AERT#color-contrast
var o = Math.round(((parseInt(rgb[1]) * 299) +
(parseInt(rgb[2]) * 587) +
(parseInt(rgb[3]) * 114)) / 1000);
return (o > 125) ? 'dark' : 'light';
}
function setOpt(text, value, toSelect) {
return $('