// JavaScript Document
//login
function loginResponse(oReq){
	if(oReq.responseText=='true'){
		location.reload();
	}else{
		document.getElementById('result').innerHTML=oReq.responseText;
	}
}
function login(username,password){
	preLoader();
	new Ajax.Request('inc/members.php?do=login&username='+encodeURIComponent(username)+'&password='+encodeURIComponent(password),{method:'get',onCreate: preLoader,onComplete: loginResponse});
}
//logout
function logout(){
	new Ajax.Request('inc/members.php?do=logout',{method:'get',onComplete: loginResponse});
}
//
function buildUsers(data,row,id){
	tabLoader();
	new Ajax.Request('inc/members.php?do=build&data='+encodeURIComponent(data)+'&row='+encodeURIComponent(row)+'&id='+encodeURIComponent(id),{method:'get',onComplete: tabResponse});
}
function createUser(username,password,email,department){
	tabLoader();
	new Ajax.Request('inc/members.php?do=create&username='+encodeURIComponent(username)+'&password='+encodeURIComponent(password)+'&email='+encodeURIComponent(email)+'&department='+encodeURIComponent(department),{method:'get',onComplete: tabResponse});
}
function viewProfile(id){
	preLoader();
	new Ajax.Request('inc/members.php?do=profile&id='+encodeURIComponent(id),{method:'get',onComplete: getResponse});
}
function updateProfile(id,table,row,data){
	preLoader();
	new Ajax.Request('inc/members.php?do=updateProfile&id='+encodeURIComponent(id)+'&table='+encodeURIComponent(table)+'&row='+encodeURIComponent(row)+'&data='+encodeURIComponent(data),{method:'get',onComplete: getResponse});
}
function buildDept(){
	preLoader();
	new Ajax.Request('inc/members.php?do=buildDept',{method:'get',onComplete: getResponse});
}
function addDept(name,desc,num1,num2,num3,num4,num5,num6){
	preLoader();
	new Ajax.Request('inc/members.php?do=newDept&name='+encodeURIComponent(name)+'&desc='+encodeURIComponent(desc)+'&num1='+encodeURIComponent(num1)+'&num2='+encodeURIComponent(num2)+'&num3='+encodeURIComponent(num3)+'&num4='+encodeURIComponent(num4)+'&num5='+encodeURIComponent(num5)+'&num6='+encodeURIComponent(num6),{method:'get',onComplete: getResponse});
}
function showDept(id){
	preLoader();
	new Ajax.Request('inc/members.php?do=showDept&id='+encodeURIComponent(id),{method:'get',onComplete: getResponse});
}
function updateDept(id,row,data){
	preLoader();
	new Ajax.Request('inc/members.php?do=updateDept&id='+encodeURIComponent(id)+'&row='+encodeURIComponent(row)+'&data='+encodeURIComponent(data),{method:'get',onComplete: getResponse});
}
function delUser(id){
	preLoader();
	new Ajax.Request('inc/members.php?do=delUser&id='+encodeURIComponent(id),{method:'get',onComplete: getResponse});
}
function delDept(id){
	preLoader();
	new Ajax.Request('inc/members.php?do=delDept&id='+encodeURIComponent(id),{method:'get',onComplete: getResponse});
}
