// JavaScript Document
function flash(arq, x, y)	{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+x+'" height="'+y+'">');
	document.write('<param name="movie" value="'+arq+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="'+arq+'" width="'+x+'" height="'+y+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
	document.write('</object>');
}

////////////////////////////////////////////////////////
var area;
/////////////////////////////////////////////////////////////

function XMLHttpRequestChange() {
	if (HttpReq.readyState == 4 && HttpReq.status == 200){
      var result = HttpReq.responseText;
      var texto = document.getElementById(area);
		texto.innerHTML = result;
   }
}

////////////////////////////////////////////////////////////////////////////

function detalhes(url, campo){
	area = campo;
	
	if (document.getElementById) { //Verifica se o Browser suporta DHTML.
		if(window.XMLHttpRequest) {
			try {
				HttpReq = new XMLHttpRequest();
			} catch(e) {
				HttpReq = false;
			}
		} else if(window.ActiveXObject) {
			try {
				HttpReq = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					HttpReq = false;
				}
			}
		}
		if(HttpReq) {
			HttpReq.onreadystatechange = XMLHttpRequestChange;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		}		  
	}
}

//////////////////////////////////////////////////////////////////

function enviar_email(url, campo, form){
	area = campo;

	var nome = form.nome.value;
	
	var email = form.email.value;
	if (email == "")	{
		alert('O campo EMAIL deve ser preenchido. Tente novamente.');
		form.email.focus();
		return;
	}else	if (!checarEmail(email))	{
		alert('Email invalido. Tente novamente.');
		form.email.focus();
		return;
	}

	var texto = form.texto.value;
	if (texto == "")	{
		alert('O campo TEXTO deve ser preenchido. Tente novamente.');
		form.texto.focus();
		return;
	}
	
	url = url + "?nome=" + nome + "&email=" + email + "&assunto=" + assunto + "&texto=" + texto;
	
	form.nome.value = "";
	form.email.value = "";
	form.assunto.value = "";
	form.texto.value = "";
	
	if (document.getElementById) { //Verifica se o Browser suporta DHTML.
		if(window.XMLHttpRequest) {
			try {
				HttpReq = new XMLHttpRequest();
			} catch(e) {
				HttpReq = false;
			}
		} else if(window.ActiveXObject) {
			try {
				HttpReq = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					HttpReq = false;
				}
			}
		}
		if(HttpReq) {
			HttpReq.onreadystatechange = XMLHttpRequestChange;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		}		  
	}
}

//////////////////////////////////////////////////////////////////

// Mudar cod
function cor(doc, cor, font_color)	{
	document.getElementById(doc).style.backgroundColor = cor;
	document.getElementById(doc).style.color = font_color;
}
//////////////////////////////////////////////

//Valida EMAIL
function checarEmail(campo){
	x = 0;
	email=campo;
  	carac_invalido = " /:,;";
  	if (email == ""){
		return false;
  	}
  	for (i=0; i<carac_invalido.length; i++){
    	carac_errado = carac_invalido.charAt(i);
    	if (email.indexOf(carac_errado,0) > -1){
			return false;
    	}
  	}

  	atPos = email.indexOf("@",1);
  	if (atPos == -1){
		return false;
  	}

  	if (email.indexOf("@",atPos+1) != -1){
		return false;
  	}
  	periodPos = email.indexOf(".",atPos)

  	if (periodPos == -1){
		return false;
  	}

  	if (periodPos+3 > email.length){
		return false;
  	}
	return true;
}
/////////////////////////////////////////////////////

