// JavaScript Document
function doLoad(value){
    err=document.getElementById('cerror');
	err.innerHTML = "<img src='pr.gif' width='100' height='9'><br><p>Ваш комментарий обрабатывается...</p>";
	// Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
		  if (req.responseJS.error == 'no') {
            // Clear error information.
            err.innerHTML = ' ';
			// Write req.responseJS to page element (_req.responseJS become responseJS). 
            comdiv=document.createElement('div')
			comdiv.innerHTML = '<div class="Comment"><div class="CommentSmoothTopLine"><div class="CommentSmoothTopLeft"><div class="CommentSmoothTopRight">&nbsp;</div></div></div><div class="CommentContent"><div class="CommentContentLeft"><div class="CommentContentRight"><img src="'+req.responseJS.avt+'" alt="аватар" width="50" height="60"  align="left" title="аватар" style="margin-left: 15px;"/><div style="margin-left: 55px; "><p>Автор: <strong>'+req.responseJS.name+'</strong></p><p class="Date">Добавлено: '+req.responseJS.date+'</p><p>'+req.responseJS.text+'</p>'+req.responseJS.comimg+'</div></div></div></div><div class="CommentSmoothBottomLine"><div class="CommentSmoothBottomLeft"><div class="CommentSmoothBottomRight">&nbsp;</div></div></div></div>';
			comment = document.getElementById('comtab');
			comment.appendChild(comdiv);
			form = document.getElementById('addcom');
			form.comtext.value = "";
          }
		  else
		  {
		  err.innerHTML = req.responseJS.er_mess;
		  }  	
        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, 'comment.php', true);
    // Send data to backend.
    req.send( { q: value } );
}
