He.Bootstrap('He.Application.Report');

He.Application.Report.ShowList = function()
{
	if(!He.Application.Report.DrawerContent)
	{
		He.Application.Report.DrawerContent = document.createElement('div');
	}

	He.Framework.Ajax.Update(He.Application.Report.DrawerContent,'/report:list',{tl:3,from:He.Framework.Nav.MakeSolid(document.location.href)});
	He.Framework.Drawer.Show(He.Application.Report.DrawerContent);

	return false;
}

He.Application.Report.ShowForm = function()
{
	if(!He.Application.Report.DrawerContent)
	{
		He.Application.Report.DrawerContent = document.createElement('div');
	}

	He.Framework.Ajax.Update(He.Application.Report.DrawerContent,'/report:form',{tl:3,from:He.Framework.Nav.MakeSolid(document.location.href)});
	He.Framework.Drawer.Show(He.Application.Report.DrawerContent);

	return false;
}

He.Application.Report.Abort = function()
{
	He.Framework.Drawer.Hide.defer();

	if(!He.IsUndefined(He.Application.Report.DrawerContent))
	{
		delete He.Application.Report.DrawerContent;
		He.Application.Report.DrawerContent = null;
	}

	return false;
}

He.Application.Report.Submit = function(_form)
{
	_form = $(_form);
	if(
		$F(_form['bug_summary']) == '' ||
		$F(_form['bug_description']) == '' /*||
		$F(_form['bug_category']) == 'Please select one'*/
	){
		He.Application.Report.Abort();
		He.Framework.Feedback.Warning('Please fill all the form','Incomplete form');
		return false;
	}

	if(He.IsObject(He.RConsole))
	{
		$('bug_dbg').value = Object.toJSON(He.RConsole);
	}
	He.LogClear();

	$('bug_from').value = He.Framework.Nav.MakeSolid(document.location.href);

	He.Framework.Ajax.PostForm(_form);
	He.Application.Report.Abort();

	return false;
}

