$(document).ready(function() { //read-more section var $el, $ps, $up, totalHeight; $(".text-content .button").click(function() { totalHeight = 0 $el = $(this); $p = $el.parent(); $up = $p.parent(); $ps = $up.find("p:not('.read-more')"); // measure how tall inside should be by adding together heights of all inside paragraphs (except read-more paragraph) $ps.each(function() { totalHeight += $(this).outerHeight(); }); $up .css({ // Set height to prevent instant jumpdown when max height is removed "height": $up.height(), "max-height": 9999 }) .animate({ "height": totalHeight }); // fade out read-more $p.fadeOut(); // prevent jump-down return false; }); //end read-more section $.jGrowl.defaults.position = 'center'; $('.overflow_scroll').hover( function () { $(this).stop().animate({ textIndent: "-" + ( $(this).width() - $(this).parent().width() ) + "px" }, 1000); }, function () { $(this).stop().animate({ textIndent: "0" }, 1000); } ); //flip start var margin =$(".flipcard_item .front").width()/2; var width=$(".flipcard_item .front").width(); var height=$(".flipcard_item .front").height(); var flipspeed = 300; $(".flipcard_item .back").stop().css({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'}); function flip_front(el) { $(el).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:flipspeed}); window.setTimeout(function() { $(".flipcard_item .back").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:flipspeed}); },flipspeed); } function flip_back(el) { $(el).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:flipspeed}); window.setTimeout(function() { $(".flipcard_item .front").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:flipspeed}); },flipspeed); } $(".flipcard_item .front").hoverIntent( function () { flip_front(this); }, function () { } ); $(".flipcard_item .back").hoverIntent( function () { }, function () { flip_back(this); } ); $('.expand_midnav').click(function() { // $('.collapsible').slideUp(); var tmp = $(this).attr('id').split('_'); tmp = 'menu_cat_' + tmp[2]; $('#' + tmp).slideToggle(); return false; }); $('.swatch_popup').each(function() { init_swatch(this); }); $('.swatch_popup').live('click', function(e) { e.preventDefault(); init_swatch(this); }); $('.popup').click(function(e) { e.preventDefault(); var new_href = $(this).attr('href').replace('?','?in_popup=1&'); $(this).attr('href', new_href); $.colorbox({ href:$(this).attr('href'), scrolling: true, opacity: 0.7, width: 640, height: 480, preloading: true }); }); $('#product_shade').change(function() { if ($(this).val() == '') { return false; } $('ul.product_tabs li a:first').trigger('click'); var the_product_id = $(this).val(); $('#add_product_id').val(the_product_id); $('#swatch_desc span').html( $('#swatch_text_' + $(this).val()).html()); var img_href = $('#swatch_' + $(this).val()).attr('href'); $('#product_image_main img').attr('src', img_href); center_product_image(); $.post('/ajax',{ act: 'get_product_details', product_id: the_product_id},function(data) { update_cart_button(data); }); return false; }); $('.swatch_2').click(function(e) { var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; $('#add_product_id').val(the_product_id); $('#product_shade').val(the_product_id); $.post('/ajax',{ act: 'get_product_details', product_id: the_product_id},function(data) { update_cart_button(data); }); $(this).children('.swatch_name').show(); return false; }); $('.swatch_3').click(function(e) { var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; $.post('/ajax',{ act: 'get_product_details', product_id: the_product_id},function(data) { update_cart_button(data); }); return false; }); //real action is in the 'live' event handler, but this must be here to the tooltip to work $('.swatch_popup').click(function(e) { return false; }); $('.swatch_popup').hover(function() { return false; }); $('.btn_addtocart').live('click', function(event) { event.preventDefault(); if ($('#product_shade').length && $('#product_shade').val() == '') { alert('Wybierz kolor'); return false; } $('.floatingcart').html('

Please wait...

'); var form_addtocart = $(this).closest('form'); $.post($(form_addtocart).attr('action'), $(form_addtocart).serialize(), function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.btn_addtocart_list').live('click', function(event) { event.preventDefault(); $('.floatingcart').html('

Please wait...

'); var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; var the_colitem_id = 0; if (tmp[3] != undefined) { the_colitem_id= tmp[3]; } $.post('/shop', { add_product_id: the_product_id, act: 'add_to_cart', floatingcart: 1, colitem_id: the_colitem_id}, function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.btn_addtocart_custom').live('click', function(event) { event.preventDefault(); $('.floatingcart').html('

Please wait...

'); var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; var tmp_2 = 'list_' + the_product_id; $.post('/shop', { add_product_id: the_product_id, act: 'add_to_cart_custom', products_list: $('#'+tmp_2).val(), floatingcart: 1}, function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.btn_addtocart_mult').live('click', function(event) { event.preventDefault(); var tmp = $(this).attr('name').split('_'); $('.floatingcart').html('

Please wait...

'); /* *

*/ $.post($('#form_addtocart').attr('action'), {add_product_id: tmp[2], act: 'add_to_cart', floatingcart: 1}, function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.show_basket_link').click(function() { if ($('.floatingcart').is(":visible") == true) { $('.floatingcart').slideUp(); } else { $('.floatingcart').slideDown(); } return false; }); $('.hide_basket_link').click(function() { $('.floatingcart').slideUp(); return false; }); var tabcontent_max_height = $('.product_tab_content :first').css('height'); var tabcontent_max_width = $('.product_tab_content :first').css('width'); $('ul.product_tabs li a').click(function(e) { e.preventDefault(); $('ul.product_tabs li').removeClass('active'); $(this).parent('li').addClass('active'); $('.product_tab_content').hide(); var target = $(this).attr('href').replace('#',''); $('#' + target).css('height',tabcontent_max_height); $('#' + target).css('width',tabcontent_max_width); $('#' + target).show(); }); $('.view_full').live('click', function(e) { e.preventDefault(); $('.view_full_container').html('Main image'); }); $('.view_full_video').live('click', function(e) { e.preventDefault(); var youtube_iframe = '