$(document).ready(function(){

	$(".slideInBg, .partName").css('opacity', '0.7');
	$(".veil").css('opacity', '0.60');

  // externi odkazy
  $('a[rel="external"]').click(function(){
		window.open( $(this).attr('href') );
    return false;
	})

	// execute your scripts when DOM is ready. this is a good habit 
	$(function() {         
	         
	    // initialize scrollable  
	    $("div.scrollable").scrollable({ 
	        vertical:true,  
	        size: 7,
	        clickable: false
	    });     
	     
	}); 


  
	$('.toCard').click(function() {	
		
		var href = $(this).attr("href");
		var desc = $(this).attr("title");
		var id = $(this).attr("id");
		
		var img = $('img[id="'+id+'"]').attr("src");
				
		$.ajax({
		      type: "GET",
		      url: href,
		      success: function(msg){
				var returnedData =  eval("(" + msg + ")");
				
				$("#cardInfo").html(returnedData['text']);
				
				if(returnedData['full'] == true) {
					$(".cardShopImg").attr("src",returnedData['img']);
					$(".toCartText").html(returnedData['toCart']);
					
				}
				
				function goToCart(v,m,f){
				      if(v == true) {
				    	  window.location=url+"e-shop/kos";
				      }
		 		}		    	
		    	
				$.prompt('<img src="'+img+'" />'+desc+' přidáno do košíku',{ opacity: 0.85, buttons: { 'Dokončit objednávku': true, 'Pokračovat v nákupu': false }, focus: 3, callback: goToCart });	
				
							
		      }
		
		  }); 
		

		return false;
		
	
	});
	
	
	
	
	
	
	$('.imageBtn').click(function() {	
		
		
		var href = $(this).parent().attr("action");
		var thisForm = $(this).parent();
		var desc = $(this).attr("title");
		var id = $(this).attr("id");
		var img = $('img[id="'+id+'"]').attr("src");		
		
		$.ajax({
		      type: "GET",
		      url: href,
		      data: thisForm.serialize(),
		      success: function(msg){
	
				var returnedData =  eval("(" + msg + ")");
				var quantity = returnedData['quantity'];
				

				$("#cardInfo").html(returnedData['text']);
				
				if(returnedData['full'] == true) {
					$(".cardShopImg").attr("src",returnedData['img']);
					$(".toCartText").html(returnedData['toCart']);
					
				}
				
				function goToCart(v,m,f){
				      if(v == true) {
				    	  window.location=url+"e-shop/kos";
				      }
				}		    	
				
				$.prompt('<img src="'+img+'" />'+desc+' ('+quantity+'x) přidáno do košíku',{ opacity: 0.85, buttons: { 'Dokončit objednávku': true, 'Pokračovat v nákupu': false }, focus: 3, callback: goToCart });	
				$("#quantity").val("1");
				
		      }
		
		  }); 

		return false;
	
	});
	
	
	
});	