
function redir(loc){
	document.location="?"+loc;
}

//mouse over fx
function color(obj,col){
	obj.style.background=col;
}

//var _W=0;
function f_open(val){
	file="get.php?id="+val;
	var _W=window.open(file,'w','width=100,height=100');
		_W.focus();
    	_W.moveTo(100,50);
}

function viewFileDiv(who){
	for(a=0; a<divIds.length; a++){ hideDiv(divIds[a]); }
	
	showDiv(who+"_div");
	//document.newroot.rootdir.focus(true);
	c=document.getElementById(who+"_comm");
	c.focus(true);
}

function addFile(id){
	var comment=document.getElementById(id+"_comm").value;
	var fn=document.getElementById(id+"_fn").value;
	
	redir("f_name="+fn+"&f_descr="+comment+"&g_id="+g_id+"&kaction=newfile&add=true");
}



//------------------------------------[ ACCESS LIST JAVASCRIPT PART ]
var isSelected=false;
//var color is set by php

//mouse over event 
function selColor(obj){
	for (a=0; a<=acl.length; a++){
		if(acl[a]==obj.id){
			obj.style.background=selcol;
			isSelected=true;
			return;
		}else{
			obj.style.background=overcolor;
			isSelected=false;		
		}
	}
}

//mouse out event
function selOut(obj){
	obj.style.background='';
	selectDefined();
}

//colour all existent tables in the page if they're in acl.
function selectDefined(){
	for(a=0; a<=acl.length; a++){
			obj=document.getElementById(acl[a]);
			if(obj)
				obj.style.background=selcol;
	}
}

//Xor function to add/remove id in acl;
function xorAcl(obj){
	for (a=0; a<=acl.length; a++){
		if(acl[a]==obj.id){
			acl.splice(a,1);
			obj.style.background=overcolor;
			return;
		 }
	}//end for
	acl.push(obj.id);
	acl.sort();
	selectDefined();
}

//Implicit add root dir in list if does not exist in acl.
function addRootIfNotExist(rootId){
	for (a=0; a<=acl.length; a++){
		if(acl[a]==rootId)
			return;
	}
	acl.push(rootId);
	acl.sort();
}

function setAclBtn(){
//?newuid=true&aclUID=7
	var loc="addAcl=true&aclUID="+user_id+"&user_group="+acl;
	redir(loc);
}

function popupPreview(id){
	file="preview.php?uid="+id;
	var _W=window.open(file,'w','width=700,height=650,scrollbars');
		_W.focus();
    	_W.moveTo(20,20);
}

function popupRemoveRA(id){
	file="removeRoot.php?uid="+id;
	var _W=window.open(file,'w','width=700,height=650,scrollbars');
		_W.focus();
    	_W.moveTo(20,20);
}
