function payMentorsFilter()
{
	// apply filtering ...
	filterRole = $("#MentorsFilter").attr('value');
	loadPayableMentors(filterRole);
}

function loadPayableMentors(Role)
{
	args = new Object();
	args.type = 'xml';
	args.section = 'mentorspayments';
	if(Role != 'All'){
		args.role = Role;
	}
	$("#MentorsToPayDiv").html('');
	drawPrettyTable("MentorsToPayDiv", "Mentors That Need Paying", "MentorsToPay");
	$('#MentorsToPay').append('<tr><td class="hdr">Full Name</td><td class="hdr">Country</td><td class="hdr">State</td><td class="hdr">City</td><td class="hdr">Zip</td><td class="hdr">Method of Payment</td><td class="hdr">Payment Due</td></tr>');
	
	$.post('get.php', args , function(data){
		i = 0;
		$('row', data).each(function(a){
			rowclass = i % 2 ? "evenrow" : "oddrow";
			
			rowContents = '<tr><td class="'+rowclass+'"><a href="#" onclick="viewProfile(\''+$(this).find('name').find('uid').text()+'\')">'+$(this).find('name').find('text').text()+'</a></td>' +
			'<td class="'+rowclass+'">' + $(this).find('address').find('country').text() + '</td>' +
			'<td class="'+rowclass+'">' + $(this).find('address').find('state').text() + '</td>' +
			'<td class="'+rowclass+'">' + $(this).find('address').find('city').text() + '</td>' +
			'<td class="'+rowclass+'">' + $(this).find('address').find('zip').text() + '</td>' +
			'<td class="'+rowclass+'">' + $(this).find('payment').find('method').text() + '</td>' +
			'<td class="'+rowclass+'" style="text-align: right">' + $(this).find('total').text() + '</td>' + 
			'</tr>';
			$('#MentorsToPay').append(rowContents);
			i++;
		});
	});
	if(Role != 'All'){
		$("#MentorsOptions").html('Download Payment File: <a href="generatefile.php?method='+Role+'">here</a>');
	}
}

function payMentors()
{
	newContext("Mentors");
	// first a search box
	$("#Mentors").append('<div id="MentorsSearch"></div>');
	$("#MentorsSearch").append('Show: <select id="MentorsFilter" onchange="payMentorsFilter()"><option value="All">All</option><option value="Paypal">Paypal</option><option value="Payoneer">Payoneer</option><option value="WesternUnion">Western Union</option></select>');
	// the matching mentors
	$("#Mentors").append('<div id="MentorsToPayDiv"></div>');
	// the options for these mentors
	$("#Mentors").append('<div id="MentorsOptions"></div>');
	loadPayableMentors('All');
}

