<!--
function transport_detail_freight_onclick(x_button)
{
	if (x_button == 'save')
	{
		if(transport_detail_freight_validate() == false)
			return;
		
		ajax_showdiv('div_form_2');
		ajax_showdiv('div_transport_detail_freight_summary_load');

		var x_id = document.getElementById('freight_id').value;

		var div = 'div_popup_2';
		var url = 'modules/transport/transport_detail_freight.php';
		var param = 'mode=update';

		param += '&freight_id=' 		+ x_id;
		param += '&freight_link_id=' 	+ document.getElementById('freight_link_id').value;
		param += '&freight_ref=' 		+ encodeURIComponent(document.getElementById('freight_ref').value);
		param += '&freight_items=' 		+ document.getElementById('freight_items').value;
		param += '&freight_type_id=' 	+ document.getElementById('freight_type_id').value;
		param += '&freight_type_other=' + encodeURIComponent(document.getElementById('freight_type_other').value);
		param += '&freight_length=' 	+ document.getElementById('freight_length').value;
		param += '&freight_width=' 		+ document.getElementById('freight_width').value;
		param += '&freight_height=' 	+ document.getElementById('freight_height').value;
		param += '&freight_volume=' 	+ document.getElementById('freight_volume').value;
		param += '&freight_volume_total=' 	+ document.getElementById('freight_volume_total').value;
		param += '&freight_weight=' 	+ document.getElementById('freight_weight').value;
		param += '&freight_desc=' 		+ encodeURIComponent(document.getElementById('freight_desc').value);

		var callback = "transport_detail_freight_callback();";

		ajax_processRequestPost(url,param,div,callback)
		return false;
	}
	return false;
}
function transport_detail_freight_callback()
{
	div    = "div_transport_detail_freight_summary";
	url    = "modules/transport/transport_detail_freight_summary.php";
	param  = "mode=edit";
	param += "&transport_id=" + document.getElementById('transport_id').value
;
	callback  = "transport_detail_action('transport_rate','');";
	callback += "Popup.hide('div_popup_2');";
	
	ajax_processRequestPost(url,param,div,callback)
	return false;
}
function transport_detail_freight_calc()
{
	transport_detail_freight_format();
	
	// Calculate Volume + Total Volume
	var items = document.getElementById('freight_items').value;
	var length = document.getElementById('freight_length').value;
	var width = document.getElementById('freight_width').value;
	var height = document.getElementById('freight_height').value;

	var volume = (parseFloat(length)/1000) * (parseFloat(width)/1000) * (parseFloat(height)/1000); 
	var volume_total = parseFloat(volume) * parseFloat(items); 

	document.getElementById('freight_volume').value = volume.toFixed(3);;
	document.getElementById('freight_volume_total').value = volume_total.toFixed(3);;
}

function transport_detail_agent_fill_address(
					obj_company,value_company,
					obj_account,value_account,
					obj_name,value_name,
					obj_address,value_address,
					obj_sub,value_sub,
					obj_area_id,value_area_id,
					obj_state,value_state,
					obj_post,value_post,
					obj_phone,value_phone,
					obj_mobile,value_mobile,
					obj_fax,value_fax,
					obj_notes,value_notes,
					div)
{
	$('#' + obj_company).val(value_company);
	$('#' + obj_account).val(value_account);
	$('#' + obj_name).val(value_name);
	$('#' + obj_address).val(value_address);
	$('#' + obj_sub).val(value_sub);
	$('#' + obj_area_id).val(value_area_id);
	$('#' + obj_state).val(value_state);
	$('#' + obj_post).val(value_post);
	$('#' + obj_phone).val(value_phone);
	$('#' + obj_mobile).val(value_mobile);
	$('#' + obj_fax).val(value_fax);
	$('#' + obj_notes).val(value_notes);
	setTimeout("$('#" + div + "').hide();", 200);
	
	// Refresh Rates/Costs
	transport_detail_agent_get_rates();
}

function transport_detail_freight_validate()
{
//	if (!isEmpty('freight_ref', 'Please enter a \'Reference\''))
//		return false;

//	if (!isSelected('freight_items', 'Items cannot be Zero'))
//		return false;

	if (document.getElementById('freight_type_id').value == 4)
	{
		if (!isEmpty('freight_type_other', 'Please enter an \'Other\' note'))
			return false;
	}

	// All Good.
	return true;
}

function transport_detail_freight_highlight()
{
	var x_color = '#99FF99'; // Green
//	index_bg_color('freight_ref',x_color);
	index_bg_color('freight_items',x_color);
	index_bg_color('freight_length',x_color);
	index_bg_color('freight_width',x_color);
	index_bg_color('freight_height',x_color);
	index_bg_color('freight_weight',x_color);
	index_bg_color('freight_type_other',x_color);
}

function transport_detail_freight_format()
{
	index_conv_dec('freight_items','0');
	index_conv_dec('freight_length','0');
	index_conv_dec('freight_width','0');
	index_conv_dec('freight_height','0');
	index_conv_dec('freight_volume','3');
	index_conv_dec('freight_volume_total','3');
	index_conv_dec('freight_weight','1');

	if (document.getElementById('freight_type_id').value != 4)
		document.getElementById('div_freight_type_id').style.visibility = 'hidden';
	else
		document.getElementById('div_freight_type_id').style.visibility = 'visible';
	
}
function transport_detail_freight_focus()
{
	document.getElementById('freight_ref').focus();
}
function transport_detail_freight_onload(mode)
{
	if ((mode == 'insert') || (mode == 'edit') || (mode == 'view'))
		ajax_showpopup('div_popup_2','');

	transport_detail_freight_highlight();
	transport_detail_freight_format();
	transport_detail_freight_focus();
	return;
}
-->
