var cm_rootURL = "http://www.webtoolsinc.com/comments"; function cm_$(st) { return document.getElementById(st); } function cm_JSONscriptRequest(fullUrl) { this.fullUrl = fullUrl; this.noCacheIE = '&noCacheIE=' + (new Date()).getTime(); this.headLoc = document.getElementsByTagName("head").item(0); //this.headLoc = document.body; this.scriptId = 'JscriptId' + cm_JSONscriptRequest.scriptCounter++; return this; } cm_JSONscriptRequest.scriptCounter = 1; cm_JSONscriptRequest.prototype.buildScriptTag = function () { this.scriptObj = document.createElement("script"); this.scriptObj.setAttribute("type", "text/javascript"); this.scriptObj.setAttribute("charset", "utf-8"); this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE); this.scriptObj.setAttribute("id", this.scriptId); return this; } cm_JSONscriptRequest.prototype.buildStyleTag = function (cssUrl) { this.styleObj = document.createElement("link"); this.styleObj.setAttribute("type", "text/css"); this.styleObj.setAttribute("rel", "stylesheet"); this.styleObj.setAttribute("href", cssUrl); return this; } cm_JSONscriptRequest.prototype.removeScriptTag = function () { this.headLoc.removeChild(this.scriptObj); return this; } cm_JSONscriptRequest.prototype.addScriptTag = function () { this.headLoc.appendChild(this.scriptObj); return this; } cm_JSONscriptRequest.prototype.removeStyleTag = function () { this.headLoc.removeChild(this.styleObj); return this; } cm_JSONscriptRequest.prototype.addStyleTag = function () { this.headLoc.appendChild(this.styleObj); return this; } function cm_loadComments(data) { cm_$("commentBox").innerHTML = unescape(data.result); cm_isCalling = false; cm_currentCall.removeScriptTag(); //alert(data.result); } function cm_addPost(boxid, comid) { var obch = cm_$('postSection'); // object caching! var currentContainer = obch.parentNode; var newContainer = cm_$(boxid+comid); if (currentContainer.id != newContainer.id) { currentContainer.innerHTML = ''; currentContainer.style.height = '1px'; newContainer.style.height = 'auto'; newContainer.innerHTML = cm_commentMarkup; cm_$('replyTo').value = comid; cm_$('postC').value = 'Reply to this comment.......'; cm_$('postC').style.color = '#777'; } } function cm_cancelPost() { cm_$('postSection').parentNode.style.height = '1px'; cm_$('postSection').parentNode.innerHTML = ''; cm_$('comBox').innerHTML = cm_commentMarkup; cm_$('comBox').style.height = 'auto'; cm_$('cancelBtn').style.display = "none"; } function cm_savePost() { if (!cm_isCalling) { var post = cm_$('postC').value; var user = cm_$('postN').value; var email = cm_$('postE').value; var replyto = cm_$('replyTo').value; var url = cm_rootURL+"/get-comment.php?ajax=1&comment="+encodeURIComponent(post)+"&replyto="+replyto +"&user="+encodeURIComponent(user)+"&em="+encodeURIComponent(email)+"&pageurl="+cm_base; cm_currentCall = new cm_JSONscriptRequest(url).buildScriptTag().addScriptTag(); cm_isCalling = true; } } function cm_callbackSavePost(data) { //alert(data.result); cm_$('commentBoardBody').innerHTML = data.result; cm_isCalling = false; cm_currentCall.removeScriptTag(); var ck = cm_getCookie('votedIds'); if (ck) { var isVoted = ck.indexOf(data.cmid); if (isVoted != -1) { // already voted return; } else { // yet to get voted ck = ck + ',' + data.cmid; cm_setCookie('votedIds', ck, 365*5); } } else { cm_setCookie('votedIds', data.cmid, 365*5); } } function cm_toggleState(fcs) { var ta = cm_$('postC'); var val = ta.value; if (fcs) { if (val == 'Write a comment.......' || val == 'Reply to this comment.......') { ta.value = ''; ta.style.color = '#000'; } } else { if (!val) { ta.value = cm_$('replyTo').value ? 'Reply to this comment.......' : 'Write a comment.......'; ta.style.color = '#999'; } } } function cm_toggle(ob, im) { if (ob.style.display != 'none') { ob.style.display = 'none'; im.title = 'open'; im.src = cm_maximize_box.src; } else { ob.style.display = 'block'; im.title = 'close'; im.src = cm_rootURL+'/images/minimize.jpg'; } } function cm_voteCast(type, comid) { if (!cm_isCalling) { var ck = cm_getCookie('votedIds'); if (ck) { var isVited = ck.indexOf(comid); if (isVited != -1) { // already voted return; } else { // yet to get voted ck = ck + ',' + comid; cm_setCookie('votedIds', ck, 365*5); } } else { cm_setCookie('votedIds', comid, 365*5); } var url = cm_rootURL+"/get-comment.php?ajax=1&comid="+comid+"&vote="+type+"&pageurl="+cm_base; cm_currentCall = new cm_JSONscriptRequest(url).buildScriptTag().addScriptTag(); cm_isCalling = true; } } function cm_callbackVoteCast(data) { //alert(data.result); cm_$('voteRes'+data.comid).innerHTML = data.result; cm_isCalling = false; cm_currentCall.removeScriptTag(); } var cm_path = cm_$("commentBox").getAttribute("path"); var cm_pathV= ''; if (cm_path) { cm_path = String(cm_path); var cm_ar = cm_path.match(/^https?:\/\/[^\/]+(.*)/); if (cm_ar) { cm_pathV = cm_ar[1].replace(/\/$/, ''); } else { cm_pathV = cm_path.replace(/^\/?(.+)\/?/, "/$1"); } } else { cm_pathV = location.pathname.replace(/\/$/, '')+location.search; } var cm_base = encodeURIComponent(location.protocol+"//"+location.hostname+cm_pathV); var cm_url = cm_rootURL+"/get-comment.php?pageurl="+cm_base; var cm_currentCall = new cm_JSONscriptRequest(cm_url).buildScriptTag().addScriptTag(); var cm_isCalling = true; var cm_commentMarkup = '
'+ '
'+ '
'+ ' Name*
'+ ' Email*'+ ''+ '
'+ '
'+ ''+ '
CANCEL REPLY
'+ '
'+ '
'; /**************** COOKIE MANAGEMENT *************************/ function cm_getCookie(cname) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(cname + "="); if (c_start!=-1) { c_start=c_start + cname.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } function cm_setCookie(cname,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=cname+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } /************* END OF COOKIE MANAGEMENT **********************/ var cm_hover_up = new Image(); cm_hover_up.src = cm_rootURL+'/images/hover_thumbs_up.jpg'; var cm_hover_down = new Image(); cm_hover_down.src = cm_rootURL+'/images/hover_thumbs_down.jpg'; var cm_maximize_box = new Image(); cm_maximize_box.src = cm_rootURL+'/images/maximize.jpg'; //var cm_owner_logo = new Image(); //cm_owner_logo.src = cm_rootURL+'/images/logo-small.jpg';