$(document).ready(function(){
    
    var show_category = $.cookie('show_category');
	if (show_category == null)
	{
		show_category = true;
 		$('#category_tree').hide();
    }
	else
	    show_category = show_category == 1 ? true : false;
	
    
    if (show_category)
    	$('#category_tree').show();
	else
		$('#category_tree').hide();
    
    $('#show_categories').click(function() {
    	var category_tree = $('#category_tree');
    	category_tree.toggle('normal', function() {
    		if (category_tree.is(':visible'))
    			$.cookie('show_category', 1, {path: '/'});
   			else
   				$.cookie('show_category', 0, {path: '/'});
    	});
    	return false;
    });
    
    $("#product #specyfication tr:odd").attr('class', 'odd');
    
    
    // Add To Cart
    $('.add_to_cart a').each(function(){
    	$(this).colorbox().bind('cbox_complete', function(e) {
    		$('#colorbox #continue').click(function(){
		    	$.fn.colorbox.close();
		    	return false;
		    });
    		
    	});
    });
        
    var is_invoice = $('#order_form_is_invoice');
    
    $('#order_invoice input[type="text"]').attr("disabled", "disabled");
	if (is_invoice.is(':checked'))
		$('#order_invoice input[type="text"]').removeAttr("disabled");
	else
		$('#order_invoice input[type="text"]').attr("disabled", "disabled");
    
    is_invoice.change(function () {
    	if (is_invoice.is(':checked'))
			$('#order_invoice input[type="text"]').removeAttr("disabled");
		else
			$('#order_invoice input[type="text"]').attr("disabled", "disabled");
	});

	//Product images
	var current_image = $('#product #current_image');
	$('#product #thumbs a').each(function(){
		var link = $(this);
		link.click(function(){
			current_image.attr('src', link.attr('href'));
			return false;
		});
	});
    
});