new Image().src = "/st/images/reghere.gif";
new Image().src = "/st/images/reghere_b.gif";

function mouseIn(me) {
    me.src = "/st/images/reghere_b.gif";
}
function mouseOut(me) {
    me.src = "/st/images/reghere.gif";
}

function calculate() {

    callback = function(data, textStatus) {
        if (textStatus != "success") return;
        $("#calcForm").html(data.form);
        if (data.result != null) {
            html  = '<table border="0" width="450" height="300">';
            html += '<tr>';
            html += '<td background="/st/images/calc_bg.gif">';

            html += '<table border="0" width="450" cellspacing="0" cellpadding="0" height="300">';
            html += '<tr><td height="33%">&nbsp;</td></tr>';

            html += '<tr><td height="33%"><p align="center"><center>';
            html += '<img src="/st/images/doll4.gif">';
            result = new String(data.result);
            for (i = 0; i < result.length; i++) {
                html += '<img src="/st/images/nr/' + result.charAt(i) + '.gif">';
            }
            html += '</center></p></td></tr>';

            html += '<tr><td height="33%"><p align="center"><center>';
            html += '<a href="/register" target="_top">'
            html += '<img src="/st/images/reghere.gif" border="0" ';
            html += '   onMouseOver="mouseIn(this);" onMouseOut="mouseOut(this);">';
            html += '</a></center></p></td></tr>';

            html += '</table>';
            html += '</td>';
            html += '</tr>';
            html += '</table>';
            jQuery.facebox(html);
        }
    }

    jQuery.post("/calc", $(".form"), callback, "json" );
}
