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() {
displaycheck();
};
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 (flagFields==false) {
alert('Please fill in all fields');
} 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 PostCommentRate = document.PostCommentForm.PostCommentRate.value;
var poststr = "PostCommentName=" + encodeURIComponent(PostCommentName) + "&PostCommentEmail=" + encodeURI(PostCommentEmail) + "&PostCommentBody=" + encodeURIComponent(PostCommentBody) + "&PostCommentRate=" + encodeURIComponent(PostCommentRate);
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
}
function hasClass(el, className)
{
if (el.classList)
return el.classList.contains(className);
return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
}
function addClass(el, className)
{
if (el.classList)
el.classList.add(className)
else if (!hasClass(el, className))
el.className += " " + className;
}
function removeClass(el, className)
{
if (el.classList)
el.classList.remove(className)
else if (hasClass(el, className))
{
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
el.className = el.className.replace(reg, ' ');
}
}
function starHover(obj) {
var star = obj.getAttribute('data-star');
for(var i = 1; i <= 5; i++)
{
el = document.getElementById('pjRrStar_' + i);
if(i <= star)
{
addClass(el, 'pjRrStarChecked');
}else{
removeClass(el, 'pjRrStarChecked');
}
}
document.getElementById('PostCommentRate').value = star;
}
loadComments = '';
document.writeln(loadComments);