function mostra_imagem(nome_imagem) {
	window.open('images/'+nome_imagem, 'Imagem', 'toolbar=no, location=no, directories=no, menubar=no, resizable=no, scrollbars=no, width=500,height=500');
}
function cadastra_senha(var_tipo){
	window.open('cadsenha.php?tipo='+var_tipo,':: Cadastro de Senha de Usuário ::', 'toolbar=no, location=no, directories=no, menubar=no, resizable=no, scrollbars=no, height=250, width=350')
}
function mostra_imagem(nome_imagem) {
	window.open('images/'+nome_imagem, 'Imagem', 'toolbar=no, location=no, directories=no, menubar=no, resizable=no, scrollbars=no, width=500,height=500');
}
function openModal(pUrl, pWidth, pHeight) {
	if (window.showModalDialog) {
		return window.showModalDialog(pUrl, window,
		  "dialogWidth:" + (parseInt(pWidth)+3) + "px;dialogHeight:" + (parseInt(pHeight)+70) + "px");
	} else {
		try {
			//netscape.security.PrivilegeManager.enablePrivilege(
			//  "UniversalBrowserWrite");
			window.open(pUrl, ":: Cadastro de Senha de Usuário ::", "width=" + pWidth + 
						", height=" + pHeight + 
						", top=" + ((screen.height-pHeight)/2) +
						", left=" + ((screen.width-pWidth)/2) +
						", toolbar=no, location=no, directories=no, menubar=no, resizable=no, scrollbars=no, modal=yes");
			return true;
		}
		catch (e) {
			alert("Script não confiável, não é possível abrir janela modal.");
			return false;
		}
	}
}
function openWindow(pUrl, pWidth, pHeight) {
		window.open(pUrl, null, "width=" + ((pWidth == null) ? screen.width : pWidth) + 
					", height=" + ((pHeight == null) ? screen.height : pHeight) + 
					", top=" + ((pHeight == null) ? 0 : ((screen.height-pHeight)/2)) +
					", left=" + ((pWidth == null) ? 0 : ((screen.width-pWidth)/2)) +
					", toolbar=no, location=no, directories=no, menubar=no, resizable=no, scrollbars=yes, modal=yes");
		return true;
}

function createRequestObject() {
   var req;
   if(window.XMLHttpRequest){
      // Firefox, Safari, Opera...
      req = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
      // Internet Explorer 5+
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      // There is an error creating the object,
      // just as an old browser is being used.
      alert('Problem creating the XMLHttpRequest object');
   }
   return req;
}

// Make the XMLHttpRequest object
var http = createRequestObject();
var destino = null;
var divload = null;

function sendRequest(act,local,div_load) {
  destino = local;
  divload = div_load;
   // Open PHP script for requests
   http.open('get', act, true);
   http.setRequestHeader('Content-Type',"application/x-www-form-urlencoded; charset=iso-8859-1");
   http.setRequestHeader("Cache-Control","no-store, no-cache, must-revalidate");
   http.setRequestHeader("Cache-Control","post-check=0, pre-check=0");
   http.setRequestHeader("Pragma", "no-cache");        
   http.onreadystatechange = handleResponse;
   http.send(null);
}

function handleResponse() {
   if(http.readyState == 4 && http.status == 200){
      // Text returned FROM the PHP script
      var response = http.responseText;
      if(response) {
         // UPDATE ajaxTest content
		 document.getElementById(destino).innerHTML = response;
		 //document.getElementById(divload).style.display = "none";
		 return(response); //**** aqui as informações vão pro limbo...
      }
   }
   if(http.readyState == 1){
      //document.getElementById(divload).style.display = "block";
	  document.getElementById(destino).innerHTML = "...<center>Aguarde processando requisi&ccedil;&atilde;o...</center>";
   }
} 
function sendmail(){
	if(document.getElementById('hdMail').value != ""){
		if(document.formContato.name.value != ""){
			if(document.formContato.email.value != ""){
				var url = 'sendmail.php';
				var parametros = "name=" + encodeURI(document.formContato.name.value) +
									 "&email=" + encodeURI(document.formContato.email.value) +
									 "&message=" + encodeURI(document.formContato.message.value) +
									 "&mail_to=" + encodeURI(document.getElementById('hdMail').value) +
									 "&from_to=" + encodeURI(document.getElementById('hdSetor').value);
				http.open('get', url+'?'+parametros, true);
				http.setRequestHeader('Content-Type',"application/x-www-form-urlencoded; charset=iso-8859-1");
			    http.setRequestHeader("Cache-Control","no-store, no-cache, must-revalidate");
			    http.setRequestHeader("Cache-Control","post-check=0, pre-check=0");
			    http.setRequestHeader("Pragma", "no-cache");        
			    http.onreadystatechange = handleResponseSendMail;
			    http.send(null);
			}else{
				alert('Preencha o seu e-mail por favor !');
			}
		}else{
			alert('Preencha o seu nome por favor !');
		}
	}else{
		alert('Falta escolher um setor para enviar o seu e-mail !');
	}
}
function handleResponseSendMail() {
    if(http.readyState == 4){
		document.getElementById('load').innerHTML = "";
		var response = http.responseText; //resultado formatado
		if(http.status == 200){
			if(response == 'ok'){
				alert('Mensagem enviada com sucesso !');
				document.formContato.name.value = '';
				document.formContato.email.value = '';
				document.formContato.message.value = '';
				document.formContato.name.focus();
			}else{
				alert('Erro ao enviar a mensagem !');
			}
		}else{
			alert('Erro ao enviar a mensagem !');
		}
	}
   if(http.readyState == 1){
	  document.getElementById('load').innerHTML = "Aguarde enviando a sua mensagem...";
   }
}