/*
	* @author Mauricio Maculan
	* @site wwww.omauricio.com.br
*/
function startList(){
	frameM = document.getElementById("iFrameMenu");
	if(navigator.userAgent.match("MSIE 6.0") || navigator.userAgent.match("MSIE 7.0")){
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++){
			 node = navRoot.childNodes[i];
			 if (node.nodeName=="LI"){
				node.onmouseover=function(){
					this.className+=" over";
					nodeF = this.childNodes[2];
					if(nodeF != undefined){
						nodeF.style.zIndex = 8;
						x = getPageOffsetLeft(nodeF);
						y = getPageOffsetTop(nodeF);
						w = nodeF.offsetWidth;
						h = nodeF.offsetHeight;
		
						frameM.style.position = "absolute";
						frameM.style.left = x + "px";
						frameM.style.top  = y +"px";
						frameM.style.width = w + "px";
						frameM.style.height  = h + "px";
						frameM.style.zIndex = (Number(nodeF.style.zIndex)-1);
						frameM.style.visibility = "hidden";
					}
				}
				node.onmouseout=function(){
					this.className=this.className.replace(" over", "");
					frameM.style.visibility = "hidden";
				}//function linha 27
			 }//linha7
		}//for
	}//linha3
}//function
	
	
function getPageOffsetLeft(el) {
 var x;
 x = el.offsetLeft;
 if (el.offsetParent != null)
  x += getPageOffsetLeft(el.offsetParent);
 return x;
}

function getPageOffsetTop(el) {
	var y;
	y = el.offsetTop;
	if (el.offsetParent != null)
	y += getPageOffsetTop(el.offsetParent);
	return y;
}

window.onload = function(){
	startList();
}

function trocaClasse(id,classe){
	document.getElementById(id).className= classe;
}


function get(id)
{
	return document.getElementById(id);
}

function Ajax(){
//verifica se o browser tem suporte a ajax
  try {
	 ajax = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(e) {
	 try {
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
	 }
	 catch(ex) {
		try {
		   ajax = new XMLHttpRequest();
		}
		catch(exc) {
		   alert("Esse browser não tem recursos para uso do Ajax");
		   ajax = null;
		}
	 }
  }
}

/* Contato */

function contato() {
  Ajax();
  //se tiver suporte ajax
  if(ajax) {
	var formContato = get("formContato");
	var destino = get("retorno");
	var nome = get("cNome").value;
	var email = get("cEmail").value;
	var assunto = get("cAssunto").value;
	var mensagem = get("cMensagem").value;
	var news = "";
	
	for(var i = 0; i < document.contato.newsletter.length; i++){
		if(document.contato.newsletter[i].checked == true){
			news = document.contato.newsletter[i].value;
		}
	}
	 
	 ajax.open("POST", "mail.php", true);
	 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 
	 ajax.onreadystatechange = function() {
		//enquanto estiver processando...emite a msg de Salvando
		if(ajax.readyState == 1) {
		   destino.innerHTML = "Enviando...";   
		}
		//após ser processado - manda a resposta para destino
		if(ajax.readyState == 4 ) {
		   if(ajax.status == 200)
			{
				//recebe valores para destino
				if(ajax.responseText)
				{
					destino.innerHTML = ajax.responseText;
					if(ajax.responseText != 'Erro'){
						formContato.reset();
					}
				}
			}
		}
	 }
	//Envia dados
	 var params = "nome="+nome+"&email="+email+"&assunto="+assunto+"&news="+news+"&mensagem="+mensagem;
	 ajax.send(params);
	 
  }
}