function updateHelpBar()
{
	new Ajax.Updater('help_bar', 'ajax_handler.php?usereportissuelogic=true&updatereportissuehelpbar=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post" 
	});
}
function updateStep(sid)
{
	new Ajax.Updater('step' + sid + '_main', 'ajax_handler.php?usereportissuelogic=true&getreportissuestep=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post",
	parameters: {step: sid},
	onComplete : function (updatestepsuccess) 
				{
					// $('step' + sid + '_main_content').show();
				}	
	});
	
}
function unsetStep(sid)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true&unsetstep=true', {
	asynchronous: true,
	method: "post",
	parameters: {step: sid},
	onSuccess : function (unsetstepsuccess) 
				{
					updateSteps();
				}	
	});
}
function setStep(sid)
{
	if (sid < 5)
	{
		Effect.Pulsate('step' + sid + '_main_content');
	}
	else
	{
		$('step' + sid + '_main_content_message').innerHTML = 'Please wait a moment ...';
	}
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true&setstep=true', {
	asynchronous: true,
	method: "post",
	parameters: {step: sid},
	onSuccess : function (setstepsuccess) 
				{
					if (sid < 5)
					{
						updateSteps(sid);
					}
					else
					{
						updateStep(5);
						updateHelpBar();
					}
				}	
	});
}

function updateSteps(sid)
{
	for (var cc = (sid + 1); cc <= 5; ++cc)
	{
		updateStep(cc);
	}
	updateStep(sid);
	updateHelpBar();
}
function setProduct(pid)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step1_product: pid},
	onSuccess : function (setproductsuccess) 
				{
					getProduct();
					getEdition();
					getBuild();
					getComponent();
					updateStep(1);
					getCategory();
					updateStep2Button();
				}	
	});
}
function getProduct()
{
	new Ajax.Updater('product_td', 'ajax_handler.php?usereportissuelogic=true&getproduct=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}
function setEdition(eid)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step1_edition: eid},
	onSuccess : function (seteditionsuccess) 
				{
					getProduct();
					getEdition();
					getBuild();
					getComponent();
					updateStep(1);
				}	
	});
}
function getEdition()
{
	new Ajax.Updater('edition_td', 'ajax_handler.php?usereportissuelogic=true&getedition=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}
function setBuild(bid)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step1_build: bid},
	onSuccess : function (setbuildsuccess) 
				{
					getProduct();
					getEdition();
					getBuild();
					updateStep(1);
				}
	});
}
function getBuild()
{
	new Ajax.Updater('build_td', 'ajax_handler.php?usereportissuelogic=true&getbuild=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}
function setIssueType(it_id)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step2_setissuetype: it_id},
	onSuccess : function (setissuetypesuccess) 
				{
					getIssueType();
					updateStep2Button();
				}
	});
}
function getIssueType()
{
	new Ajax.Updater('step2_issuetype', 'ajax_handler.php?usereportissuelogic=true&getissuetype=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}
function setComponent(c_id)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step2_setcomponent: c_id},
	onSuccess : function (setcomponentsuccess) 
				{
					getComponent();
					updateStep2Button();
				}
	});
}
function getComponent()
{
	new Ajax.Updater('step2_component', 'ajax_handler.php?usereportissuelogic=true&getcomponent=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}
function setCategory(cat_id)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step2_setcategory: cat_id},
	onSuccess : function (setcategorysuccess) 
				{
					getCategory();
					updateStep2Button();
				}
	});
}
function getCategory()
{
	new Ajax.Updater('step2_category', 'ajax_handler.php?usereportissuelogic=true&getcategory=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}
function setSeverity(s_id)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step2_setseverity: s_id},
	onSuccess : function (setseveritysuccess) 
				{
					getSeverity();
					updateStep2Button();
				}
	});
}
function getSeverity()
{
	new Ajax.Updater('step2_severity', 'ajax_handler.php?usereportissuelogic=true&getseverity=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}

function updateStep2Button()
{
	new Ajax.Updater('step2_button', 'ajax_handler.php?usereportissuelogic=true&updatestep2button=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}

function addLink()
{
	var params = Form.serialize('rni_step4_add_link');
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: params,
	onSuccess : function (addlinksuccess) 
				{
					$('rni_step4_add_link').reset();
					getLinks();
				}
	});
}

function removeLink(l_id)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step4_removelink: l_id},
	onSuccess : function (removelinksuccess) 
				{
					getLinks();
				}
	});
}

function getLinks()
{
	new Ajax.Updater('step4_linklist', 'ajax_handler.php?usereportissuelogic=true&getlinks=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}

function removeFile(f_id)
{
	new Ajax.Request('ajax_handler.php?usereportissuelogic=true', {
	asynchronous: true,
	method: "post",
	parameters: {rni_step4_removefile: f_id},
	onSuccess : function (removefilesuccess) 
				{
					getFiles();
				}
	});
}

function getFiles()
{
	new Ajax.Updater('step4_filelist', 'ajax_handler.php?usereportissuelogic=true&getfiles=true', {
	asynchronous: true,
	evalScripts: true,
	method: "post"
	});
}
