var go = false;

function pre(id){
  $('on'+id).className='on';
  $('comment-preview'+id).style.display='block';
  return sajax.XMLCmd('/ajx/comment.php',{'event': 'PRE','id':id,'text':$('mycomment'+id).value});
}

function changeword(id,countcom){

if(countcom > 11) {
  $('commentform1').className='visible simple-comment';
  $('commentforms1').className='answer-form';
}
$('commentform0').className='visible simple-comment';
$('commentforms0').className='answer-form'; 
_XDOC=$('mycomment'+id);
element = document.getElementById('writecomment'+id).style;
if (element.display == "none" || !element.display){
     $('a'+id).innerHTML="<span>(</span>отменить<span>)</span>";
     if($('choicecomm').value!=0 && $('choicecomm').value!=id) changeword($('choicecomm').value, countcom);
     $('choicecomm').value = id;
}else{
     $('a'+id).innerHTML="<span>(</span>ответить<span>)</span>";
     $('choicecomm').value=0;
}
ShowHideSimple('writecomment'+id);
try{$('mycomment'+id).focus()}catch(e){}
return false;
}

function nullwrite(){
	if($('choicecomm').value!=0)  ShowHideSimple('writecomment'+$('choicecomm').value);
	id = $('choicecomm').value;
	if(id!='0') $('a'+ id).innerHTML="<span>(</span>ответить<span>)</span>"; 
	$('choicecomm').value=0;
return false;
} 

function goDel(){
if(go){
	ShowHide('delcomment');
	go = false;
	return sajax.XMLCmd('/ajx/comment.php',{'event': 'DEL','id':$("iddel").value,'s':$("idsd").value,'pid':$("idpid").value});
}
return false;
}
 
function DEL(iid,section,pid){
 $("iddel").value = iid;
 $("idsd").value = section;
 $("idpid").value = pid;
 go = true;
return false;
}

function disable_button(obj){
/* comment by D.Tiourin
	obj.className='small-button-disabled';
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {eval("obj.onclick =  function(){ return false; };");}
	else {obj.setAttribute('onclick','return false;');}
*/
return false;
}


  //comment
function ShowHideElement(handler, type) {
	reg = new RegExp(" active"); 
	//var form = handler.parentNode.parentNode.parentNode.getElementsByTagName('form')[0]; 
	if (type=="form")
	{
		//var flip = handler.parentNode.getElementsByTagName('form')[0];
	}
	else if (type=="paragraph")
	{
		var flip = testnode(testnode(handler)); //.parentNode
		
		//alert(flip.nodeName.className);
	   if(flip.nodeName == 'UL')
		{	
			var comImages = testnode(flip);
			answer = testnode(comImages);
		}
		else
		{
			answer = flip;
		}
	}

	if (reg.test(flip.className))
	{
		flip.className=flip.className.replace(reg, "");
		handler.parentNode.parentNode.parentNode.className = "bad_comment"; 
		if (type=="paragraph")
		{
			handler.innerHTML = "показать"; 
			if (comImages) {
				comImages.style.display = "none";
				comImages.style.visibility = "hidden";
			}
			answer.style.display = "none";
			answer.style.visibility = "hidden";
		}
	}
	else
	{
		flip.className += " active";
		handler.parentNode.parentNode.parentNode.className = "comment";
		if (type=="paragraph")
		{
			handler.innerHTML = "скрыть"; 
			if (comImages) {
				comImages.style.display = "block";
				comImages.style.visibility = "visible";
			}
			answer.style.display = "inline";
			answer.style.visibility = "visible";
		}
	}

	fixie();
}

