var _open = false, _form = false, _close = false;
var duration = 600;

function initPage()
{

	_open = document.getElementById('ask-question');
	_form = document.getElementById('right-form-div');
	_form_sub = document.getElementById('right-form');
	_close = document.getElementById('up-down');
	
	if(_form && _form_sub)
	{
		_form.moofx = new Fx.Styles('right-form-div',{duration:duration,onStart: function(){toggle_form()},onComplete: function(){hide_form()}});	
		_form_sub.moofx = new Fx.Styles('right-form',{duration:duration});	
		_form._height = _form_sub.offsetHeight;
		
		if(_form.className.indexOf("active") != -1)
		{
			_form.is_oppened = true;
			_form.moofx.set({'height': _form._height})
		}
		else
		{
			_form.is_oppened = false;
			_form.style.display = "none";		
			_form.moofx.set({'height': 0})
			_form_sub.moofx.set({'top': (-1)*_form._height})
		}
	}	
	
	if(_open)
	{
		_open.onclick = function()
		{
			if(!_form.is_oppened)
			{
				_form.moofx.start({'height':[0,_form._height]});
				_form_sub.moofx.start({'top':[(-1)*_form._height,0]});
			}
		}
	}

	if(_close)
	{
		_close.onclick = function()
		{
			if(_form.is_oppened)
			{
				_form.moofx.custom({'height':[_form._height,0]});
				_form_sub.moofx.start({'top':[0,(-1)*_form._height]});
			}
		}
	}
	
	
}

function toggle_form()
{
	if(_form)
	{
		_form.is_oppened = !_form.is_oppened;
		_form.style.display = "block";
	}
}

function hide_form()
{
	if(_form && !_form.is_oppened)
	{
		_form.style.display = "none";
	}	
}

if (window.attachEvent){
	window.attachEvent("onload", initPage);
	}
else if (window.addEventListener){
	window.addEventListener("load", initPage, false);
	}