function addCommentJS(){
	if(document.getElementById('userid').value=="0"){dLoginBox("submit_comment","below_left");
	}else{
		if(document.getElementById('user_comment').value.length>2){
		document.getElementById('SCmmntsLoading').style.display = "block";
		document.getElementById('SCmmntsLoading').style.color = "#009900";
		mySWF.callSWF("addComment", ["JS", document.getElementById('f').value, document.getElementById('user_comment').value]);
		document.getElementById('user_comment').value = '';
		document.getElementById('SCmmntsLoading').innerHTML = "جاري إضافة التعليق...";
		document.getElementById('CmtTxtBox').style.display = "none";
		//document.getElementById('SCmmntsLoading').style.display = "none";
		}else{
			document.getElementById('SCmmntsLoading').style.display = "block";
			document.getElementById('SCmmntsLoading').style.color = "#CC0000";
			document.getElementById('SCmmntsLoading').innerHTML = "Please submit a comment";
}}
} 


function Builtcomments(ComObj){

//alert('Start');
		document.getElementById('SCmmntsLoading').style.display = "none";
		document.getElementById('CmtTxtBox').style.display = "block";
		var Comments=ComObj.comments;

//alert(Comments.length);
//alert(2);
		commentsTotal = ComObj.commentsTotal.split("comment_Status");
		parseInt(commentsTotal[0]); 
		if(commentsTotal[0] > 0)
		var div_content = "<div align='left' style='height:25px; padding-left:7px; border-bottom: 1px dashed #999; margin-bottom:5px;'><b>عدد التعليقات&nbsp;:&nbsp;</b>"+commentsTotal[0]+"</div>";
//alert(2);
		var reply_tip="رد";
		reply_tip=reply_tip.replace(' ','&nbsp');
		var vote_up_tip="أعجبني";
		vote_up_tip=vote_up_tip.replace(' ','&nbsp');
		var vote_down_tip="لم يعجبني";
		vote_down_tip=vote_down_tip.replace(' ','&nbsp');
//alert(4);

		var flag_for_spam_tip="مشاركة عابثة";
		flag_for_spam_tip=flag_for_spam_tip.replace(' ','&nbsp');
//alert(5);

//TEMP FLAG VALUE
var tempflag=1;

//TEMP MARK VALUE
var userMark=0;
var comOkayImg;
var comBadImg;
	for (var i=0; i<Comments.length; i++)
	{
	var ComItem=Comments[i];
//alert(ComItem.id);
	div_content += '<div id="comment_group_'+ComItem.id+'" class="combox" onmouseover=JAVASCRIPT:ShowPanel("dv_commentsreply_'+ComItem.id+'");this.className="combox_hover";  onmouseout=JAVASCRIPT:HidePanel("dv_commentsreply_'+ComItem.id+'");this.className="combox";> <div id="dv_cmntsloader'+ComItem.id+'" align="left" class="loadergif"><img src="images/imgloader.gif" width="28" height="28"></div>';
	
	var alter_username = ComItem.username;
	if(ComItem.username.indexOf(" ") == -1)
	{
		alter_username = ComItem.username.substr(0,14);
	}

div_content += '<div style="float:left; width:115px; padding-left:8px;"><a href="http://www.yabdoo.com/board/member.php?u=' + ComItem.userid +'" class="blue" target="_blank" title='+ComItem.username+'>'+ alter_username +'</a><br/><div id="dv_voteupdown'+ComItem.id+'">'+ComItem.date+'<br/><div style="float:left">';

if(userMark == 1)
{
comOkayImg = GenrateIcon('vote_up_over', vote_up_tip, ComItem.id, '', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'mark' + '","'+ '1' + '","")');
comBadImg = GenrateIcon('vote_down', vote_down_tip, ComItem.id, '', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'mark' + '","'+ '2' + '","")');
}
else if(userMark == 2)
{
comOkayImg = GenrateIcon('vote_up', vote_up_tip, ComItem.id, '', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'mark' + '","'+ '1' + '","")');
comBadImg = GenrateIcon('vote_down_over', vote_down_tip, ComItem.id, '', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'mark' + '","'+ '2' + '","")');
}
else
{
comOkayImg = GenrateIcon('vote_up', vote_up_tip, ComItem.id, '', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'mark' + '","'+ '1' + '","")');
comBadImg = GenrateIcon('vote_down', vote_down_tip, ComItem.id, '', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'mark' + '","'+ '2' + '","")');
}
         
div_content += comOkayImg;
div_content += '</div><div id="comment_okay_'+ComItem.id+'" style="float:left;">'+ComItem.okay+'</div><div style="float:left">';
div_content += comBadImg;

         div_content += '</div><div id="comment_bad_'+ComItem.id+'" style="float:left;">'+ComItem.bad +'</div></div></div>';

	div_content += '<div id="dv_comments" style="width:265px; float:left;">'+ ComItem.comment+'</div>'; 
	div_content += '<div id="dv_commentsreply_'+ComItem.id+'" style="padding-left:7px; display:none">';
         
if(ComItem.reply > 0)
{
	div_content += GenrateIcon('reply_over', reply_tip, ComItem.id, 'combdr', 'JAVASCRIPT:ShowHidePanel("replyTxt'+ComItem.id +'")');
}
else
{
	div_content += GenrateIcon('reply', reply_tip, ComItem.id, 'combdr', 'JAVASCRIPT:ShowHidePanel("replyTxt'+ComItem.id +'")');
}

if(tempflag > 0)
{             
       div_content += GenrateIcon('flag_over', flag_for_spam_tip, ComItem.id, 'combdr', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'flag' + '","'+ '1' + '","sssssssss")');
}
else
{
    div_content += GenrateIcon('flag_up', flag_for_spam_tip, ComItem.id, 'combdr', 'JAVASCRIPT:userPostAction("'+  ComItem.id + '","'+ 'flag' + '","'+ '1' + '","sssssssss")');
 
}


div_content += '</div></div><div id="replyTxt'+ComItem.id+'" style="display:none; background-color: #E1E1E1;" align="center"><textarea name="Address" id="Address" rows="3" cols="52" class="required">@'+ ComItem.username +'</textarea><div align="right" style="padding-bottom:5px;padding-top:2px;padding-right:10px;"><button type="button" name="submit_personal" id="submit_personal" class="btn" onClick=JAVASCRIPT:ShowHidePanel("replyTxt'+ComItem.id+'"); style="margin-right:2px;">Cancel</button><button type="button" name="submit_personal" id="submit_personal" class="btn">Post</button></div></div>';

	}
	if(Comments.length>0)
	document.getElementById('show_comments').innerHTML = div_content;
         else
         	document.getElementById('show_comments').innerHTML = 'كن أول من يعلق على هذا الملف';
	
	var nlinks = parseInt(commentsTotal[0]/10);
	var dv_links = '<div style="float:left;">';
	if(nlinks){
		for(var j=1;j<=nlinks;j++){
		 if(ComObj.page==j){
			var selected_page="";
		 }
		 else{
			selected_page="border:1px solid #666666";
		 }
	  dv_links += '<a style="color:#0066FF;'+ selected_page+'" href="#!section=watch&f='+document.getElementById("f").value+'" id="'+j+'" onClick="pagination(this.id)">&nbsp;'+(j)+'&nbsp;</a>&nbsp;';
		 } 
	 }
	dv_links += '</div><div id="cmnts_loading" align="center" style="float:right;width:200px;"></div>';
	document.getElementById("pg_links").innerHTML = dv_links;
}
	
function pagination(number){
	document.getElementById('cmnts_loading').innerHTML ="تحميل...";
	mySWF.callSWF("readComments", ["JS", document.getElementById('f').value, number]);
}
