/* -----------------------------------------------------------------------------
	myQuiltGenie - NAME TYPE - scripts
----------------------------------------------------------------------------- */
var fab_width	= 42;

//	calc_block(size, num);
function calc_block(size, num) 
{
	var strip1_width	= (size / 4) + 0.5, 
		strip2_width	= ((size / 8) * 3) + 0.5, 
		num1			= num * 4, 
		num2			= num * 8, 
		fab1_strip1		= calc_strips(strip2_width, num1), 
		fab2_strip1		= calc_strips(strip1_width, num), 
		fab2_strip2		= calc_strips((strip1_width + 1), num1);
	fab_width	-= ((strip1_width + 1) / 2);
	fab1_strip1	+= calc_strips((strip1_width + 1), (num1/2));
	fab_width	+= ((strip1_width + 1) / 2);
	document.getElementById('mgq_info').innerHTML	= num + ' - ' + format_fraction(size) + '" ' + ((num > 1) ? 'blocks' : 'block') + ' using ' + ((fab_width > 22) ? (fab_width + 1) + '" fabric bolt width' : 'fat quarters') + '.';
	document.getElementById('fab_1').innerHTML	= '&nbsp;- ' + calc_yds_str(strip2_width, fab1_strip1) + format_cut_instr(strip2_width, fab1_strip1, 'square', num1) + ' Also subcut into ' + num1 + ' <a href="#mgq_temp2" style="font-weight: bold;">template B<a> triangles using <a href="#mgq_instr">cutting instructions</a> below.';
	document.getElementById('fab_2').innerHTML	= '&nbsp;- ' + calc_yds_str(((strip1_width * fab2_strip1) + (strip2_width * fab2_strip2))) + format_cut_instr(strip1_width, fab2_strip1, 'square', num) + format_cut_instr(strip2_width, fab2_strip2) + ' Subcut strips into 8 <a href="#mgq_temp1" style="font-weight: bold;">template A<a> triangles using <a href="#mgq_instr">cutting instructions</a> below.';
	document.getElementById('mgq_num_units').innerHTML	= 'Make ' + num1 + ' units.';
	document.getElementById('mgq_num_blocks').innerHTML	= 'Makes ' + num + ' ' + ((num > 1) ? 'blocks' : 'block') + '.';
	document.getElementById('mgq_temp1').style.height	= (strip2_width - 0.5) + 'in';
	document.getElementById('mgq_temp2').style.height	= (strip2_width - 0.5) + 'in';
	//document.getElementById('').innerHTML	= '';
}

//	calc_quilt(size, cols, rows);
function calc_quilt(size, cols, rows) 
{
	
}

//	update_page();
function update_page() 
{
	var size	= Number(document.mgq_form.block_size.value), 
		num		= 0, 
		cols	= 0, 
		rows	= 0;
	fab_width	= Number(document.mgq_form.fab_width.value);
	if (document.mgq_form.num_blocks) 
	{
		num		= Number(document.mgq_form.num_blocks.value);
		if (calc_block) 
		{
			calc_block(size, num);
		}
	}
	else 
	{
		cols	= Number(document.mgq_form.num_cols.value);
		rows	= Number(document.mgq_form.num_rows.value);
		if (calc_quilt) 
		{
			calc_quilt(size, cols, rows);
		}
	}
}

//	start_page();
function start_page() 
{
	document.mgq_form.block_size.disabled	= '';
	document.mgq_form.fab_width.disabled	= '';
	if (document.mgq_form.num_blocks) 
	{
		document.mgq_form.num_blocks.disabled	= '';
	}
	else 
	{
		document.mgq_form.num_cols.disabled	= '';
		document.mgq_form.num_rows.disabled	= '';
	}
}
