/*
* index.js
* Polya's blog project's JScript file
* Copyright by Victor Didenko aka Vicar aka le'Aio
*/
function fnOnLoadPage(id, e) {
fnValignBottom();
if (id != 0) fnShowComment(id);
}
function fnAddCommentBeforeSend(f, ncid) {
var name = f.name.value;
var email = f.email.value;
var comment = f.comment.value;
if (comment == "") {
alert("nothing to add");
return false;
}
if ((/[\"<>;:]|(^\s*$)/).test(name)) {
alert("bad name");
return false;
}
if (email != "") {
if (!(/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,6}$/i).test(email)) {
alert("bad e-mail");
return false;
}
}
setCookie('cookiename', name, 5000); setCookie('cookiemail', email, 5000);
var s = id(ncid); s.innerHTML = parseInt(s.innerHTML) + 1;
var text = '~name~, ~date~
';
if (email != "") name = ''+name+'';
comment = comment.replace(/\r\n|\r|\n/g,"
");
text = text.replace("~name~", name);
text = text.replace("~date~", "just added");
text = text.replace("~comment~", comment);
id(ncid.replace("s", "cs")).innerHTML += text;
fnSHAddComment(ncid.replace("s", "a"));
return true;
}
function fnButtonDown(bt) {
if (bt.className == 'top_bt') {
switch (bt.id) {
case 'top_log':
if (id("logindialog").style.visibility == 'visible') {
id("logindialog").style.visibility = 'hidden';
} else {
id("logindialog").style.top = 74;
id("logindialog").style.left = 100;
id("logindialog").style.visibility = 'visible';
bt.src = 'images/top/top3_login_gl.gif';
setTimeout('id("loginnameinput").focus()', 10);
}
break;
}
}
}
function fnShowComment(postid) {
var p = id(postid);
p.innerHTML = "loading... please wait";
if (p.style.visibility == 'visible') {
p.style.visibility = 'hidden';
} else {
p.style.visibility = 'visible';
var pathtoload = "comm"+"ents.ph"+"p?id=";
fnLoadHTML(p, pathtoload + postid);
}
}
function fnSHAddComment(postid) {
var p = id(postid);
(p.style.display != 'block') ? p.style.display = 'block' : p.style.display = 'none';
}
function fnHover(isover, e) {
e = e || window.event; var it = e.target || e.srcElement;
if (it.className == 'top_bt') {
it.src = (isover) ? loginimg_in.src : loginimg_out.src;
if (id("logindialog").style.visibility == 'visible') it.src = loginimg_in.src;
if (e.type == 'click') fnButtonDown(it);
}
if (e.type == 'click') fnValignBottom();
}