function desativaItemHome(idItemHome){
	var parametros = 'id='+idItemHome;
	new Ajax.Request(site_url+'/home/desativa/',{ 
			method:'post',
			parameters:parametros,
		  	onSuccess: function(response){
		    	var resultText = response.responseText;
				if(resultText.length>0){
					//alert(resultText);
				}
		    }
		}
	);
}

function enviaResultado(form){
	
	
	var texto = replaceAll(form.texto.value,'\n','<br>');
	
	
	window.envieResultadoform = form;
	var parametros = 'nome='+form.nome.value;
	parametros+='&email='+form.email.value;
	parametros+='&idioma='+form.idioma.value;
	parametros+='&pais='+(form.pais.value.length<=0?"%20":form.pais.value);
	parametros+='&cidade_id='+form.cidade_id.value;
	parametros+='&programa_id='+form.programa_id.value;
	parametros+='&texto='+texto;
	parametros+='&titulo='+form.titulo.value;
	parametros+='&tmpImgName='+form.tmpImgName.value;
	//alert("DEBUG : "+parametros);
	new Ajax.Request(site_url+'/resultado/ajaxSalva/',{ 
			method:'post',
			parameters:parametros,
		  	onSuccess: function(response){
		    	//alert('Dados Enviados com sucesso.');
				sucessoResultado();
				var resultText = response.responseText;
				if(resultText!=""){
					//alert(resultText);
				}
					
				
				
		    }
		}
	);
	
}

function sucessoResultado(){
	//alert("Sucesso Resultado");
	try{window.envieResultadoform.reset();}catch(e){alert(e)}
	document.getElementById('ModalContentSendResult_form').style.display = 'none';
	document.getElementById('ModalContentSendResult_msg').style.display = 'block'; 
}


function enviaInforme(form){
	//alert('Ajax called');
	window.envieInfoform = form;
	var parametros = 'categoria='+form.tipo.value;
	parametros+='&titulo='+form.titulo.value;
	parametros+='&realizacao='+form.realizacao.value;
	parametros+='&periodo='+form.periodo.value;
	parametros+='&expira='+form.expira.value;
	parametros+='&local='+form.local.value;
	parametros+='&telefone='+form.telefone.value;
	parametros+='&email='+form.email.value;
	parametros+='&site='+form.site.value;
	parametros+='&resumo='+form.resumo.value;
	
	new Ajax.Request(site_url+'/informe/ajaxSalva/',{ 
			method:'post',
			parameters:parametros,
		  	onSuccess: function(response){
		    	var resultText = response.responseText;
				
				if(resultText == '0'){
					alert('Erro ao enviar o email');
				}else{
					
					sucessoInforme();
				}
		    }
		}
	);
	
}

function sucessoInforme(){
	try{window.envieInfoform.reset();}catch(e){}
	document.getElementById('ModalContentSendInfo_form').style.display = 'none';
	document.getElementById('ModalContentSendInfo_msg').style.display = 'block'; 
}
function saidaSucessoInforme(){
	tb_remove();
	document.getElementById('ModalContentSendInfoForm').style.display = 'block';
	document.getElementById('ModalContentSendInfoSucess').style.display = 'none'; 
}

function saidaSucessoResultado(){
	tb_remove();
	document.getElementById('ModalContentSendResultForm').style.display = 'block';
	document.getElementById('ModalContentSendResultSucess').style.display = 'none'; 
}

function enviaAmigo(form){
	//alert('Ajax called');
	window.enviaAmigoform = form;
	var parametros = 'seu_nome='+form.seu_nome.value;
	parametros+='&seu_email='+form.seu_email.value;
	parametros+='&am_nome='+form.am_nome.value;
	parametros+='&am_email='+form.am_email.value;
	parametros+='&mensagem_amigo='+form.mensagem_amigo.value;
	parametros+='&link='+window.location.href;
	new Ajax.Request(site_url+'/ajax/emailSender/enviaAmigo/',{ 
			method:'post',
			parameters:parametros,
		  	onSuccess: function(response){
		    	var resultText = response.responseText;
				
				if(resultText == '0'){
					alert('Erro ao enviar o email');
				}else{
					sucessoEnviaAmigo();
				}
		    }
		}
	);
	
}


function sucessoEnviaAmigo(){
	try{window.enviaAmigoform.reset();}catch(e){}
	document.getElementById('ModalContentSendFriend_form').style.display = 'none';
	document.getElementById('ModalContentSendFriend_msg').style.display = 'block'; 
}






function enviaCadastroMailing(form){
	//alert("enviaCadastroMailing :"+form);
	window.formMailing = form.id;
	
	var parametros = 'fullname='+form.fullname.value;
	parametros+='&email='+form.email.value;
	parametros+='&email-button='+form.email_button.value;
	
	
	new Ajax.Request('http://www.iieb.org.br/lista.htm',{
			method:'post',
			parameters:parametros,
		  	onSuccess: function(response){
		    	var resultText = response.responseText;
				var posRs = resultText.indexOf('Sua requisição de inscrição foi recebida e será agilizada logo');
				if(posRs<0){
					alert('Erro ao efetuar o cadastro');
				}else{
					eximeConfirmacaoCadastroMailing();
				}
		    }
		}
	);
}
function eximeConfirmacaoCadastroMailing(){
	//alert(window.formMailing);
	document.getElementById(window.formMailing+"_form").style.display = 'none';
	document.getElementById(window.formMailing+"_success").style.display = 'block';
}
function saidaConfirmacaoCadastroMailing(){
	tb_remove();
	document.getElementById(window.formMailing).reset();
	document.getElementById(window.formMailing+"_form").style.display = 'block';
	document.getElementById(window.formMailing+"_success").style.display = 'none'; 
}



function pegaCidades(dropEstados,drop_cidade_id){
//	alert('id do estado>'+dropEstados.value)
	
	try{
		window.drop_cidade_id = drop_cidade_id;
		var dropCidades = document.getElementById('cidade_id_'+window.drop_cidade_id);
		if (dropEstados.selectedIndex == 0) {
			dropCidades.style.display = 'none';
		}
		else {
			dropCidades.style.display = 'block';
			dropCidades.disabled=false;
			
		}
		
		new Ajax.Request(site_url+'/ajax/cidadeEstadoAjax/listaCidades/'+dropEstados.value,{ 
				method:'get',
				onSuccess: function(responseCidades){
					xmlCidades = responseCidades.responseXML;
					var xmlCidades_txt = responseCidades.responseText;
					//alert(xmlCidades_txt);
					populaComboCidades(xmlCidades);
				}
			}
		);
	}catch(ee){}
}


function populaComboCidades(xmlCidades,drop_cidade_id){
	try{
		//alert('assa');
		var dropCidades = document.getElementById('cidade_id_'+window.drop_cidade_id);
		
		//alert('assa 2 '+xmlCidades);
		var root = xmlCidades.getElementsByTagName('cidades')[0];
		//alert('assa 3'+root);
		var cidades = xmlCidades.getElementsByTagName("cidade");
		//alert('assa 4');
		dropCidades.options.length = cidades.length;
		for (var i = 0 ; i < cidades.length ; i++) {
			var cidade = cidades[i];
			var id  =  cidade.getAttribute("id");
			var nome = cidade.firstChild.nodeValue;
			dropCidades.options[i] =  new Option(nome,id,false);
		}
		
	}catch(e){alert(e)}
}

function enviaContato(form){
	//alert('Ajax called');
	window.envieContatoform = form;
	var parametros = 'nome='+form.nome.value;
	parametros+='&email='+form.email.value;
	parametros+='&para='+form.para.value;
	parametros+='&assunto='+form.assunto.value;
	parametros+='&texto='+form.texto.value;
	new Ajax.Request(site_url+'/ajax/emailSender/enviaContato/',{ 
			method:'post',
			parameters:parametros,
		  	onSuccess: function(response){
		    	var resultText = response.responseText;
				
				if(resultText == '0'){
					alert('Erro ao enviar o email');
				}else{
					sucessoContato();
				}
		    }
		}
	);
	
}

function registraParticipante(obj,part_id,prog_id,prog_status){
	checkThis(obj);
	var param = part_id+'/'+prog_id+'/'+prog_status;
	new Ajax.Request(site_url+'/inscricao/registraParticipante/'+param,{ 
			method:'get',
		  	onSuccess: function(response){
				retorno = response.responseText;
				if(retorno !=''){
					alert(retorno );
				}
		     //document.getElementById('usr_status_'+ins_id).innerHTML = retorno;
			}
		}
	);
}
function mudaStatus(idCheckBox, ins_id,prog_status,prog_id){
	var status = document.getElementById('usr_status_'+ins_id).innerHTML;
	
	var param = ins_id+'/'+status+'/'+prog_status+'/'+prog_id;
	new Ajax.Request(site_url+'/inscricao/mudaStatus/'+param,{ 
			method:'get',
		  	onSuccess: function(response){
		     retorno = response.responseText;
			 document.getElementById(idCheckBox).className = "checkBox "+retorno;
		     document.getElementById('usr_status_'+ins_id).innerHTML = retorno;
			}
		}
	);
}
	
function editaTextoFoto(id_foto,indice){
	
	document.getElementById('btnSalvar_'+indice).style.display = 'none';
	document.getElementById('spanSalvando_'+indice).style.display = 'inline';
	
	var descritivo = document.getElementById('descritivoFoto_'+indice).value;
	
	var parametros = 'descritivo='+descritivo;
	parametros+='&id='+id_foto,
	parametros+='&indice='+indice;
	new Ajax.Request(site_url+'/foto/atualizaTextoAjax/',{ 
			method:'post',
			parameters:parametros,
		  	onSuccess: function(response){
		    	var resultText = response.responseText;
							
				if(resultText.length!=0){
					//alert(resultText);
					document.getElementById('btnSalvar_'+resultText).style.display = 'inline';
					document.getElementById('spanSalvando_'+resultText).style.display = 'none';
				}
		    }
		}
	);
}

function sucessoContato(){
	try{window.envieContatoform.reset();}catch(e){}
	document.getElementById('ModalContentSendContato_form').style.display = 'none';
	document.getElementById('ModalContentSendContato_msg').style.display = 'block'; 
}