
function selecionaTodosDaDiv(div,defaultValue){
	//Pega elemento pai deste objeto (ex: div)
	var divParent = document.getElementById(div);
	//Neste elemento pegamos todos os inputs
	checks = divParent.getElementsByTagName("input");
	//Para cara elemento adiquirido
	for (i=0;i<checks.length;i++){
		//se for do tipo checkbox
		if (checks[i].type == 'checkbox') {
			//recebe o valor da propriedade checked do elemento clicado
			checks[i].checked = defaultValue;
		}
	}
}

function close_Window(){
	window.close();
}


function atribui_valores(div){
   
   var  tdColor ="td1";
	//var theTable = window.opener.document.getElementById('areas_selecionas');
	var divParent = document.getElementById(div);
	//Neste elemento pegamos todos os inputs
	
	checks = divParent.getElementsByTagName("input");
	//Para cara elemento adiquirido
	for (i=0;i<checks.length;i++){
		if (checks[i].type == 'checkbox' && checks[i].checked==true ) {
			//recebe o valor da propriedade checked do elemento clicado

			var ds_conc = document.getElementById('ds_conc_'+checks[i].value).value;
			var ds_area = document.getElementById('ds_area_'+checks[i].value).value;
			
			var cd_conc = document.getElementById('cd_conc_'+checks[i].value).value;
			var cd_area = document.getElementById('cd_area_'+checks[i].value).value;
			
			var hidden =window.opener.document.createElement('input');
			hidden.type = 'hidden';
			hidden.id='lista';
			hidden.name='lista[]';
			hidden.value= cd_conc+':'+cd_area;
			
			var img =window.opener.document.createElement('img');
			img.src = '../../../../visuais/nucleo/cadastro/basic/imagens/cad_excluir.gif';
			img.id = 'img_'+cd_conc+'_'+cd_area;
			
			
			img.style.cursor="pointer";

			if(window.opener.document.getElementById('tr_'+cd_conc+'_'+cd_area)==null){
			
			    var linha = window.opener.document.getElementById('areas_selecionas').insertRow(window.opener.document.getElementById('areas_selecionas').rows.length);
			    linha.id = 'tr_'+cd_conc+'_'+cd_area;
			    var lin0 = linha.insertCell(0);
			    if (i %2==0)
			    {
			       tdColor = "td1"; 
			       
			    }
			    else
			    {
	             tdColor = "td2"; 
			    }   
			    lin0.appendChild(window.opener.document.createTextNode(ds_conc));
			    lin0.className = tdColor;
			    
			    var lin1 = linha.insertCell(1);
			    lin1.appendChild(window.opener.document.createTextNode(ds_area));
			    lin1.className = tdColor;
			    
			    lin1.appendChild(hidden);
			    
			    var lin2 = linha.insertCell(2);
			    lin2.innerHTML = '<img style="cursor:pointer" src="../../../../visuais/nucleo/cadastro/basic/imagens/cad_excluir.gif" onclick="exclui_valores(this.parentNode.parentNode.rowIndex)">';
			    lin2.className = tdColor;
			}
		}//fecha  if
	}// fecha for
	
}

function exclui_valores(i){
    document.getElementById('areas_selecionas').deleteRow(i-1);
}


function validateForm() { 

	var errors="";
	var cont=0;

   if (!document.form1) {
      return true;
   }

	var situacao = document.form1.situacao;

	for (i=0;i<situacao.length;i++){
		if (situacao[i].type == 'checkbox' && situacao[i].checked==true ) {
			cont = cont+1;
		}
	}
	
	if(cont == 0){
		errors+='- Uma situação deve ser informada.\n';
	}
			
	if(document.form1.lista == undefined){
		errors+='- Um curso/área deve ser informado.\n';
	}
	
	if(document.form1.ds_titulo.value == ""){   
		errors+='- Um título deve ser informado.\n';
	}
	
	if (document.form1.ds_descricao.value.length<=0){
		errors+='- Uma descrição deve ser informada.\n';
	}

		    		
	if (errors) {
		alert('Valores inválidos:\n'+errors);
	}
	document.returnValue = (errors == '');
}


function exclui_arquivo(arq){
	document.form1.arquivo_excluir.value = arq;
	document.getElementById('upload_arquivo').style.display = '';
	document.getElementById('nm_arquivo').style.display = 'none';
}

function envio(pagina){
	window.location.href=pagina;
}



