var request;var request2;var cpage=1;var fl=false; function setPageCompleted(){ if ((request2.readyState == 4)&&(request2.status==200)){ if (request2.responseText != "0"){ document.getElementById('comments').innerHTML=request2.responseText; } } return 0; } function setPage(page){ if (fl){ fl=false; document.getElementById('status').innerHTML=''; } if(window.XMLHttpRequest) {request2=new XMLHttpRequest();} else if (window.ActiveXObject) {request2=new ActiveXObject("Microsoft.XMLHTTP");} request2.onreadystatechange=setPageCompleted; request2.open("GET", "http://www.chelny.su/mod/komm.php?action=getPage&event=news&event_id=366&page=" + page, true); request2.send(null); document.getElementById('comments').innerHTML="
"; return 0; } function submitMessageCompleted(){ if ((request.readyState == 4)&&(request.status == 200)){ if (request.responseText != "0"){ document.getElementById('myform').reset(); change_block('kommjs_min','kommjs_plus','kommjs_add'); document.getElementById('countComments').innerHTML=request.responseText; k=parseInt(request.responseText); cpage=parseInt((k + 3 - 1) / 3); setPage(cpage); document.getElementById('status').innerHTML='
Комментарий добавлен.
'; fl=true; } else{ document.getElementById('status').innerHTML='
Не удалось добавить комментарий.
'; } } } function submitMessage(){ var url="http://www.chelny.su/mod/komm.php?action=addMessage&event=news&event_id=366&name="; var obj=document.getElementById('name').value; if (!obj.length){ document.getElementById('err').style.display='block'; return 0; } url+=obj+"&text="; var obj=document.getElementById('text').value; if (!obj.length){ document.getElementById('err').style.display='block'; return 0; } obj=encodeURI(obj); url+=obj+"&city=" + document.getElementById('city').value + "&email=" + document.getElementById('email').value; document.getElementById('err').style.display='none'; if(window.XMLHttpRequest) {request=new XMLHttpRequest();} else if (window.ActiveXObject) {request=new ActiveXObject("Microsoft.XMLHTTP");} request.onreadystatechange=submitMessageCompleted; request.open("GET",url, true); request.send(null); return 0; }