Ajax.Responders.register({
  onCreate: function() {
    if($('busy') && Ajax.activeRequestCount>0)
      Effect.Appear('busy',{duration:0.5,queue:'end'});
  },
  onComplete: function() {
    if($('busy') && Ajax.activeRequestCount==0)
      Effect.Fade('busy',{duration:0.5,queue:'end'});
  }
});

function replace_element(id1,id2)
{
	document.getElementById(id1).innerHTML = document.getElementById(id2).innerHTML;
		
}
function topic_toggle(id,section_id)
{
	Element.toggle(id);
	new Ajax.Request('/user_topic/toggle/'+id+"?section_id=" + section_id, {asynchronous:true});
}
function find_text_in_element(id1,strFind)
{
	return document.getElementById(id1).innerHTML.search(strFind);
}
function GetInnerHTML(id1,str1)
{
	str1 = document.getElementById(id1).innerHTML;
}
function replace_in_place (strDivPreText, strText,iCount,strTest)
{
	id0 = strDivPreText+"0";
	 if (document.getElementById(id0).innerHTML.indexOf(strTest) == -1)
	 {
		 for (i =0;i<(iCount-1) ;i++)
		{
			id1 = strDivPreText + (4-i);
			id2 = strDivPreText + (3-i);
			replace_element(id1,id2);
		}
		document.getElementById(id0).innerHTML = strText;
	 }
}
function insert(strDivPreText, strText,strTest,strDiv)
{
	 id0 = strDivPreText+"0";
	 strCurrent = document.getElementById(strDiv).innerHTML
	 if (document.getElementById(id0).innerHTML.indexOf(strTest) == -1)
	{
		strCurrent = document.getElementById(strDiv).innerHTML;
		document.getElementById(strDiv).innerHTML = strText+"<div>" + strCurrent + "</div>";
		//new Insertion.Top(strDiv,strText);
	}
	 
}

function lbfocus() {
	username = document.getElementById('user_login');
	password = document.getElementById('user_password');
	if(username.value == 'username' && password.value == 'password') {
		username.value = '';
		username.style.color = 'black';
//		password.value = '';
//		password.style.color = 'black';
	}
}

function lbfocuscomment() {
	username = document.getElementById('user_login_comment');
	if(username.value == 'username') {
		username.value = '';
		username.style.color = 'black';
	}
}