function confirma(hp){
    if (confirm('Deseja realmente excluir este registro?')){
        document.location = hp;
    }
}

function atendimento(root_path) {
	window.open(root_path+"/atendimento/index/", "Atendimento", "status=no, width=500, height=500");
}

function confirmar(hp){
    if (confirm('Deseja realmente apagar esta mensagem?')){
        document.location = hp;
    }
}



/**
 * FUNCOES PARA PERMISSOES
 */

function adicionar(){
	obj = document.formCadastro.areas;
	obj2 = document.formCadastro.selecionados;

	offset = 0;
	len = obj.length;

	for (i=0; i<len; i++){
		if (obj.options[i-offset].selected){
			var opt = document.createElement('option');

			opt.text = obj.options[i-offset].text;
			opt.value = obj.options[i-offset].value;

			try {
				obj2.add(opt,null); // standards compliant
			}
			catch(ex) {
				obj2.add(opt); // IE only
			}


			obj.remove(i-offset);
			offset = offset + 1;
		}
	}
}

function deletar(){
	obj = document.formCadastro.areas;
	obj2 = document.formCadastro.selecionados;

	offset = 0;
	len = obj2.length;

	for (i=0; i<len; i++){
		if (obj2.options[i-offset].selected){
			var opt = document.createElement('option');
			opt.text = obj2.options[i-offset].text;
			opt.value = obj2.options[i-offset].value;

			try {
				obj.add(opt,null); // standards compliant
			}
			catch(ex) {
				obj.add(opt); // IE only
			}

			obj2.remove(i-offset);
			offset = offset + 1;
		}
	}
}

function enviar(){
	obj = document.formCadastro.selecionados;

	perm = "";
	virgula = "";

	for (i=0; i<obj.length; i++){
		perm = perm + virgula + obj.options[i].value;
		virgula = ";";
	}

	document.formCadastro.selec.value = perm;
	return true;
}
