bugReport = {};

bugReport.show = function (debugDiv) {
	//hide a bunch of objects that appear in front of the div overlay
	$$('object', 'embed', 'iframe').each(function(node){ node.style.visibility = 'hidden'; });

	Effect.Appear('debugBack', {to: 0.6});
	Effect.Appear(debugDiv);
};

bugReport.hide = function (debugDiv) {
	Effect.Fade(debugDiv);
	Effect.Fade('debugBack');
	setTimeout(function () { $$('object', 'embed', 'iframe').each(function(node){ node.style.visibility = 'visible'; }); }, 1000);
};

bugReport.invert = function (div1, div2) {
	Effect.Fade(div1);
	Effect.Appear(div2);
};

bugReport.isdefined = function (variable)  // warning !!! this works only form variables
{
	return ((typeof(variable) == "undefined") ? false : true);
};

bugReport.reportBug = function () {
	if ($('brUsername')){
		bugParam = {url: document.location, post: POST, get: GET, username: $F('brUsername'), bugMsg: $F('brMsg')};
	} else {
		bugParam = {url: document.location, post: POST, get: GET, bugMsg: $F('brMsg')};
	}
	(new Ajax.Request(URL_ROOT_PATH + 'ajax/bugReport/bugReport.php', {
		method: 'POST',
		parameters: bugParam,
		onSuccess: function(transport) {
			var data = transport.responseText.evalJSON();
			if(data.success) {
				Effect.Fade('debugForm');
				bugReport.show('debugEnd');
				$("bugEnd").innerHTML=data.message;
			} else {
				Effect.Fade('debugForm');
				bugReport.show('debugFailed');
				$("bugFailed").innerHTML=data.message;
			}
		}
	}));
};
