// JavaScript Document

/* slider-config */
var slider01_config = {
		speed: 1000,
		interval: 5000,
		next_speed: 200,
		prev_speed: 200,
		image_speed: 100};


$(document).ready(function(){

	
	$(".popup_insert").bind('submit',function(){  
		$('#insert_info').parent().remove();
		var element = $(this);
		//alert(element.find('h2').text());
		var insert_post = $(this).serialize();
		insert_post += '&system_cart_insert=';	
		$.post('/kosik/detail-ajax.htm',insert_post, function(data) {	
			if(data.error_list){alert(data.error_list.cart_insert);}
			else
			{
			var obsah = '<div class="cpt">'+ javascript_product_insert_title +'</div><div id="product-add-info-wrap"><div id="product-add-info"><em>'+ javascript_product_insert_note +'</em></div><div id="product-add">';
			obsah += '<div class="product_image">' + element.find('.box-img').html() + '</div>';
			obsah += '<div class="product_cpt">' + element.find('h2').text() + '</div>';
			obsah += '<div class="product_price">'+ element.find("input[name='quantity']").val() +' x '+ element.find(".system_prize_final").text() + ' Kč s DPH</div></div></div>';
			obsah += '<div class="product_back"><a href="" title="" class="product_back_shopping click_close">'+ javascript_product_insert_back +'</a><a href="/kosik/detail.htm" title="" class="product_summary_popup">V košíku ' + data.price_list.total_quantity + ' Ks za ' + data.price_list.cart_sum + ' Kč</a><a href="/kosik/detail.htm" title="" class="product_forward">'+ javascript_product_insert_order +'</a><div class="clear"></div></div>';
            
			fnpopup('<div id="insert_info"><div id="cart-table"><div class="cart-table-close"><a title="" href="#"><img alt="" src="/templates/css/img/cart-table-close.gif"></a></div><div id="system_cart_table">' + obsah + '</div></div></div>')
			fnpopup_show('#insert_info');				 
			
			$(".system_total_quantity").text(data.price_list.total_quantity); 
			$(".system_cart_sum").text(data.price_list.cart_sum);
			}
		},"json");
		return false;
	});		

	/* seq-box hover */
	$(".seq-box").hover(
	  function () {
	    $(this).addClass("seq-box-hover");
	  }, 
	  function () {
	    $(this).removeClass("seq-box-hover");
	  }
	);
	
	/* buble */
	$(".box-prize p .box-buble").hover(
	  function () {
	    $(this).find("em").show();
	  },
	  function () {
	    $(this).find("em").hide();
	  }
	);
	
	/* box hover */
	$(".box").hover(
	  function () {
	    $(this).addClass("box-hover");
	  }, 
	  function () {
	    $(this).removeClass("box-hover");
	  }
	);
	
	/* index - left - slide show */
	var counter = 0;
	var pict_count = 0;
	var pict_count_final = 0;
	
	function hideAll(){
		$('.banner-index ul li').each(function() {
		$(this).hide();
		pict_count = pict_count + 1;
	});}
	hideAll();
	
	$(".banner-index ul li:eq(" + counter + ")").show();
	pict_count_final = pict_count -2;
	
	$('.edge').click(function() {
		if (counter > pict_count_final)
			{
				hideAll();
				counter = 0;
				$(".banner-index ul li:eq(" + counter + ")").fadeIn(1000);
				return false;
			}
		else
			{
				hideAll();
				counter = counter + 1;
				$(".banner-index ul li:eq(" + counter + ")").fadeIn(1000);
				return false;
			}
	});
	
	
	/*Togglovani billing adresy****************************************************/	
	$(".toggle_billing_address").live('change click',function () {//togglování billing adresy 
		if ($(".toggle_billing_address").is(":checked")) 
			{$("#system_billing_address").show();}
   		else
   			{$("#system_billing_address").hide();}
	});
	$(".toggle_billing_address").trigger('change');
	

});
