var consoleTable;
var consoleTableHeight = 0;
var panelHeight = 120
    
function tableSize(){
    consoleTable = document.getElementById('innerform');
    consoleTableHeight  = consoleTable.offsetHeight;
    panelHeight = consoleTableHeight + 80; //get content height
}  
    
$(document).ready(function() {
    var items = 0;
    
    $("#sendItems").click(function(){
        window.location='/cart';        
    });
    $("#new-user").click(function(){
        window.location='/cart/registration';        
    });
    
    tableSize();
    
    var panelSpeed = 500;
    $('#open').click(function(){
        $(this).css({'background':'url(../images/loader.gif) no-repeat'});
        
        $.get('/body/includes/library/cart.php',function(data) {
            if (data=='') {
                $("#sendItems").hide();
                $("table#consoleTable").html('<tr><td>Корзина пуста</td></tr>');
            } else $("table#consoleTable").html(data);
      
            tableSize();
            
            $('#clientPanel .panel').animate({height: panelHeight +'px'}, panelSpeed, function() {
                $('#open').css({'background':'url(../images/icons.png) no-repeat 0 -59px','display' : 'none'});
                $('#close').css({'display' : 'block'});
            });
            
      });       
    }); 
    
    $('#close').click(function(){
        $('#clientPanel .panel').animate({height: '0px'},panelSpeed, function() {
            $('#open').css({'display' : 'block'});
	        $('#close').css({'display' : 'none'});
        });	
    });
    
    $('#servis li').hover(function(){
        $(this).stop(true,false).animate({backgroundPosition: '0px 0px'}, 500);
    },function(){
        $(this).stop(true,false).animate({backgroundPosition: '0px -100px'},500);
    });
  
    $('#cash .chek').click(function(){
        $('#cash .dropdown').css({'display' : 'block'});	
        $('#cash .dropdown').click(function(){
            $(this).css({'display' : 'none'});
        });                                   
        $('#cash .dropdown li').click(function() {
            window.location='/?'+$(this).attr('class');        
        });
    });
});
