function addGroups(){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=addGroups',true)
		xmlhttp.send(null)
	}
}

function addGroupsNow(){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=addGroupsNow&group_name='+document.getElementById("group_name").value+'&description='+document.getElementById("description").value+'&id='+document.getElementById("id").value,true)
		xmlhttp.send(null)
	}
}

function editGroups(id){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=editGroups&id='+id,true)
		xmlhttp.send(null)
	}
}

function editGroupsNow(id){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=editGroups&group_name='+document.getElementById("group_name").value+'&description='+document.getElementById("description").value+'&id='+id,true)
		xmlhttp.send(null)
	}
}

function deleteGroup(id){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=deleteGroup&id='+id,true)
		xmlhttp.send(null)
	}
}

function addUsers(){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=addUsers',true)
		xmlhttp.send(null)
	}
}

function addUsersNow(){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		var username=document.getElementById('username').value
		var password='';
		if(document.getElementById('password').value!=''){
			password=MD5(document.getElementById('password').value)
		}
		var email=document.getElementById('email').value
		var name=document.getElementById('name').value
		var group_id=document.getElementById('group_id').value
		var id=document.getElementById('id').value
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=addUsersNow&username='+username+'&name='+name+'&email='+email+'&group_id='+group_id+'&password='+password+'&id='+id,true)
		xmlhttp.send(null)
	}
}

function editUsers(id){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
				
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=editUsers&id='+id,true)
		xmlhttp.send(null)
	}
}

function deleteUser(id){
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
				
		xmlhttp.open("GET",wwwroot+'ajax/?module=user&action=deleteUser&id='+id,true)
		xmlhttp.send(null)
	}
}

function setGroup(group_id){
	
	xmlhttp = checkBrwser()
	if(xmlhttp){
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("editDataDiv").innerHTML=xmlhttp.responseText
				document.getElementById("editDataDiv").style.visibility='visible'
				document.getElementById("loadDiv").innerHTML=''
			}else{
				requestNotReady()
			}
		}
		
		xmlhttp.open("GET",wwwroot+'ajax/?module=users&action=permissions&group_id='+group_id,true)
		xmlhttp.send(null)
	}
}

function stopPermission(msg){
	document.getElementById('msg').innerHTML=msg
}
