function fctCreateXMLHTTP(){
    xmlHttp = null   
	
	try{
		xmlHttp = new XMLHttpRequest();
	}catch(e1){
		try{
			//alert('e1 Não é Firefox='+e1.description)
			xmlHttp = new ActiveXObject("Microsoft.Msxml2.XMLHTTP");
		}catch(e2){
			//alert('e2 Não é IE não='+e2.description)
				//alert("Seu navegador não suporta o recurso de comentários desta página.")
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e3){
				//alert('e3='+e3.description)
				alert("Seu navegador não suporta o recurso de comentários desta página.")
					xmlHttp = null;
			}
			
		}

		
	}

	if(!xmlHttp && typeof XMLHttpRequest != "undefined")
		xmlHttp = new XMLHttpRequest();
		return xmlHttp;
	
}

fctCreateXMLHTTP();

function stateChanged()
{
if (xmlHttp.readyState){
        //alert(xmlHttp.readyState)
		//alert("state="+xmlHttp.readyState+"\n"+xmlHttp.responseText)
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
            //alert(xmlHttp.status)
			//alert(xmlHttp.responseText)
			//TESTE
			//alert("state="+xmlHttp.readyState+"\n"+xmlHttp.responseText)
            fctCreateXMLHTTP();

        }
    }
}

function fctNewAjax(intMethod,strUrl,strFormData,fctStatus){
   
    intMethod = (intMethod)? "POST" : "GET";
   
   
    if(intMethod=="POST"){

        if(fctStatus)xmlHttp.onreadystatechange=fctStatus;
        xmlHttp.open("POST",strUrl,true)
        xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        xmlHttp.setRequestHeader("Cache-Control","post-check=0, pre-check=0");
        xmlHttp.setRequestHeader("Pragma", "no-cache");
		xmlHttp.send(strFormData)
       
    }else{
       
        if(fctStatus)xmlHttp.onreadystatechange=fctStatus;
        if(!strFormData)strFormData="";
        xmlHttp.open("GET",strUrl+strFormData,true)
        xmlHttp.setRequestHeader('Content-Type','text/xml');
        xmlHttp.setRequestHeader('encoding','ISO-8859-1');
        xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        xmlHttp.setRequestHeader("Cache-Control","post-check=0, pre-check=0");
        xmlHttp.setRequestHeader("Pragma", "no-cache");
        xmlHttp.send(null)   
    }
}

function fctListaComm(intQtdComm){
	document.getElementById('divForm').style.display='none';
	document.getElementById('divListaComentarios').style.display='block';
	document.getElementById('divComentariosStatus').style.display='none';
	for(i=0; i<=intQtdComm; i++){
		
		var strDiv = "divComm"+i;
		try{
			document.getElementById("divComm"+i).style.display='block';
		}catch(e){
			//alert(e.description)
				return null;
		}
			
	}
	
}


function fctEnviarNews(){
	strFormData ="act=newsletter&strNome="+document.getElementById('strNomeNews').value;
	strFormData +="&strEmail="+document.getElementById('strEmailNews').value;
	fctNewAjax(1,"acoes_input.php", strFormData,fctEnviarNewsStatus);
}


function fctEnviarNewsStatus(){
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		//alert('TODO: resposta ao usuario')
		document.getElementById('divNewsLetter').innerHTML = "<b>Muuuuuu...ito Obrigado por participar!</b>";
	 } 

}

function fctEnviarContato(e){
//alert('enviando contato');
	strFormData ="&strNome="+document.getElementById('fldContatoNome').value;
	strFormData +="&strEmail="+document.getElementById('fldContatoEmail').value;
	strFormData +="&strMsg="+document.getElementById('txtAreaContato').value;
	fctNewAjax(1,"acoes_input.php", strFormData,fctEnviarContatoStatus);
	e.preventDefault();
	return false;
}

function fctEnviarContatoStatus(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById('fldContatoNome').value = 'nome';
		document.getElementById('fldContatoEmail').value = 'e-mail';
		document.getElementById('txtAreaContato').value = 'mensagem';
		alert('Obrigado! Lhe responderemos em breve!')
		//document.getElementById('divNewsLetter').innerHTML = "<b>Obrigado por participar!</b>";
	 }
}

/*function fctEnviarNewsStatus(){
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		alert('enviado')
		//document.getElementById('divNewsLetter').innerHTML = "<b>Obrigado por participar!</b>";
	 } 

}*


/*=============================================================================================================== */


function fctShowDiv(div){
	document.getElementById(div).style.display = 'block';
}

function fctHideDiv(div){
	document.getElementById(div).style.display = 'none';
}

function fctShowTube(div){
	
	for(i=0; i<6; i++){
		
		if(div!=i){
			document.getElementById("divVideo"+i).style.display = 'none';
		}
		
	}
	
	document.getElementById("divVideo"+div).style.display = 'block';
}





function fctSwap(obj,img){
	obj.src = img;
}


function fctShowComm(div){

	document.getElementById("divComm"+div).style.display = 'block';

}

function fctFocus(obj, str){
	if(obj.value == str.replace(/^\s+|\s+$/g,"")) obj.value = "";
}

function fctBlur(obj, str){
	if(obj.value == "") obj.value = str;
}



















