var flagCaptcha = false;
var flagFields = true;
var message = 'Please fill in all mandatory fields ! \n';
function createRequestObject(){
try {
xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
alert('Sorry, but your browser doesn\'t support XMLHttpRequest.');
};
return xmlhttp;
};
var http = createRequestObject();
function refreshimg(){
var url = InstallationUrl + 'captcha-refresh.php';
dorefresh(url, displayimg);
};
function dorefresh(url, callback) {
http.open('POST', url, true);
http.onreadystatechange = displayimg;
http.send(null);
};
function displayimg() {
if(http.readyState == 4) {
var showimage = http.responseText;
document.getElementById('captchaimage').innerHTML = showimage;
};
};
function checkForm() {
var submission = document.PostCommentForm.vercode.value;
var url = InstallationUrl + 'captcha-process.php?captcha=' + submission;
http.open('GET', url, true);
http.onreadystatechange = displaycheck;
http.send(null);
};
function displaycheck() {
flagFields = true;
var PostCommentName = document.PostCommentForm.PostCommentName.value;
var PostCommentEmail = document.PostCommentForm.PostCommentEmail.value;
var PostCommentBody = document.PostCommentForm.PostCommentBody.value;
if (PostCommentName.length==0 || PostCommentEmail.length==0 || PostCommentBody.length==0){
flagFields = false;
};
if(http.readyState == 4) {
var showcheck = http.responseText;
if(showcheck == '1') {
flagCaptcha = true;
} else if(showcheck == '0') {
flagCaptcha = false;
};
if (flagCaptcha == false || flagFields==false) {
if (flagCaptcha == false && flagFields == false) {
message = 'Please fill in all fields ! \nIncorrect verification code \n';
} else if (flagCaptcha == false) {
message = 'Incorrect verification code \n';
} else if (flagFields == false) {
message = 'Please fill in all fields \n';
};
};
if (flagCaptcha == false || flagFields==false) {
alert(message);
} else {
ajaxpage(InstallationUrl + 'postcomment.php?id='+pageCommentID+'&do=post','PostCommentContainer','post');
};
};
};
var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var bustcacheparameter="";
function ajaxpage(url, containerid, requesttype){
var page_request = createRequestObject();
if (requesttype=='get'){
if (bustcachevar) bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
} else if (requesttype=='post') {
var PostCommentName = document.PostCommentForm.PostCommentName.value;
var PostCommentEmail = document.PostCommentForm.PostCommentEmail.value;
var PostCommentBody = document.PostCommentForm.PostCommentBody.value;
var poststr = "PostCommentName=" + encodeURIComponent(PostCommentName) + "&PostCommentEmail=" + encodeURI(PostCommentEmail) + "&PostCommentBody=" + encodeURIComponent(PostCommentBody);
page_request.open('POST', url, true);
page_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
page_request.setRequestHeader("Content-length", poststr.length);
page_request.setRequestHeader("Connection", "close");
page_request.send(poststr);
};
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
loadComments = '';
document.writeln(loadComments);