
function menuLogin(event){
	event.stopPropogation = true;
	userName = $("#menuLoginUser").attr('value');
	passWord = $("#menuLoginPass").attr('value');
	$.post('action.php', { section: 'login' , username: userName , password: $("#menuLoginPass").attr('value') }, 
	function(g){
		$('error',g).each(function(e){
			alert( ($(this).text()) );
		});
		leftMenuLoad();
		afterLogin();
	});
	// reload the left menu ...
	return false;
}

function menuLogout(){
	$.post('action.php', { section: 'logout' } , function(g){
		$('error',g).each(function(e){
			alert( ($(this).text()) );
		});
		document.location='?';
	});
	
	return false;
}

function leftMenuLoad(){
	$.post('get.php', { section: 'leftmenu' } , function(data){	
		$("#LeftMenuArea").html(data);
		$("#menuLoginForm").bind('submit', {}, menuLogin);
	});
}
function leftMenuOver(id){
	if(!$("#LeftMenuItem" + id).hasClass('act')){
		$("#LeftMenuItem" + id).removeClass('dft');
		$("#LeftMenuItem" + id).addClass('ovr');
	}
}

function leftMenuOut(id){
	if($("#LeftMenuItem" + id).hasClass('ovr')){
		$("#LeftMenuItem" + id).removeClass('ovr');
		$("#LeftMenuItem" + id).addClass('dft');
	}
}

function leftMenuClick(id){
	if(doIng) return;
	$(".act").each(function(g){
		$(this).removeClass('act');
		$(this).addClass('dft');
	});
	$("#LeftMenuItem" + id).removeClass('ovr');
	$("#LeftMenuItem" + id).removeClass('dft');
	$("#LeftMenuItem" + id).addClass('act');
}

function changeEmails(state){
	$.post('get.php', { section: 'leftmenu' , act: 'toggle_email_notifications' } , function(data){	
		$("#LeftMenuArea").html(data);
		$("#menuLoginForm").bind('submit', {}, menuLogin);
	});
}

var LMPageNum = '';
var LMPerPage = '';
var LMFilter = '';

function listmentorsReload(){
	args = new Object();
	if(LMPerPage != ''){
		args.itemsperpage = LMPerPage;
	}
	if(LMPageNum != ''){
		args.pg = LMPageNum;
	}
	if(LMFilter != ''){
		args.filter = LMFilter;
	}
	$.post('listmentors.php', args , function(data){
		$("#ListMentors").html('');
		$("#ListMentors").append(data);
	});
}

function listmentorsPage(pgN){
	LMPageNum = pgN;
	listmentorsReload();
}

function listmentorsPerPage(npPg){
	LMPerPage = npPg;
	// otherwise we will end up somewhere completely random ...
	LMPageNum = '';
	listmentorsReload();
}

function listmentorsFilter(){
	LMFilter = $("#txtFilter").attr('value');
	listmentorsReload();
}

function listmentorsFilterClear(){
	LMFilter = '';
	listmentorsReload();
}

function loadMentorList(){
	newContext("ListMentors");
	$('#ListMentors').load('listmentors.php', {});
	LMPerPage = '';
	LMPageNum = '';
	LMFilter =  '';
}
