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

function member_summary_button(x_button)
{
	if (x_button == 'filter_reset')
	{
		document.getElementById('filter_user').value 		= 0;
		document.getElementById('filter_location').value 	= 0;
		document.getElementById('filter_status').value 		= 0;

		var qry = 'modules/member/member_summary.php';
		qry += '?filter_type=' 			+ '0';
		qry += '&filter_user=' 			+ '0';
		qry += '&filter_location='		+ '0';
		qry += '&filter_status=' 		+ '0';

		ajaxFunction(qry,'ajax_body');
		return false;
	}
	if (x_button == 'filter_apply')
	{
		var qry = 'modules/member/member_summary.php';
		qry += '?filter_type=' 			+ document.getElementById('filter_type').value;
		qry += '&filter_user=' 			+ document.getElementById('filter_user').value;
		qry += '&filter_location=' 		+ document.getElementById('filter_location').value;
		qry += '&filter_status=' 		+ document.getElementById('filter_status').value;

		ajaxFunction(qry,'ajax_body');
		return false;
	}
	
	if (x_button == 'add_new')
	{
		if (!isSelected('user_type_id', 'Please select a User Type'))
			return false;
	
		var qry = 'modules/member/member_detail.php';
		qry += '?mode='  				+ 'insert';
		qry += '&user_type_id=' 		+ document.getElementById('user_type_id').value;

		ajaxFunction(qry,'ajax_body');
		return false;
	}

	if (x_button == 'edit_member')
	{
		var qry = 'modules/member/member_detail.php';
		qry += '?mode='  				+ 'edit';

		ajaxFunction(qry,'ajax_body');
		return false;
	}

	if (x_button == 'with_selected_apply')
	{
		var with_selected = document.getElementById('with_selected').value

		// Test for at least one checked checkbox
		var checkbox_count = 0;
		var id_string = '';
		for (var i=1; i<document.forms[0].elements.length; i++) 
		{
			// Look for check box matches
			if ((document.forms[0].elements[i].type == "checkbox") && (document.forms[0].elements[i].name == "checkbox_id[]")) 
			{
				if (document.forms[0].elements[i].checked == true)
				{
					checkbox_count++;
					id_string = id_string + document.forms[0].elements[i].value + ',';
				}
			}
		}
		
		if (checkbox_count == 0)
		{
			alert('No items selected!\n\nPlease check at least one item');
			document.getElementById('with_selected').value = 0; // Reset Starting Position
			return false;
		}
		
		if (with_selected == 1) // Create SMS
		{
			/// Remove last comma
			id_string = id_string.slice(0, -1)
			
			x_window = "modules/popup/sms_popup.php?mode=insert&checkbox_id=" + id_string;
			var new_window = window.open(x_window,'sms_popup','width=300,height=300,resizable=no,scrollbars=no');
			new_window.focus();
			document.getElementById('with_selected').value = 0; // Reset Starting Position
			return false;
		}
		if (with_selected == 2) // Create Email
		{
			/// Remove last comma
			id_string = id_string.slice(0, -1)
			
			x_window = "modules/popup/email_popup.php?mode=member_general&checkbox_id=" + id_string;
			var new_window = window.open(x_window,'popup','width=300,height=300,resizable=no,scrollbars=no');
			new_window.focus();
			document.getElementById('with_selected').value = 0; // Reset Starting Position
			return false;
		}
		return false;
	}
	else if (x_button == 'select_all')
	{
		// Read through all page elements
		for (var i=0; i<document.forms[0].elements.length; i++) 
		{
			// Look for check box matches
			if ((document.forms[0].elements[i].type == "checkbox") && (document.forms[0].elements[i].name == "checkbox_id[]")) 
			{
				// Copy Sel state to all check boxes
				document.forms[0].elements[i].checked = document.forms[0].checkboxSel.checked;
			}
		}
	}
	return false;
}
-->

