var hiding = false;

function addProductToCart(sender){
    product = sender.parent().parent().parent().parent();
    options = { to: ".logout-links", className: "ui-effects-transfer" };
    product.effect( "transfer", options, 500 );
}

function toggleDebugger(){
    if(hiding == undefined || hiding == false){
        $(".debugger-spacer").css( "height" , "80px"  );
        $(".debugger-container").css( "height" , "30px"  );
        $(".debugger-container").css( "overflow-y" , "hidden"  );
        hiding = true;
    }else{

        $(".debugger-container").css( "height" , "30%"  );
        $(".debugger-spacer").css( "height" , "400px"  );
        $(".debugger-container").css( "overflow-y" , "auto"  );
        $(".debugger-container").effect("slide", { direction: "down", distance: "400" }, 1000);
        hiding = false;
    }
}

function submitDebugForm(form){
    var container = form.parent().next();
    var pathname = window.location.pathname;
    container.html("<center><img src='"+$.url('public/images/spinner.gif')+"' /></center>");
    var method = form.attr("method");
    var url = form.attr("action");
    
    $.post($.url("application/proxy"), form.serialize(), function(data){
          container.hide();
          container.html("<pre>"+data+"</pre>");
          container.fadeIn();
    });
    
}

$.url = function(url) {
  return $('base').attr('href')+url;
}
