var cursValutar = 0;
$(document).ready(function() {
    Ajax.Request({
        url: conf.location+"/controller/user/ajax/getCurs.php",
        onComplete: function(raspuns) {
            $I("cursValutar2").value = $.trim(raspuns);
        }
    });
    $("a#scrieImpresie").click(function() {
        dialog = document.createElement("div");
        dialog.setAttribute("id", "impresieDiv");
        dialog.setAttribute("title", "Lasa-ne o impresie.");
        dialog.innerHTML = "Nick: <input type='text' id='nick' /><br/><textarea id='impresie' rows='5' cols='33'></textarea>";
        $I("scrieImpresie").appendChild(dialog);
        $("div#impresieDiv").dialog( {
            modal : true,
            width : 400,
            height : 300,
            resizable: false,
            buttons : {
                'Cancel' : function() {
                    dialog.parentNode.removeChild(dialog);
                    $(this).dialog('close');
                },
                'Trimite' : function() {
                    nick = $V("nick");
                    impresie = $V("impresie");
                    impresie = impresie.replace(/\n/g, '<br/>');
                    if (nick && impresie) {
                        Ajax.Request({
                            url: "http://eastbayiasi.ro/controller/user/ajax/impresii.php?nick="+nick+"&impresie="+impresie,
                            onLoad: function(){
                                $I("impresieDiv").innerHTML = "<img src='http://eastbayiasi.ro/templates/user/image/loading.gif' width='360px' height='159px' />";
                            },
                            onComplete: function(raspuns) {
                                $I("impresieDiv").innerHTML = raspuns;
                                $("div#impresieDiv").dialog("option", "buttons", {
                                    'Close': function(){
                                        dialog.parentNode.removeChild(dialog);
                                        $(this).dialog('close');
                                    }
                                });
                            }
                        });
                    }else
                        alert("Trebuie completate toate campurile");
                }
            }
        });
    });
});
