function createRequestObject() {
var req;
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('هناك خطأ المتصفح لا يدعم الاجاكس ');
}
return req;
}
var http = createRequestObject();
function sendcomment() {
	var content = document.getElementById('content').value;
	content = content.replace(/\r\n\r\n/g, "</p><p>");
	content = content.replace(/\r\n/g, "<br>");
	content = content.replace(/\n\n/g, "</p><p>");
	content = content.replace(/\n/g, "<br>");
	var bid = document.getElementById('bid').value;
	var bname = document.getElementById('bname').value;
	var comnkind = document.getElementById('comnkind').value;
	var codea = document.getElementById('codea').value;
	var codec = document.getElementById('codec').value;
	if (bname == '') {
    formErrors = "اين الاسم؟";
    alert(formErrors);
    document.commentform.bname.focus();
    return false;
    }
	if (bid == '') {
    formErrors = "هناك خطأ";
    alert(formErrors);
    document.commentform.bid.focus();
    return false;
    }
	if (content == '') {
    formErrors = "أين التعليق؟";
    alert(formErrors);
    document.commentform.bmessage.focus();
    return false;
    }
    if (codec == '') {
    formErrors = "اين كود التأكيد؟";
    alert(formErrors);
    document.commentform.codec.focus();
    return false;
    }
    if (codea == '') {
    formErrors = "اين كود التأكيد؟";
    alert(formErrors);
    document.commentform.codea.focus();
    return false;
    }
    document.commentform.send.disabled=true;
	var poststr = "comment.php?bmessage=" + encodeURI(content) + "&bid=" + bid + "&bname=" + encodeURI(bname) + "&comnkind=" + encodeURI(comnkind) + "&codea=" + encodeURI(codea) + "&codec=" + encodeURI(codec);
    http.open('GET',poststr);
    http.onreadystatechange = handlecomment;
    http.send(null);
}
function handlecomment() {
    if(http.readyState <4){
        document.getElementById('fcommentdiv').innerHTML = 'انتظر قليلاً...';
    }
    if(http.readyState == 4){
        var response = http.responseText;
        document.getElementById('fcommentdiv').innerHTML = response;
    }
}






