function popup(name, file, width, height) {
	scrolling = true;
	window.name = "main";

   	width = Math.min(width, screen.width-40);
	height = Math.min(height, screen.height-60);

	wleft = (screen.width - width) / 2;
	wtop  = (screen.height - height) / 2 - 20;

	win = window.open(file, name, "width=" + width + ",height=" + height + ",left=" + wleft + ",top=" + wtop + ",location=no,menubar=no,resizable=no,scrollbars=" + ((scrolling)?'yes':'no') + ",status=no,toolbar=no");
	win.focus();
}

function login(p){
	popup('login', 'index.php?action=login&t='+p, 300, 150);
}
function add_user(p){
	if(p>0){
		popup('add_user', 'index.php?action=edit_user&id='+p, 300, 400);
	}else{
		popup('add_user', 'index.php?action=add_user', 300, 400);
	}
}
function add_ctg(v,p){
	if(v=='add'||v=='edit'){
		popup('add_ctg', 'index.php?id='+p+'&action='+v+'_node', 300, 360);
	}
}
function add_img(p,c){
	if(p>0){
		popup('add_img', 'index.php?action=edit_item&node_id='+c+'&id='+p, 350, 470);
	}else{
		popup('add_img', 'index.php?action=add_item&node_id='+c+'&id='+p, 350, 470);
	}
}
function move (p,c){
	popup('move', 'index.php?action=move_item&ctg='+c+'&id='+p, 300, 200);
}
function addcom(c,p){
	if(c>0){
		popup('addcom', 'index.php?action=edit_comment&item_id='+p+'&comm_id='+c, 300, 250);
	}else{
		popup('addcom', 'index.php?action=add_comment&item_id='+p, 300, 250);
	}
}
function addgroup(p){
	if(p>0){
		popup('addgroup', 'index.php?action=edit_group&id='+p, 260, 130);
	}else{
		popup('addgroup', 'index.php?action=add_group&id='+p, 260, 130);
	}
}
function dropuser(id,name) {
	ans=window.confirm("Delete: are you sure you want to delete user "+name+"?");
	if(ans) {
		document.galery.del_user.value=1
		document.galery.userid.value=id
		document.galery.submit();
	}
}
function dropgroup(id,name) {
	ans=window.confirm("Delete: are you sure you want to delete group "+name+"?");
	if(ans) {
		document.galery.del_group.value=1
		document.galery.groupid.value=id
		document.galery.submit();
	}
}


