function str_replace(haystack, needle, replacement) {
    var r = new RegExp(needle, 'g');
    return haystack.replace(r, replacement);
}
function showDiv(t){
    $('#'+t).toggle(150);
    return false
}
function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? new Date(argv[2]) : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + /*escape (*/ value /*)*/ +
        ((expires == null) ? "" : ("; expires="+expires.toGMTString())) +
        ((path == null) ? "; path=/" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
};
function add_com(){
    i=$('#form_com input[name="id"]').attr('value')
    c=$('#form_com textarea[name="comment"]').attr('value')
    $('#form_com [name="sub"]').attr("disabled", true)
    $.post("/cgi-bin/blog.py",
        { id:i, comment:c,
            cmd:'add_comment',
            ajax:'true'},function(data)
            {showDiv('post_form')
             $("#status_message").html("<strong>"+data+"</strong>");
                $("#status_message").show(1000);
                window.setTimeout(function() { $("#status_message").hide("slow")},1500)
                $('#form_com [name="sub"]').attr("disabled", false);
                var h='<div><p>'+str_replace(c,"\n", "<br />")+'</p><hr /   ></div>';
                $('#div_com').append(h);
            }
    );
}
$(document).ready(function() {
    $("#menu span").each(function() {$(this).bind("click", function(){
        $("#menu div").hide()
        $(this).next().toggle()
    })})
})
