//Block open in iframe (need refactor because of prerender content in admin)
//if (top.location!= self.location) {
// top.location = self.location.href
//}
$(document).ready(function() {
//Init header position: fixed fix
$("header.affix").next().css("padding-top",$("header.affix").height());
//Init lightbox
$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
event.preventDefault();
$(this).ekkoLightbox();
});
//Init smooth scroll
if(jQuery().niceScroll) {
$("html").niceScroll({
mousescrollstep: 20,
scrollspeed: 30
});
}
$('a[href*=#]').on('click', function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
});
//Init gallery item height fix
$('.sys-gallery-image .sys-item').each(function() {
var height = ($(this).width()/155)*100;
$(this).find(".sys-image").height(height);
$(this).find(".sys-image img").height(height);
$(this).find(".sys-hover").height(height);
$(this).find(".fa-stack").each(function() {
$(this).css('margin-top',(height/2)-($(this).height()/2));
});
$(this).find(".sys-iris").height(height);
});
//Init image link item height fix
$('.sys-imagelink .sys-item').each(function() {
var height = ($(this).width()/155)*100;
$(this).find(".sys-image").height(height);
$(this).find(".sys-image img").height(height);
$(this).find(".sys-hover").height(height);
$(this).find(".sys-iris").height(height);
});
//Init fullwidth
var block = $('.sys-fullwidth');
var width = $(window).width();
block.width(width);
block.css('margin-left',-(($(window).width()-block.parent().width())/2));
$( window ).resize(function() {
var block = $('.sys-fullwidth');
var width = $(window).width();
block.width(width);
block.css('margin-left',-(($(window).width()-block.parent().width())/2));
});
//Init slider
for (i = 0; i < window.Sliders.length; i++) {
var id = window.Sliders[i].id;
var config = window.Sliders[i].config;
$('#sys-slider-'+id).show().revolution(config);
}
$('.tp-leftarrow').html('');
$('.tp-rightarrow').html('');
$('.tp-bullets .bullet').html('');
});
/**
$(document).ready(function() {
setInterval(function(){
var serviceMaxHeight = 0;
var serviceH2MaxHeight = 0;
$('.SC_services .SC_services_box').each(function() {
if($(this).height() > serviceMaxHeight){
serviceMaxHeight = $(this).height();
}
//alert($(this).height());
});
$('.SC_services .SC_services_box').css("height", serviceMaxHeight);
var serviceH2MaxHeight = 0;
$('.SC_services h2').each(function() {
if($(this).height() > serviceH2MaxHeight){
serviceH2MaxHeight = $(this).height();
}
//alert($(this).height());
});
$('.SC_services h2').css("height", serviceH2MaxHeight);
resizeGalleryImg('.SC_gallery_col img');
resizeImage('.SYS_resize');
},500);
resizeGalleryImg('.SC_gallery_col img');
resizeImage('.SYS_resize');
$(".fancybox").fancybox();
});
function resizeGalleryImg(selector){
$(selector).each(function() {
var maxWidth = $(this).parent().parent().width();
var maxHeight = $(this).parent().parent().height();
var ratio = 0;
if($(this).width() == 0){
$(this).load(function () {
var width = $(this).width();
var height = $(this).height();
if(width > maxWidth){
ratio = maxWidth / width;
$(this).css("width", maxWidth);
$(this).css("height", height * ratio);
height = height * ratio;
}
var width = $(this).width();
var height = $(this).height();
if(height > maxHeight){
ratio = maxHeight / height;
$(this).css("height", maxHeight);
$(this).css("width", width * ratio);
width = width * ratio;
}
$(this).css('margin-top', (maxHeight - $(this).height()) / 2 + "px");
$(this).css('margin-left', (maxWidth - $(this).width()) / 2 + "px");
});
} else {
var width = $(this).width();
var height = $(this).height();
if(width > maxWidth){
ratio = maxWidth / width;
$(this).css("width", maxWidth);
$(this).css("height", height * ratio);
height = height * ratio;
}
var width = $(this).width();
var height = $(this).height();
if(height > maxHeight){
ratio = maxHeight / height;
$(this).css("height", maxHeight);
$(this).css("width", width * ratio);
width = width * ratio;
}
$(this).css('margin-top', (maxHeight - $(this).height()) / 2 + "px");
$(this).css('margin-left', (maxWidth - $(this).width()) / 2 + "px");
}
});
}
function resizeImage(selector){
$(selector).each(function() {
var maxWidth = $(this).parent().parent().width();
var maxHeight = $(this).parent().parent().height();
var ratio = 0;
if($(this).width() == 0){
$(this).load(function () {
var width = $(this).width();
var height = $(this).height();
if(width > maxWidth){
ratio = maxWidth / width;
$(this).css("width", maxWidth);
$(this).css("height", height * ratio);
height = height * ratio;
}
var width = $(this).width();
var height = $(this).height();
if(height > maxHeight){
ratio = maxHeight / height;
$(this).css("height", maxHeight);
$(this).css("width", width * ratio);
width = width * ratio;
}
$(this).css('margin-top', (maxHeight - $(this).height()) / 2 + "px");
$(this).css('margin-left', (maxWidth - $(this).width()) / 2 + "px");
});
} else {
var width = $(this).width();
var height = $(this).height();
if(width > maxWidth){
ratio = maxWidth / width;
$(this).css("width", maxWidth);
$(this).css("height", height * ratio);
height = height * ratio;
}
var width = $(this).width();
var height = $(this).height();
if(height > maxHeight){
ratio = maxHeight / height;
$(this).css("height", maxHeight);
$(this).css("width", width * ratio);
width = width * ratio;
}
$(this).css('margin-top', (maxHeight - $(this).height()) / 2 + "px");
$(this).css('margin-left', (maxWidth - $(this).width()) / 2 + "px");
}
});
}
var PercentRemains = 100;
function UpdateCart(item_total_price, item_total_price_tax, radku){
$('#items_sumary_price_tax').html(item_total_price_tax.toFixed(2));
$('#items_sumary_price').html(item_total_price.toFixed(2));
UpdateFinalPrice(item_total_price_tax,item_total_price, 100);
}
function SwitchCustomer(element){
if (element.is(':checked')) {
$('#new_customer_info').slideUp(function(){
$('#registered_customer_info').slideDown();
});
} else {
$('#registered_customer_info').slideUp(function(){
$('#new_customer_info').slideDown();
});
}
}
function SwitchAddress(element){
if (element.is(':checked')) {
$('#faktAddr').hide();
$('#name').removeAttr('required');
$('#surname').removeAttr('required');
$('#address').removeAttr('required');
$('#city').removeAttr('required');
$('#zip').removeAttr('required');
$('#tel').removeAttr('required');
$('#email').removeAttr('required');
} else {
$('#faktAddr').show();
$('#name').attr('required', 'required');
$('#surname').attr('required', 'required');
$('#address').attr('required', 'required');
$('#city').attr('required', 'required');
$('#zip').attr('required', 'required');
$('#tel').attr('required', 'required');
$('#email').attr('required', 'required');
}
}
function UpdateFinalPrice(item_total_price_tax,item_total_price, percent_remains){
item_total_price_tax = Number(item_total_price_tax.replace(/\s+/g, ''));
item_total_price = Number(item_total_price.replace(/\s+/g, ''));
// pokud je parametr zbyvajicich procent prazdny nebo nedefinovany.. pouzije se globalni promenna nastavovana ve funkci UpdateCart
if(percent_remains === undefined || percent_remains == null || percent_remains == ''){
percent_remains = PercentRemains;
}
// UPDATE TRANSPORT FREE
$("input[name='transport']").each(function(){
if(percent_remains <= 0){
$(this).attr("data-price", 0);
$(this).closest('tr').find(".price .value strong").html("zdarma");
}else{
$(this).attr("data-price", $(this).attr("data-original-price"));
if($(this).attr("data-original-price") == 0){
var price = "zdarma";
}else{
var price = $(this).attr("data-original-price") + ' Kč';
}
$(this).closest('tr').find(".price .value strong").html(price);
}
});
if ($('input[name=payment]').length) {
if($("input[name='payment']:checked").attr("data-price") != undefined){
item_total_price_tax += Number($("input[name='payment']:checked").attr("data-price"))
item_total_price += Number($("input[name='payment']:checked").attr("data-price"))
}
if($("input[name='transport']:checked").attr("data-price") != undefined){
item_total_price_tax += Number($("input[name='transport']:checked").attr("data-price"))
item_total_price += Number($("input[name='transport']:checked").attr("data-price"))
}
}
$('#items_final_price_tax').html(item_total_price_tax.toFixed(2));
$('#items_final_price').html(item_total_price.toFixed(2));
}
function UpdateCount(id,count,radku){
var item_total_price_tax = 0;
var item_total_price = 0;
for(i = 0; i < Number(radku); i++){
item_price_tax = Number($('#count-'+ i).val().replace(/\s+/g, '')) * Number($('#item_price_tax-'+ i).html().replace(/\s+/g, ''));
item_price = Number($('#count-'+ i).val().replace(/\s+/g, '')) * Number($('#item_price-'+ i).html().replace(/\s+/g, ''));
$('#item_total_price_tax-'+ i).html(item_price_tax.toFixed(2));
$('#item_total_price-'+ i).html(item_price.toFixed(2));
if(item_price_tax){
item_total_price_tax += item_price_tax;
item_total_price += item_price;
}
}
$.getJSON('UpdateCount/'+id+'/'+count+'/', function(json){
if(json.code == 103){
$('#count-' + id).val(json.inStock);
$('#count-'+ id).closest('tr').children('.item_info').children('img').removeClass('hidden');
return false;
}else{
$('#count-'+ id).closest('tr').children('.item_info').children('img').addClass('hidden');
UpdateCart(item_total_price, item_total_price_tax, radku);
return true;
}
});
}**/