var $jQuery=jQuery.noConflict();
$jQuery(function(){var c={dataType:"json",success:function(g){$jQuery("#dialog-confirm").empty();
$jQuery("#dialog-confirm").append(dialogContent(g));
$jQuery("#dialog-confirm").dialog("option","title",title(g));
var f=$jQuery("#dialog-confirm").parent().find("div.ui-dialog-buttonset");
var h=f.find("button:nth-child(1)");
var e=f.find("button:nth-child(2)");
var d=f.find("button:nth-child(3)");
h.addClass("closeButton");
e.addClass("showCartButton");
e.click(function(){window.location=g.showCartLink
});
d.addClass("checkoutButton");
d.click(function(){window.location=g.checkoutLink
});
$jQuery("#dialog-confirm").dialog("open")
},type:"post"};
var b={};
b[jQuery.i18n.prop("conShoppingText")]=function(){$jQuery(this).dialog("close")
};
b[jQuery.i18n.prop("showCartText")]=function(){};
b[jQuery.i18n.prop("checkoutText")]=function(){};
var a={autoOpen:false,resizable:false,draggable:true,height:300,width:400,modal:true,buttons:b};
$jQuery(".ajaxForm").each(function(){$jQuery(this).ajaxForm(c)
});
$jQuery("#dialog-confirm").dialog(a)
});
function title(a){if(a.success=="true"){$title=jQuery.i18n.prop("productAdded")
}else{$title=jQuery.i18n.prop("error")
}return $title
}function dialogContent(b){var a='<div id="dialog-content" style="text-align: center;">';
if(b.success=="true"){a+=productWidget(b);
updateCart(b.productsNumber,b.bonus,b.toPay)
}else{a+=errorWidget(b.errorMsg)
}a+="</div>";
return a
}function productWidget(a){return'<h4><span class="productId">['+a.productId+"]</span> "+a.productName+'</h4><img src="'+a.gfx+'" alt="'+a.productName+'" />'
}function errorWidget(a){return'<div class="ui-widget"><div style="padding: 0pt 0.7em;" class="ui-state-error ui-corner-all"><p><span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert"></span><strong>Błąd:</strong> '+a+"</p></div></div>"
}function updateCart(a,f,c){var e=$jQuery("#topMenuCart > #productsNumber").next();
e.empty();
e.append(a);
var d=$jQuery("#topMenuCart > #bonusLabel").next();
d.empty();
d.append(f);
var b=$jQuery("#topMenuCart > #toPayLabel").next();
b.empty();
b.append(c)
};
