// JavaScript Document
$(document).ready(function(){

	$("#popup_insert").bind('submit',function(){
		var insert_post = $(this).serialize();
		insert_post += '&system_cart_insert=';	
		/*$('#insert_info').parents('.popup-container').remove();*/
		/*fnpopup_show(); */
		$.post('/kosik/detail-ajax.htm',insert_post, function(data) {	
			if(data.error_list){alert(data.error_list.cart_insert);}
			else
			{
			/*$(".cart").append(data.html_data.cart_summary_table.html + '<br />');*/			
			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">' + $(".detail-img").html() + '</div>';
			obsah += '<div class="product_cpt">' + $("h1").text() + '</div>';
			obsah += '<div class="product_price">'+ $("input[name='quantity']").val() +' x <strong>'+ $(".action-prize span").text() + '</strong> s DPH</div></div></div>';
			
			obsah += '<div class="product_summary-popup">V košíku' + data.price_list.total_quantity + 'Ks za ' + data.price_list.cart_sum + 'Kč</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');	
			/*$('.top-cart a').replaceWith($(data).find(".top-cart").html());*/
			}
		},"json");
		return false;
	});	

		
	$(".login").hover(
		function(){$(this).addClass("hovered");},
		function(){$(this).removeClass("hovered");
	});
	
	$(".login em").hover(
		function(){$(this).addClass("hovered-em");},
		function(){$(this).removeClass("hovered-em");
	});
		
	$("body").bind('mouseup',function(){
		if($(".login").hasClass("hovered")){
			if($(".login em").hasClass("hovered-em")){
				$(".login").toggleClass("login-hover");
				}
				else
				{
				$(".login").addClass("login-hover");
				}							
		}
		else
		{$(".login").removeClass("login-hover");}
	});		
	

	 	
 	/*skrývání obsahu*/
	$('.slick-toggle').find("div").hide();
	
	$('.slick-toggle p').toggle(function() {
	  $(this).parent().find("div").show(300);
	  $(this).addClass("slick-hover");
	  $(this).parent().addClass("slick-toggle-hover");
	}, function() {
	  $(this).parent().find("div").hide(300);
	  $(this).removeClass("slick-hover");
	  $(this).parent().removeClass("slick-toggle-hover");
	});
	
	/* slider */
	var counter = 0;

	$(".index-info dl dd:eq(" + counter + ")").show();
	function edge(){
		if(counter <= 0){$('.arrow-left').hide();}else{$('.arrow-left').show();}
		if(counter >= c - 1){$('.arrow-right').hide();}else{$('.arrow-right').show();}
	}
	edge();

	var c = $('.index-info dl dd').length;
	var iiw = c * 990;
	$(".index-info dl").css("width", iiw);

	//minus
	$('.arrow-left').click(function() {
		counter = counter - 1;
		$(".index-info dl").animate({"left": "+=990px"}, "slow");
		edge();
	});

	//plus
	$('.arrow-right').click(function() {
		counter = counter + 1;    
		$(".index-info dl").animate({"left": "-=990px"}, "slow");
		edge();
	});

//form
    $(".verify").attr("value","verified");
   
    /*$(".contact-form1").bind('submit',function(){
        var insert_post = $(this).serialize(); //metoda serialize vytvoří post z aktuálního formuláře
        insert_post += '&submitted=1'; //kpostu přilepím potvrzovací hodnotu
        $.post($(this).attr('action'),insert_post, function(data) { // Ajax volá url které je jako ACTION ve FORMU a vrací data
           
        	alert(data);	
            var jdata = eval("(" + data + ")");
               
            if (jdata.status == 'true'){//vykonají se funkce dle návratových dat
                window.location.href=jdata.url;
               
            }
            else{

                $('.error_message').attr('style','display:true');
               
            };
        },'');
        return false;
    });	*/
		
		
    $(".contact-form1").bind('submit',function(){
    	
    	var status = true;
    		    
    	if($("#form_name").val() == "") status = false;
    	if($("#form_mail").val() == "") status = false;
    	//if($("#form_phone").val() == "") status = false;
    		    
    	if(status == true) {
    	     return true;
    	}
    	else {
    		$('.error_message').attr('style','display:true');
    		return false;
    	}
    });		
    
	
});






