function initMenu() {
$('#menu ul').hide();
/* $('#menu li a').removeAttr('href');
$('#menu li a').dblclick(
function() {
$(this).next().slideToggle();
}
);*/
}
post_reakce = function(id) {
$('#fp_parent').val(id);
if(id!=0) { $('#fp_subjekt').val("re: "+$('#li-'+id).html()); } else { $('#fp_subjekt').val(""); }
$('#diskuze_form').show();
$('#fp_jmeno').focus();
}
send_post = function(kod) {
var jmeno = $('#fp_jmeno').val();
var email = $('#fp_email').val();
var subjekt = $('#fp_subjekt').val();
var telo = $('#fp_telo').val();
var kod = $('#fp_kod').val();
var parent = $('#fp_parent').val();
$.ajax({
type: "POST",
url: "/scripts/ajax/ajax.zboziKoment.php",
cache: false,
data: "f_jmeno="+jmeno+"&f_email="+email+"&f_subjekt="+subjekt+"&f_telo="+telo+"&f_kod="+kod+"&f_parent="+parent,
dataType: "text",
beforeSend: function(){
// alert("Loading");
},
success: function(return_data){
var json_data = JSON.parse(return_data);
if (json_data.status==1) {
$('#fp_jmeno').val("");
$('#fp_email').val("");
$('#fp_subjekt').val("");
$('#fp_telo').val("");
$('#fp_parent').val("0");
$('#commentinfo').html("
Váš příspěvek byl vložen začne se zobrazovat po schválení administrátorem.
");
$('#diskuze_form').hide();
} else {
$('#commentinfo').html("Při vkládání příspěvku se vyskytla nečekaná chyba.
");
}
}
});
}
$('.diskuze_close').click(function(){ $('#diskuze_form').hide();});
$(document).ready(function(){
initMenu();
$(".megamenuHorizontal").dcMegaMenu({
rowItems: '3',
speed: 'fast',
effect: 'fade'
});
$('.nivo_hp').nivoSlider({
animSpeed: 1500,
pauseTime: 8000
});
$(window).hashchange( function(){
var hash = window.location.hash;
var pgnumber = hash.replace("#", "");
if (pgnumber=="") pgnumber=37;
pgnumber =parseInt(pgnumber);
if (pgnumber==0) pgnumber=1;
$.post("/scripts/ajax/ajax.nactiZbozi.php?page="+pgnumber,
function(data){
if (data != "") {
$("#items_container_body").html(data);
$.scrollTo($("#shop_nazev_kategorie").position().top, 'fast');
}
});
$('.ajaxpaging').removeClass('paging_sel');
$('#go_to_page_'+pgnumber).addClass('paging_sel');
})
var aktualni_strana=1;
var hash = window.location.hash;
var pgnumber = hash.replace("#", "");
if (pgnumber=="") pgnumber=37;
pgnumber =parseInt(pgnumber);
if (pgnumber==0) pgnumber=1;
$('.ajaxpaging').removeClass('paging_sel');
$('#go_to_page_'+pgnumber).addClass('paging_sel');
$('.ajaxpaging').removeClass('paging_sel');
$('#go_to_page_'+pgnumber ).addClass('paging_sel');
$.post("/scripts/ajax/ajax.nactiZbozi.php?page="+pgnumber,
function(data){
if (data != "") {
$("#items_container_body").html(data);
}
});
$(".zbozi_koupit_detail").fancybox({
'hideOnContentClick': true,
'padding':0,
'margin':0,
'overlayColor':'#000',
beforeShow: function(){
//$(".fancybox-skin").css("backgroundColor","transparent");
}
});
$(".zbozi_koupit").fancybox({
'hideOnContentClick': true,
'padding':0
});
$('._blank').click(function() {
return !window.open(this.href);
});
var srovnaniOpen=0;
var basketOpen=0;
var lbOpen=0;
var basketChangeStatus=1;
var pocet_ke_srovnani =0;
$(".validate").validationEngine();
$("._fancy").fancybox({'titleShow' : true,'transitionIn' : 'elastic','transitionOut' : 'elastic'});
if ($("#hp_car1 ul").children().length>0 ) {
$("#hp_car1").jCarouselLite({
btnNext: ".akce_car_right",
btnPrev: ".akce_car_left",
circular: true,
visible: 4,
auto: 4000,
speed: 500,
scroll: 1
});
}
if ($("#hp_car2 ul").children().length>0 ) {
$("#hp_car2").jCarouselLite({
btnNext: ".akce_car_right",
btnPrev: ".akce_car_left",
circular: true,
visible: 4,
auto: 4000,
speed: 500,
scroll: 1
});
}
if ($("#hp_car3 ul").children().length>0 ) {
$("#hp_car3").jCarouselLite({
btnNext: ".akce_car_right",
btnPrev: ".akce_car_left",
circular: true,
visible: 4,
auto: 4000,
speed: 500,
scroll: 1
});
}
if ($("#hp_car4 ul").children().length>0 ) {
$("#hp_car4").jCarouselLite({
btnNext: ".dop_car_right",
btnPrev: ".dop_car_left",
circular: true,
visible: 5,
auto: 4000,
speed: 500,
scroll: 1
});
}
$(".btn-loginbox").click(function(){
if (lbOpen==0) {
$("#loginbox").animate({marginTop: "+=150px",}, 'slow');
lbOpen=1;
} else {
$("#loginbox").animate({marginTop: "-=150px",}, 'slow');
lbOpen=0;
}
});
$("#biname").mouseover(function(){
$("#kosik_nahled").fadeIn('fast');
if (basketChangeStatus==1) {nacti_ax_basket();basketChangeStatus=0;}
});
$("#biname").mouseout(function(){
$("#kosik_nahled").fadeOut('fast');
});
$('body').click(function(event){
if ( ! $(event.target).closest('#kosik_nahled').length ) {
$("#kosik_nahled").fadeOut('fast');
}
});
$(".ocb").click(function(){
$("#kosik_nahled").fadeOut('fast');
});
$("#jq2").scrollable({circular: false, mousewheel: true});
$("#jq1").scrollable({ circular: false, mousewheel: false });
$("#btn_srovnani").click(function(){
if (srovnaniOpen==0) {
nacti_ax_srovnavac();
$('#srovnavac_cointainer').css({height: 54}).animate({ height: '315' }, 'slow');
$('#btn_srovnani').html('Skrýt');
srovnaniOpen=1;
} else {
if (pocet_ke_srovnani>0) {
$('#srovnavac_cointainer').css({height: 315}).animate({ height: '54' }, 'slow');
$('#btn_srovnani').html('Zobrazit');
} else {
$('#srovnavac_cointainer').css({height: 315}).animate({ height: '0' }, 'slow');
}
srovnaniOpen=0;
}
});
nacti_ax_basket = function() {
$.ajax({
type: "POST",
url: "/scripts/ajax/ajax.getBasket.php",
cache: false,
//data: "kod="+kod+"&pocet="+pocet,
dataType: "text",
beforeSend: function(){
// alert("Loading");
},
success: function(return_data){
var json_data = JSON.parse(return_data);
var rows;
$("#ax_basket > tbody").empty();
$('#ax_basket > tbody').append('Název | Počet ks | Cena/ks |
');
for (rows in json_data) {
if (rows!='system') {
var pocet = json_data[rows]['pocet'];
var cena = format_number('cz',json_data[rows]['cena']);
//var nazev = json_data[rows]['vyrobce']+" "+json_data[rows]['model'];
var nazev = json_data[rows]['nazev'];
$('#ax_basket > tbody').append(''+nazev+' | '+pocet+'ks | '+cena+' |
');
}
}
var celkem_s_dani=json_data['system']['price_with_vat'];
var celkem_bez_dani=json_data['system']['price_no_vat'];
var pocet_polozek=json_data['system']['count_items'];
$('#ax_basket > tbody').append('Celkem | '+pocet_polozek+'ks | '+format_number('cz',celkem_s_dani)+' |
');
}
});
}
srovnavac_remove = function(kod) {
$.ajax({
type: "POST",
url: "/scripts/ajax/ajax.removeSrovnavac.php",
cache: false,
data: "kod="+kod,
dataType: "text",
beforeSend: function(){
// alert("Loading");
},
success: function(return_data){
var json_data = JSON.parse(return_data);
var rows;
$("#sr_"+kod).remove();
if (json_data.status==1) {
$("#srovnavac_pocet").html(json_data.count_items+" ks");
pocet_ke_srovnani=json_data.count_items;
}
}
});
}
nacti_ax_srovnavac = function() {
$.ajax({
type: "POST",
url: "/scripts/ajax/ajax.getSrovnavac.php",
cache: false,
dataType: "text",
beforeSend: function(){
// alert("Loading");
},
success: function(return_data){
var json_data = JSON.parse(return_data);
var rows;
var itmp=1;
$("#srovnavac_items_holder").empty();
for (rows in json_data) {
if (rows!='system') {
var foto = json_data[rows]['foto'];
var cena = format_number('cz',json_data[rows]['cena']);
var kod = json_data[rows]['kod'];
var link = json_data[rows]['link'];
// var nazev = json_data[rows]['vyrobce']+" "+json_data[rows]['model'];
var nazev = json_data[rows]['nazev'];
foto_file = "/rimg/118x118/"+foto;
if (foto=="") foto_file = "/styl/nophoto2.png";
var sclass='srovnavac_items';
if (itmp==pocet_ke_srovnani) {sclass='srovnavac_items_last'; }
$('#srovnavac_items_holder').append(' ');
itmp++;
}
}
}
});
}
add_to_basket = function(kod,typ_ceny, info) {
input_id='#num_'+kod;
cloneImg = $('#himg_'+kod);
cloneImg.flyto('#kosik_holder');
var pocet = $(input_id).val();
if (info=='montaz') { //pridat montaz
// kod_montaze = $('#kod_montaze').val();
kod_montaze = $("input[name='f_bandl']:checked").val();
if (kod_montaze!='0') {
$.ajax({
type: "POST",
url: "/scripts/ajax/ajax.addToBasket.php",
cache: false,
data: "kod="+kod_montaze+"&pocet="+pocet+"&cena="+1+"&info="+kod,
dataType: "text",
beforeSend: function(){
// alert("Loading");
},
success: function(return_data){
var json_data = JSON.parse(return_data);
if (json_data.status==1) {
}
}
});
}
}
$.ajax({
type: "POST",
url: "/scripts/ajax/ajax.addToBasket.php",
cache: false,
data: "kod="+kod+"&pocet="+pocet+"&cena="+typ_ceny+"&info="+info,
dataType: "text",
beforeSend: function(){
// alert("Loading");
},
success: function(return_data){
var json_data = JSON.parse(return_data);
if (json_data.status==1) {
$("#basketinfo_ks").html(json_data.count_items);
$("#basketinfo_cena").html(format_number('cz',json_data.price_no_vat));
$("#kosik_info_ks").html(json_data.count_items);
$("#kosik_info_cena").html(format_number('cz',json_data.price_no_vat));
}
sety = json_data.update_sets;
set_action = sety["grant"];
set_vyrobce= sety["vyrobce"];
if (set_action==1) {
//$('#status-info').html('Na zboží Vám byla přiznána setová cena.
');
//$("#emailno").fancybox().trigger('click');
}
}
});
nacti_ax_basket();
basketChangeStatus=0;
// $('#kosik_holder').addClass('kosik_naplneny');
// $('#kosik_holder').removeClass('kosik');
}
add_to_srovnavac = function(kod) {
cloneImg = $('#himg_'+kod);
cloneImg.flyto('.srovnavac');
$.ajax({
type: "POST",
url: "/scripts/ajax/ajax.addToSrovnavac.php",
cache: false,
data: "kod="+kod,
dataType: "text",
beforeSend: function(){
// alert("Loading");
},
success: function(return_data){
var json_data = JSON.parse(return_data);
if (json_data.status==1) {
$("#srovnavac_pocet").html(json_data.count_items+" ks");
pocet_ke_srovnani=json_data.count_items;
if (srovnaniOpen==0 && pocet_ke_srovnani==1) {$('#srovnavac_cointainer').css({height: 0}).animate({ height: '54' }, 'slow');$('#btn_srovnani').html('Zobrazit');}
}
}
});
nacti_ax_srovnavac();
}
$("#fulltextsrch").autocomplete("/scripts/ajax/ajax.fulltext.php", {
width: 320,
max: 100,
highlight: false,
scroll: true,
scrollHeight: 300,
selectFirst:false,
width: 337,
left: -20,
formatItem: function(data, i, n, value) {
var json_data = JSON.parse(value);
//return json_data[0]['rozmer'] + " "+ json_data[0]['vyrobce']+" "+json_data[0]['model']+"
"+json_data[0]['model']+"";
return ""+json_data[0]['nazev']+"
"+json_data[0]['anotace']+"";
},
formatResult: function(data, value) {
var json_data = JSON.parse(value);
//return json_data[0]['rozmer'] + " "+ json_data[0]['vyrobce']+" "+json_data[0]['model'];
return json_data[0]['nazev'];
}
});
$('#fulltextsrch').focus(function(){if ($('#fulltextsrch').val()=='Hledej...') $('#fulltextsrch').val("");});
$('#fulltextsrch').blur(function(){if ($('#fulltextsrch').val()=='') $('#fulltextsrch').val("Hledej...");});
$('#zp_email').focus(function(){if ($('#zp_email').val()=='Váš@email') $('#zp_email').val("");});
$('#zp_email').blur(function(){if ($('#zp_email').val()=='') $('#zp_email').val("Váš@email");});
});
function number_format (number, decimals, dec_point, thousands_sep) {
decimals=2;
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
s = '',
toFixedFix = function (n, prec) {
var k = Math.pow(10, prec); return '' + Math.round(n * k) / k;
};
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0'); }
return s.join(dec);
}
function format_number(country,number) {
return number_format (number, 2,',', ' ')+' Kč';
}
set_sort = function (type) {
$('#f_sort_type').val(type);
$('#f_sort_set').submit();
}
posun_strankovani = function (pocet_stran,aktualni_strana,posun) {
$('html, body').animate({scrollTop:$("#shop_nazev_kategorie").position().top}, 'fast');
$('.paging').addClass('nodisp');
for(i=1; i <= pocet_stran; i++) {
if((i-posun< aktualni_strana) && (i+posun>aktualni_strana)) {$('#go_to_page_'+i).removeClass('nodisp'); }
if((aktualni_strana-posun<1) && (i<=(posun*2)-1)) {$('#go_to_page_'+i).removeClass('nodisp'); }
if((i+(posun*2-1)>pocet_stran) && (aktualni_strana*1+posun*1)>pocet_stran) {$('#go_to_page_'+i).removeClass('nodisp'); }
if (aktualni_strana>posun && pocet_stran>(posun*2-1)) {$('#paging_first').removeClass('nodisp');$('#paging_first_txt').removeClass('nodisp'); } else {$('#paging_first').addClass('nodisp');$('#paging_first_txt').addClass('nodisp'); }
if (aktualni_strana<=pocet_stran-posun) {$('#paging_last').removeClass('nodisp'); $('#paging_last_txt').removeClass('nodisp'); } else {$('#paging_last').addClass('nodisp'); $('#paging_last_txt').addClass('nodisp'); }
}
return false;
}
$.fn.flyto = function(obj,callback) {
var $cloneImg = $(this).clone();
basketOffset = $(obj).offset();
var basketY = basketOffset.top,
basketX = basketOffset.left,
imgY = $(this).offset().top,
imgX = $(this).offset().left;
var gotoX = basketX - imgX;
gotoY = basketY - imgY,
newImageWidth = $(this).width() / 3,
newImageHeight = $(this).height() / 3;
$cloneImg.addClass('fly_elem')
.prependTo($(this).parent())
.animate({opacity: 0.4}, 100 )
.animate({opacity: 0.1, marginLeft: gotoX, marginTop: gotoY, width: newImageWidth, height: newImageHeight}, 800, function() {
$(this).remove();
});
if(callback)
setTimeout(callback, 800);
return $(this);
};