// =========================================================================================
// ================================================================================= AJAX ==
//==========================================================================================

// instancia do objeto XMLHTTP
//============================================================================================
	function openAjax() {
		var ajax;
		try {
			ajax = new XMLHttpRequest();} 
		catch(ee) {
			try {
				ajax = new ActiveXObject("Msxml2.XMLHTTP");} 
			catch(e) {
				try {
					ajax = new ActiveXObject("Microsoft.XMLHTTP");} 
				catch(E) {
					ajax = false; }	} }
		return ajax;}

// captura elemento pelo ID
//============================================================================================
	function getID(ID) {
			return document.getElementById(ID);}

// captura elemento pela TAG NAME
//============================================================================================
	function getTN(tagname) {
		return document.getElementsByTagName(tagname);}
		
// exibe e oculta DIV no parametro
//============================================================================================
	function showAd(id,opt){
		var obj = getID(id+opt);
		var ret = getID("callAjax");
		if(obj.className == "ajaxHide") {			 
			obj.className = "ajaxShow";}
		else {
			obj.className = "ajaxHide";
			ret = focus();}}

// processamento de cadastro de newsletter
//============================================================================================
	function cadSet(dm) {
		var retorno = getID("return");
		var name = getID("nomecad");
		var mail = getID("emailcad");
		nome = name.value;
		email = mail.value;
		if(nome == "" || nome == "Nome"){
			alert("Você deve preencher seu nome!");}
		else{
			if(email == "" || email == "E-mail"){
				alert("Você deve preencher seu email!");}
			else{
				var ajax = openAjax();
				ajax.open('GET', 'http://'+dm+'/neoadmin/_distribuite/neo.cadastros/_public/cadprcss.php?tp=1&nome='+nome+'&email='+email, true);
				ajax.onreadystatechange = function() {
						if (ajax.readyState == 1) {
							retorno.innerHTML = '<img src="http://'+dm+'/site/images/loading.gif"/>';}
						if (ajax.readyState == 4) {
							if (ajax.status == 200) {
								retorno.innerHTML = ajax.responseText;} } }
				ajax.send(null);}
			}
	}

