// JavaScript Document
function limpacampo(){
		document.getElementById('email').value="";
	}
	
function InsCampo(){
		document.getElementById('email').value="Digite seu e-mail";
	}

function setResp(valor){
	document.getElementById('resp').value=valor;
}

function setEnq(tipo){
	var resp = document.getElementById('resp').value;
	var idenq = document.getElementById('idref').value;
	http.open('GET','enquete.php?opt='+resp+'&idref='+idenq,true);
	http.onreadystatechange = function(){
	if (http.readyState==4){
		window.open('../enquete_resul.php?id='+idenq+'&tipo='+tipo,'Enquete','width=380,height=350');
	}
}
	http.send(null);
}


function setEnquete(tipo){
	var resp = document.getElementById('resp').value;
	var idenq = document.getElementById('idref').value;
	http.open('GET','enquete.php?opt='+resp+'&idref='+idenq,true);
	http.onreadystatechange = function(){
	if (http.readyState==4){
		window.open('../../enquete_resul.php?id='+idenq+'&tipo='+tipo,'Enquete','width=380,height=350');
	}
}
	http.send(null);
}
function apagafotonot(foto){
		http.open("GET","delfotonot.php?id="+foto,true);
		http.onreadystatechange=muda;
		http.send(null);
	}
	
function apagaArquivo(idarq){
		http.open("GET","delarquivo.php?id="+idarq,true);
		http.onreadystatechange=mudaArq;
		http.send(null);
	}

function mudaArq(){
		if(http.readyState==4){
			var resp=http.responseText.split('|');
			document.getElementById('campo').style.display=resp[1];
			document.getElementById('arquivob').style.display=resp[0];
		}
	}

function muda(){
		if(http.readyState==4){
			var resp=http.responseText.split('|');
			document.getElementById('campo').style.display=resp[1];
			document.getElementById('fotov').style.display=resp[0];
		}
	}

function getCity(est){
	http.open('GET','getCity.php?est='+est,true);
	http.onreadystatechange = makecity;
	http.send(null);

}

function makecity(){
	var cmb = document.getElementById('cidade');
	if(http.readyState==4){
		cmb.options.length=1;
		var resp = http.responseText.split(',');
		for(i=0;i<(resp.length-1);i++){
			var opt = resp[i].split('|');
			cmb.options[i]= new Option(opt[0],opt[1]);
		}
	}
}

function Islogin(){
	var user = document.getElementById('usuario').value;
	var senha = document.getElementById('senha').value;
	http.open('GET','valida.php?user='+user+'&senha='+senha,true);
	http.onreadystatechange=trocalogin;
	http.send(null);
}

function trocalogin(){
	if(http.readyState==4){
		var resp=http.responseText;
		if(resp==1){
			window.location.assign('index.php?pag=areacliente.php');
		}else{
			alert(resp);
		}
	}	
}
function getPagina(pag,idd){
	//alert("www");
	destivamenu();
	document.getElementById('atv').value=idd;
	document.getElementById(idd).className='style2'
	http.open('GET',pag,true);
	http.onreadystatechange=troca;
	http.send(null);
}

function getPagina2(pag){
	http.open('GET',pag,true);
	http.onreadystatechange=troca;
	http.send(null);
}

function getPaginaNova(pag,idd){
	destivamenu();
	document.getElementById(idd).className='style2';
	document.getElementById('atv').value=idd;
	http.open('GET',pag,true);
	http.onreadystatechange=troca;
	http.send(null);
}

function getPagCont(pag){
		http.open('GET',pag,true);
		http.onreadystatechange=troca;
		http.send(null);
}

function troca(){
	if(http.readyState==4){
		document.getElementById('container').innerHTML=http.responseText;
	}
}

function destivamenu(){
	var menus= new Array('home','empresa','equipamentos','social','contato');
	for(i=0;i<menus.length;i++){
    	document.getElementById(menus[i]).className='style1';
	}
}

function sobre(idd){
	document.getElementById(idd).className='style2'
}

function sobre2(idd){

	document.getElementById(idd).className='textoBoldOn';
}

function sobre3(idd){
	document.getElementById(idd).className='menuEmpresa2'
}

function sobre4(idd){
	document.getElementById(idd).className='areaTarja bt_laranja_on'
}

function fora(idd){
	var atv=document.getElementById('atv').value;
	if(atv!=idd){
		document.getElementById(idd).className='style1';
	}
}

function fora2(idd){
			
		document.getElementById(idd).className='textoBoldOff';
}

function fora3(idd){
		document.getElementById(idd).className='menuEmpresa';
}

function fora4(idd){
		document.getElementById(idd).className='areaTarja bt_laranja_off';
}
function fora5(idd){
			
		document.getElementById(idd).className='textoBold3Off';

}

function getAjax(){
	ajax = null;
	try{
		ajax = new XMLHttpRequest();
		}catch(e){
			try{
				ajax = new ActiveXObject("Microsoft.XMLHttp");
			}catch(e){
				try{
					ajax = new ActiveXObject("MSXML2.XMLHttp");
				}catch(e){
					alert("Seu navegador não suporta Ajax");
				}
			}
	    }
	return ajax;
}

var http = getAjax();
