function select_cb(id,state,l) {
	var form=document.forms[id];
	for(var i=0;i<form.length;i++) {
		var e=form.elements[i];
		if(e.type=="checkbox" && e.id.substr(0,l.length)==l) e.checked=state; // && e.name.substr(0,2)=="cb") 
	}
}

function table_page(id,p) {
	//var e=document.getElementById("page");
	//e.value=p;
	//table_action(id,"table:page");	
	table_action(id,"table:"+id+":page:"+p);
}

function table_sort(id,sb,st) {
	//var e1=document.getElementById("sortby");
	//e1.value=sb;
	//var e2=document.getElementById("sorttype");
	//e2.value=st;
	//table_action(id,"table:sort");
	table_action(id,"table:"+id+":sort:"+sb+":"+st);
}

function table_filter(id,fb,id_fc,read) {
	//var e1=document.getElementById("filterby");
	//e1.value=fb;
	//var e2=document.getElementById("filtercontent");
	//if(e2) e2.value="";
	//table_action(id,"table:filter");
	var fc=document.getElementById(id_fc);
	if(fc) {
		if(read) fc=fc.value;
		else     {
			fc.value="";
			fc="";
		}
	} else {
		fc="";
	}
	table_action(id,"table:"+id+":filter:"+fb+":"+fc);
}

function table_action(id_form,a) {
	var form=document.forms[id_form];
	for(var i=0;i<form.length;i++) {
		var e=form.elements[i];
		if(e.type=="hidden" && e.id=="__action") e.value=a;
	}
	form.submit();
	//var e=document.getElementById("__action");
	//e.value=a;	
	//document.forms[id_form].submit();
}

function table_action_delete(id_form,msg,l) {
	var form=document.forms[id_form];
	var n=0;
	for(var i=0;i<form.length;i++) {
		var e=form.elements[i];
		if(e.type=="checkbox" && e.id.substr(0,l.length)==l && e.checked) {
			if(n>0) msg+=',';
			msg+="\n";
			msg+="  "+e.value;
			n++;
		}
	}		

	if(n && confirm(msg)) {
		table_action(id_form,"table:"+id_form+":delete");
	}
}

function table_action_delete_pending_accounts(id,msg,l) {
	if( confirm(msg)) {
		table_action(id,"delete_pending");
	}
}

function table_action_check_licenses(id,msg) {
	if( confirm(msg)) {
		table_action(id,"check_licenses");
	}
}

