function blogEdit(item_id,user_name,post_name) {
	document.getElementById("action").value = "";
	document.getElementById("return").value = "edit_form";
	document.getElementById("item_id").value = item_id;
	if (user_name && post_name)
	{
		document.getElementById("item_name").value = "עריכת התגובה של "+user_name+" לפוסט '"+post_name+"':";
	}
	document.getElementById("postForm").submit();
}

function blogDelete(item_id) {
	document.getElementById("action").value = "delete";
	document.getElementById("return").value = "redirect";
	document.getElementById("item_id").value = item_id;
	document.getElementById("postForm").submit();
}

function blogCompose() {
	document.getElementById("action").value = "";
	document.getElementById("return").value = "post_form";
	document.getElementById("postForm").submit();
}

var sent = 0;
function submitReply(text_id,item_id)
{
	if (sent) return;
	
	frm = document.getElementById("replyForm");
	frm.item_text.value = document.getElementById(text_id+"_text").value;
	frm.send_mail.value = document.getElementById(text_id+"_send_mail").value;
	frm.item_id.value = item_id;
	frm.submit();
	sent = 1;
}


function viewImage(url,width,height)
{
	window.open(url,"_blank","resizable=1,scrollbars=1,location=0,toolbar=0,width="+width+
						",height="+height+"");
}


function onReturnText(req, text_id) 
{
	if (this.req.readyState == 4) 
	{
		var num_of_comments = req.responseText.split("|")[0];
		var successTxt = req.responseText.split("|")[1];
	//alert(num_of_comments);
	if(num_of_comments != 0) {
		$("open_comments").innerHTML =  "<img align=\"absmiddle\" src=\"/design/img/new/num_comments.gif\" alt=\"\" border=\"0\"/> "+ num_of_comments +" תגובות ";
	}
		$("resultMsg"+text_id).innerHTML = successTxt;
		
	}
}

function addComment(text_id, item_id)
{
	item_text = $(text_id+"_text").value;
	send_mail = $(text_id+"_send_mail").value;
	
	var param="action=respond&item_id="+item_id;
	param += "&item_text="+item_text;
	param += "&send_mail="+send_mail;
	param += "&return=status";
	
	//LoadDiv("POST", "/blog.php", param, "resultMsg"+text_id);
	AsyncReq("POST", "/blog.php", param, onReturnText, text_id);
	//alert(response.req.responseText);
	form_reset(text_id+"_form");
	
	//toggle("a"+text_id);
	//window.document.location.reload();
}	


function showComments(item_id, item_channel, item_name) {

	var param="id="+item_id;
	param += "&channel="+item_channel;
	param += "&name="+item_name;
	param += "&return=onlyResponses";
	
	param = encodeURI(param);
	//alert(param);
	LoadDiv("POST", "/blog.php", param, "allComments_"+item_id);
	toggle("allComments_"+item_id);
	
	//toggle("main_reply_"+item_id);
}
	
