var pid=0;
var action='';
function mover(obj){
	obj.className='inline_div_over';
}
function mout(obj){
	obj.className='inline_div';
}
function blurthis(obj, str){
	if(obj.value==str){
		obj.value='';
		obj.style.color='#333';			
		obj_h=parseInt(2*parseInt(obj.style.height));		
		if(!isNaN(obj_h)){
			obj.style.height=obj_h;
		}	
	}
}
function blurredthis(obj, str){
	if(obj.value==''){
		obj.value=str;
		obj.style.color='gray';
		

		obj_h=parseInt(parseInt(obj.style.height));		
		if(!isNaN(obj_h)){
			obj.style.height=(obj_h/2);
		}
	}
}
function validate_this(obj, str){
	myid=obj.getAttribute('myid');
	val=document.getElementById(myid).value;
	if(val=='' || val==str){
		alert('comment must not be empty');
		return false;
	}
}
function validate_reply(obj, str){
	
	myid=obj.getAttribute('myid');
	val=document.getElementById(myid).value;
	if(val=='' || val==str){
		alert('comment must not be empty');
		return false;
	}
}
function reply_this(obj){
	if(pid!=0){
		prev_dest_obj=document.getElementById(pid);
		dest_obj.innerHTML='&nbsp;';
	}
	pid=obj.getAttribute('myid');
	dest_obj=document.getElementById(pid);	

	frm_str="<form name=frm_comment method=post action='submit_reply.php' onsubmit='return validate_reply(this, \"enter a reply here\");' myid='my_reply'><input type=hidden  id=pid name=pid value=''><input type=hidden id=thread_id name=thread_id value=''>&nbsp;<br><textarea onfocus='blurthis(this, \"enter a reply here\");' onblur='blurredthis(this, \"enter a reply here\");' style='height:50px;' name='my_reply' id='my_reply'>enter a reply here</textarea><br><br style='line-height:5px;'><input type=submit name=submit_btn class=btn value='reply'> <input type=button name=submit_btn class=btn value='cancel' onclick='replace_reply_div();'> <!--&nbsp;&nbsp;<a href='#?'>formating tips</a>--></form>&nbsp;<br>";

	dest_obj.innerHTML=frm_str;
	//assign pid to form element
	document.getElementById('pid').value=pid;	
	document.getElementById('thread_id').value=my_thread_id;

}
function replace_reply_div(){
	document.getElementById(pid).innerHTML='&nbsp;';
	pid=0;
}
function vote_down(obj){
	clicked_obj=obj;	
	myid=obj.getAttribute('myid');
	up_obj=document.getElementById(myid+'_up');
	down_obj=document.getElementById(myid+'_down');
	action='vote';
	r=Math.random();
	makeRequest("vote-discussion.php?id="+myid+"&do=down"+"&r="+r); return;
}
function vote_up(obj){
	clicked_obj=obj;	
	myid=obj.getAttribute('myid');
	up_obj=document.getElementById(myid+'_up');
	down_obj=document.getElementById(myid+'_down');
	action='vote';
	r=Math.random();
	makeRequest("vote-discussion.php?id="+myid+"&do=up"+"&r="+r); return;	
}	
function vote_down_comment(obj){
	clicked_cmt_obj=obj;	
	myid=obj.getAttribute('myid');
	up_cmt_obj=document.getElementById(myid+'_up');
	down_cmt_obj=document.getElementById(myid+'_down');
	action='vote_cmt';
	r=Math.random();
	makeRequest("vote-discussion-comment.php?id="+myid+"&do=down"+"&r="+r); return;
}
function vote_up_comment(obj){
	clicked_cmt_obj=obj;	
	myid=obj.getAttribute('myid');
	up_cmt_obj=document.getElementById(myid+'_up');
	down_cmt_obj=document.getElementById(myid+'_down');
	action='vote_cmt';
	r=Math.random();
	makeRequest("vote-discussion-comment.php?id="+myid+"&do=up"+"&r="+r); return;	
}	
function add_to_watch(obj, thread_id){
	obj.className='hidden_div';
	action='';	r=Math.random();
	makeRequest("add-forum-thread-watchlist.php?id="+thread_id+"&r="+r); return;
}
function flag_forum(obj, thread_id){
	obj.className='hidden_div';
	action='';	r=Math.random();
	makeRequest("flag-forum-thread.php?id="+thread_id+"&r="+r); return;
}
function  flag_forum_comment(obj, comment_thread_id){
	obj.className='hidden_div';
	action='';	r=Math.random();
	makeRequest("flag-forum-comment.php?id="+comment_thread_id+"&r="+r); return;
}
function pop_url(url, w_width, w_height){
	width_=w_width;	height_=w_height;	window.open(url , '','toolbar=no,status=yes,scrollbars,resizable,dependent,width='+width_+',height='+height_+',left=0,top=0');
}
