var blnImagesSaved = false;
var strReportURL = "http://partners.secalc.com/get_report.php";

/**
* Set values for individual data fields as Total Capacity field is being entered
*/

setSecondaryFields = function()
{
	var data_total = $F('data_total');
	
	//alert(data_total);
	
	$('data_db').value 		= (data_total / 2.5).round().toString();
	$('data_collab').value 	= (data_total / 6.666).round().toString();
	$('data_files').value 	= (data_total / 5).round().toString();
	$('data_virtual').value = (data_total / 9.0909).round().toString();
	$('data_eng').value 	= (data_total / 20).round().toString();
	$('data_appdev').value 	= (data_total / 12.5).round().toString();
	$('data_other').value	= (data_total / 100).round().toString();
}

/**
* Update Total Capacity field when secondary fields are updated
*/

setTotalField = function()
{
	var data_total = parseFloat($F('data_db'));
	data_total += parseFloat($F('data_collab'));
	data_total += parseFloat($F('data_files'));
	data_total += parseFloat($F('data_virtual'));
	data_total += parseFloat($F('data_eng'));
	data_total += parseFloat($F('data_appdev'));
	data_total += parseFloat($F('data_other'));
	
	$('data_total').value = data_total.toString();
}


/**
* set flag indicating that image version of chart has been saved
*/

setImagesSaved = function()
{
	blnImagesSaved = true;	
}

/**
* Redirect to registration form only after chart image has been saved
*
* @param type string Specifies which form the user submitted
*/

goToRegForm = function(saveMsg)
{
	// DEBUG
	//blnImagesSaved = true;
	
	$("getReportLink1").innerHTML = '<strong><img src="/secalc/images/wait_icon.gif" width="11" height="11" alt="" /> '+saveMsg+'</strong>';
	//$("getReportLink2").innerHTML = '<strong><img src="img/wait_icon.gif" width="11" height="11" alt="" /> '+saveMsg+'</strong>';
	//$("getReportLink3").innerHTML = '<strong><img src="img/wait_icon.gif" width="11" height="11" alt="" /> '+saveMsg+'</strong>';
	
	new PeriodicalExecuter(function(pe)
	{		
		if (blnImagesSaved == true)
		{
			pe.stop();
			
			// redirect to reg form
			window.location = strReportURL;
		}
	}
	, 1);
}