var ajaxObj = new XMLHTTP("http://3dskimaps.com/_comments/mybic/mybic_server.php"); var per_page = 5; function comment_write(comment_group) { var error = ''; if (document.getElementById('author').value == '') { error += "Cannot post a comment without a name.\n"; } if (document.getElementById('new_comment').value == '') { error += "Cannot post an empty comment.\n"; } if (document.getElementById('sq_sum').value != document.getElementById('sq_answer').value) { error+="Spam answer not correct, please try again.\n"; } if (error != '') { alert(error); } else { var q = "action=comment_write&comment_group="+comment_group; q += "&author="+document.getElementById('author').value; q += "&text="+document.getElementById('new_comment').value; ajaxObj.call(q, comment_write_cb); } } function comment_page(page) { document.getElementById('page_start').value = page; redraw_comments(document.getElementById('comment_group').value); } function comments_paging(comment_group) { ajaxObj.call("action=comments_paging&comment_group="+comment_group, comments_paging_cb); } function comments_read(comment_group) { ajaxObj.call("action=comments_read&comment_group="+comment_group+"&page_start="+document.getElementById('page_start').value+"&per_page="+per_page, comments_read_cb); } function comment_read(comment_id) { ajaxObj.call("action=comment_read&comment_id="+comment_id, comment_read_cb); } function comment_read_cb(resp) { document.getElementById("new_comment").value = "[Q]"+resp.text+"[/Q]\n"; } function comment_write_cb(resp) { redraw_comments(resp); } function comments_paging_cb(resp) { if ((typeof(resp) != 'undefined') || (resp != '')) { var c = ''; var p = ''; var r = ''; c += resp; if (c != '') { n = parseInt(c); i = 1; p += 'Comments: '+r+''; i += per_page; if (i <= n) p += ' | '; c +='
'; c +='
'; c +='
'; return c; } function commentform_goto(comment_id) { comment_read(comment_id); document.location = "#commentform"; } function comment_body(who, dt, comment_id, text) { var c = ''; c +='
'; c +='
'+dt+' — '+who+'
'; c +='
'+text; c +='
'; c +='
'; // postoptions c +='
'; //text c +='
'; //comment return c; } function spam_question() { var c = ''; var i1 = Math.round(10*Math.random()) var i2 = Math.round(10*Math.random()) c +='
'; c +='

Spam Question:  What\'s '+i1+' + '+i2+'?  '; c +=''; c +='  Your Answer: '; //c +='

Your Answer: '; c +=''; c +='

'; return c; } function comments_close(comment_group) { var c = ''; c +='
'; //content c +='
'; c +='
'; c +=''; c +=''; c +='none
'; c +='
Post your comment
'; c +='
'; c +='
'; c +='
'; c +='

'; c +='

'; c +=''; c +='
'; c += spam_question(); //c +='

Post Comment

'; c +='

'; c +='
'; c +='
'; // postoptions c +='
'; //text c +='
'; //comment c +='
'; //content c +=''; //interior c +=''; //exterior return c; } function draw_comments(targ) { var content = targ; var c = ''; c += comments_open(); c += comments_close(targ.id); content.innerHTML = c; document.getElementById('page_start').value='1'; comments_read(targ.id); comments_paging(targ.id); } function redraw_comments(comment_group) { var content = document.getElementById(comment_group); var p = document.getElementById('page_start').value; var c = ''; c += comments_open(); c += comments_close(document.getElementById(comment_group).id); content.innerHTML = c; document.getElementById('page_start').value=p; comments_read(comment_group); comments_paging(comment_group); }