$(document).ready(
	function() 
	{
	
		$('#bgcontainer .SCS .goods .good').mouseover(function(){
			$(this).children('.buy-button').show();
		});
		$('#bgcontainer .SCS .goods .good').mouseout(function(){
			$(this).children('.buy-button').hide();
		});	
		$.get("/basket/", { tmpl : 'mini'}, function(data){
		  $('#cart_id').html(data);
		  
		});
	}
);
(function($) {

	$.extend({
		add2cart: function(oid, target_id, callback) {
      
      var source_id = 'good_' + oid;
      
      var source = $('#' + source_id );
      var target = $('#' + target_id );
      
      var shadow = $('#' + source_id + '_shadow');
      if( !shadow.attr('id') ) {
          $('body').prepend('<div id="'+source.attr('id')+'_shadow" style="display: none; background-color: #ddd; border: solid 1px darkgray; position: static; top: 0px; z-index: 100000;">&nbsp;</div>');
          var shadow = $('#'+source.attr('id')+'_shadow');
      }
      
      if( !shadow ) {
          alert('Cannot create the shadow div');
      }
      
      shadow.width(source.css('width')).height(source.css('height')).css('top', source.offset().top).css('left', source.offset().left).css('opacity', 0.5).show();
      shadow.css('position', 'absolute');
      $.get("/basket/", { oid: oid, action: 'add', tmpl : 'mini'}, function(data){
		  target.html(data);
	  });
/* 

								<form class="buy" action="/basket/?action=add" method="post">
								<div>
								Цена: {if $item.content.old_price}<strike>{$item.content.old_price}</strike> {/if}<strong>{$item.content.price}</strong> руб<br />
								<input class="image" type="image" src="/media/img/buy.gif" alt="Купить" />
								{*<input type="hidden" name="tmpl" value="abs" />*}
								<input type="hidden" name="oid" value="{$item.oid}" />

       */
      shadow.animate( { width: target.innerWidth(), height: target.innerHeight(), top: target.offset().top, left: target.offset().left }, { duration: 300 } )
        .animate( { opacity: 0 }, { duration: 100, complete: callback } );
        
		}
	});
})(jQuery);

function buy(name, cost){
	
}
