// JavaScript Document

function SortBy(i,j)
{
	location.href = "/bulletin/" + i + "/" + j;
}

function AdvancedSearch()
{

	if (Element.visible($('SearchPanel')))
	{ 
		Element.hide($('SearchPanel'));
	}else{
		
		$('SearchPanel').style.top = Position.cumulativeOffset($('AdvancedSearch')).top + 15 + "px";
		$('SearchPanel').style.left = Position.cumulativeOffset($('AdvancedSearch')).left + 10 + "px";
		Element.show($('SearchPanel'));	
	}
}

function Inappropriate(x,y)
{
	
	if(y == 0)
	{
		message = "OyaMessage";
	}else if(y == 1){
		message = "ChildMessage" + x;
	}
	
	var box = "<div><b>You are about to report this comment as inappropriate.<b></div><div class=\"YesNo\"><a href=\"JAVASCRIPT:SendInappropriate(" + x + "," + y + ");\">Yes</a>&nbsp;&nbsp;/&nbsp;&nbsp;<a href=\"JAVASCRIPT:NoInappropriate();\">No</a></div>";
	
	var id_box = $('InappropriatePopup');
	
	Element.update(id_box,box);
	
	id_box.style.top = Position.cumulativeOffset($(message)).top + "px";
	id_box.style.left = Position.cumulativeOffset($(message)).left + 500 + "px";
		
	Element.show(id_box);	
}

function SendInappropriate(x,y)
{
	
	var message = '';

	if(y == 0)
	{
		message = "OyaMessage";
	}else if(y == 1){
		message = "ChildMessage" + x;
	}else{
		exit();	
	}
	
	var url = '/js/inappropriate_notify.php';
	var pars = 'id=' + x + '&type=' + y;
		
	var myAjax = new Ajax.Request(
		url, 
	{
		method: 'post', 
		parameters: pars,
		onLoading:function(){
			$(message).innerHTML = '';
			Element.update($('InappropriatePopup'),"<b>Sending...</b>");
		},
		onComplete:function(){
			$(message).innerHTML = '<span class="Notified">Sent</span>';
			Element.update($('InappropriatePopup'),"Sent");
			Element.hide($('InappropriatePopup'));
		}
	});
}

function NoInappropriate()
{
	Element.hide($('InappropriatePopup'));
}

function ShowTerm()
{
	if(Element.visible($('PostTerms')))
	{
		Element.hide($('PostTerms'));
	}else{
		Element.show($('PostTerms'));
	}
					  
}
