<!--
//  Title:       Region Summary
//  Developer:   Wade McDonough
//  Verion:      1.0
//  Date:        3 Nov 2006
//  Description: 
// 
/////////////////////////////

function staff_detail_onclick(x_button)
{
	if (x_button == 'save')
	{
		if(staff_detail_validate() == false)
			return;
		
		ajax_showdiv('div_form_1');

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

		var url = 'modules/staff/staff_detail.php';

		var param = 'mode=update';
		param += '&user_id=' 			+ x_id;
		param += '&user_status_id=' 	+ document.getElementById('user_status_id').value;
		param += '&user_type_id=' 		+ document.getElementById('user_type_id').value;
		param += '&user_notes=' 		+ encodeURIComponent(document.getElementById('user_notes').value);
		param += '&user_client_id=' 	+ '0';

		param += '&user_name=' 			+ encodeURIComponent(document.getElementById('user_name').value);
		param += '&user_status_id=' 	+ document.getElementById('user_status_id').value;
		param += '&user_email='			+ document.getElementById('user_email').value;
		param += '&user_username='		+ encodeURIComponent(document.getElementById('user_username').value);
		param += '&user_password='		+ encodeURIComponent(document.getElementById('user_password').value);
		param += '&user_address=' 		+ encodeURIComponent(document.getElementById('user_address').value);
		param += '&user_suburb='		+ encodeURIComponent(document.getElementById('user_suburb').value);
		param += '&user_state_id='		+ document.getElementById('user_state_id').value;
		param += '&user_postcode='		+ document.getElementById('user_postcode').value;
		param += '&user_mobile='		+ document.getElementById('user_mobile').value;
		param += '&user_phone_1='		+ document.getElementById('user_phone_1').value;
		param += '&user_phone_2='		+ document.getElementById('user_phone_2').value;
		param += '&user_phone_3='		+ document.getElementById('user_phone_3').value;
		param += '&user_fax='			+ document.getElementById('user_fax').value;
		param += '&user_commission='	+ document.getElementById('user_commission').value;

		var div = 'div_popup_1';
		var callback = "index_location('setup', 'staff', 'summary', '" + x_id + "')";
		ajax_processRequestPost(url,param,div,callback)
		return false;
	}
	return false;
}

function staff_detail_validate()
{
	if (!isEmpty('user_name', 'Please enter a \'Name\''))
		return false;

	if (!isSelected('user_type_id', 'Please select a \'Type\''))
		return false;

	if (!isEmpty('user_username', 'Please enter a \'Username\''))
		return false;

	if (!isEmpty('user_password', 'Please enter an \'Password\''))
		return false;

	if (!isEmpty('user_mobile', 'Please enter a \'Mobile\''))
		return false;

	// All Good.
	return true;
}
function staff_detail_highlight()
{
	index_bg_color('user_name','#99FF99');
	index_bg_color('user_type_id','#99FF99');
	index_bg_color('user_username','#99FF99');
	index_bg_color('user_password','#99FF99');

	index_bg_color('user_status_id','#99FF99');

	index_bg_color('user_mobile','#99FF99');
}
function staff_detail_format()
{
	index_conv_dec('user_commission','2');
}
function staff_detail_onload(id)
{
	if ((id == 'insert')  || (id == 'edit') || (id == 'view'))
		ajax_showpopup('div_popup_1','div_result');

	staff_detail_highlight();
	staff_detail_format();
}
-->
