//popup watku
function moreForum(id,max,IdWatek,IdTemat)
{
 for(i=0;i<max;i++)
 {
 $('IdBox'+i).setStyle({background: '#FFF'});
 }

 $(id).setStyle({background: '#F5FBFF'});

 showForum(IdWatek,IdTemat);
}




//popup forum
function showForum(IdWatek,IdTemat)
{
 var rand = Math.round(Math.random()*10000);
 displayUrl('modalDialog_contentDiv_foto', 'popup.php?d=Forum/Forum,forum,'+IdWatek+'&IdTemat='+IdTemat+'&rand='+rand, 760, 560);
}





//--pokaz ukryj CommentForm--------------------------------------
function showCommentForm(ID,usr)
{
stan=$(ID).getStyle('display');
if(stan=='none')
{
 $(ID).show();
 $('nick').value=usr;
 if(ID=='NewComment') {document.location.href='#NewCommentForm';}
} else
      {
	  $(ID).hide();
	  }

}




//--pokaz ukryj form w liscie odpowiedzi--------------------------------------
function showAnswerCommentForm(ID, IdWatek, IdTemat)
{
stan=$('AnswerCommentForm'+ID).getStyle('display');

if(stan=='none')
{
$('AnswerCommentForm'+ID).show();
new Ajax.Updater({ success: 'AnswerCommentForm'+ID }, '/inc/ajax_forum.php', { parameters: { id: ID, idwatek: IdWatek, idtemat: IdTemat, action: 'showAnswerCommentForm' }, onComplete: function(){ var x; } } );

} else
      {
	  $('AnswerCommentForm'+ID).hide();
	  }

}
















//--addComment--------------------------------------
function addComment(IdTemat,IdUser)
{

if(IdUser>0)
{
if($('nick').value!='' && $('temat').value!='' && $('komentarz').value!='')
{
$('CommentAlert').update('proszę czekać...').show();

//new Ajax.Updater({ success: 'CommentList' }, '/inc/ajax_forum.php', { parameters: { nick: $F('nick'), temat: $F('temat'), komentarz: $F('komentarz'), idtemat: IdTemat, action: 'addNewComment' },
//onComplete: function(){ $('CommentAlert').hide(); },  insertion: Insertion.Top } );

new Ajax.Request('/inc/ajax_forum.php', { parameters: { nick: $F('nick'), temat: $F('temat'), komentarz: $F('komentarz'), idtemat: IdTemat, action: 'addNewComment' },
onComplete: function(transport){  /*$('CommentAlert').update('sss'+transport.responseText);*/  window.location.reload();} } );


showCommentForm('NewComment');

}else{
     alert('proszę wypełnić formularz');
     }
}else{
     alert('Aby dodać komentarz proszę sie zalogować.');
     }


}














//--addAnswer--------------------------------------
function addAnswer(id, IdWatek, IdTemat,IdUser)
{

if(IdUser>0)
{
if($('nick'+id).value!='' && $('komentarz'+id).value!='')
{
//$('AnswerComment'+id).update('proszę czekać...');

//new Ajax.Updater({ success: 'CommentList' }, '/inc/ajax_forum.php', { parameters: { nick: $F('nick'), temat: $F('temat'), komentarz: $F('komentarz'), idtemat: IdTemat, action: 'addNewComment' },
//onComplete: function(){ $('CommentAlert').hide(); },  insertion: Insertion.Top } );

new Ajax.Request('/inc/ajax_forum.php', { parameters: { nick: $F('nick'+id), komentarz: $F('komentarz'+id), id: id, idtemat: IdTemat, action: 'addNewAnswer' }, onComplete: function() { closeMessage(); showForum(IdWatek,IdTemat)} } );

//showCommentForm('NewComment');

}else{
     alert('proszę wypełnić formularz.');
     }
}else{
     alert('Aby dodać komentarz proszę sie zalogować.');
     }


}