$(document).ready(function() { 
    $('#test').click(function() { 
        $.blockUI({ message: $('#question') , css: {height:'1px',width:'1px',top:'0px',left:'0px'} }); 
    }); 

    $('#addreview').click(function() { 
        $.blockUI({ message: $('#question') , css: {height:'1px',width:'1px',top:'0px',left:'0px'} }); 
    }); 

    $('#noreview').click(function() { 
        $.blockUI({ message: $('#question') , css: {height:'1px',width:'1px',top:'0px',left:'0px'} }); 
    }); 

    $('#no').click(function() { 
        $.unblockUI(); 
        return false; 
    }); 
});

function sendReview(name,title,body,plan,price,stability,speed,usable,support){
    //改行処理
    var p = "</p><p>";
    tex = "<p>\n" + body;
    tex = tex.replace(/\r\n/g, "<br />");
    tex = tex.replace(/(\n|\r)/g, "<br />");
    tex = tex.replace(/(<br \/>){2,}/g, "\n"+p+"\n");
    tex = tex.replace(/<br \/>/g, "<br />\n");
    tex += "</p>";
    tex = tex.replace(/<p>(\r\n|\n|\r}\b)*<\/p>/g, "");
    tex = tex.replace(/<p>(\r\n|\n|\r}\b)*<br \/>/g, "<p>"); 

    $.blockUI({ message: "<h1>投稿ありがとうございました。</h1>"}); 
    $.ajax({ 
        url: '/sendreview.php?name='+encodeURI(name)+'&title='+encodeURI(title)+'&body='+encodeURI(tex)+'&plan='+plan+'&price='+price+'&stability='+stability+'&speed='+speed+'&usable='+usable+'&support='+support, 
        cache: false, 
        complete: function() { 
            // unblock when remote call returns 
            $.unblockUI(); 
            window.location.reload();
        } 
    }); 
}
