function click() {
	if (event.button==2||event.button==3){
	    oncontextmenu='return false';
	}
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;");

var Ajax = false;

function ajaxRequest(){
	Ajax = false;
	if (window.XMLHttpRequest){
	Ajax = new XMLHttpRequest();
	}else if (window.ActiveXObject){
     var versoes = ["Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];	 
	   for (var i=0;i<=versoes.length;i++){
		try {
			Ajax = new ActiveXObject(versoes[i]);
			}catch (e){}	
	   }
	}
}

function retornoAjax(){
   if (Ajax.readyState == 4 && Ajax.status == 200){
	  document.getElementById('conteudo').innerHTML = Ajax.responseText;
   }
}

function enviarcot(envurl,envtit,envfot,envpag){
	document.getElementById('aviso').value = "enviando...";
	document.getElementById('enviarcot').disabled = true;
	ajaxRequest();
	if (Ajax){
	var dadoscot = "acao=cotar&seunome=" + encodeURI(document.form.seunome.value) + "&seuemail=" + encodeURI(document.form.seuemail.value) + "&ddd=" + document.form.ddd.value + "&seutelefone=" + document.form.seutelefone.value + "&quantidade=" + document.form.quantidade.value + "&mensagem=" + encodeURI(document.form.mensagem.value);
	Ajax.onreadystatechange = retornoAjax;
	Ajax.open('POST','cotar.php?url='+envurl+'&tctrl='+envtit+'&fctrl='+envfot+'&pag='+envpag,true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
	Ajax.setRequestHeader('Content-length', dadoscot.length); 
	Ajax.send(dadoscot);
	}else{
	document.form.submit();
	}	
}

function acessar(urldest){
	ajaxRequest();
	if (Ajax){
	Ajax.onreadystatechange = retornoAjax;
	Ajax.open('GET',urldest,'true');
	Ajax.send(null);
	}else{
	window.location.href = urldest;
    }
}

function cotar(coturl,cottit,cotfot,pag){
	if (document.form.seunome.value == "" || document.form.seuemail.value == "" || document.form.quantidade.value == ""){
	document.getElementById('aviso').value = "os campos marcados (*) são obrigatórios!";	
	}else{
		if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.form.seuemail.value)){
		document.getElementById('aviso').value = "O seu e-mail não é válido!";	
		}else{		
			if (document.form.ddd.value != ""){
				if (document.form.seutelefone.value == ""){
				document.getElementById('aviso').value = "nº de telefone não preenchido!";	
				}else{
				enviarcot(coturl,cottit,cotfot,pag);
				}	
			}else if (document.form.ddd.value == ""){
			enviarcot(coturl,cottit,cotfot,pag);	
			}	
		}
	}
}

function pula_campo(){
	if (Number(document.form.ddd.value)){
		document.getElementById('aviso').value = "";
		if (document.form.ddd.value.length == 2){
		document.form.seutelefone.focus();
		}
	}else{
		document.form.ddd.value = "";
		document.getElementById('aviso').value = "digite apenas números no campo DDD";	
	}
}

function ver_ddd(){
	if (document.form.ddd.value.length < 2){
	document.getElementById('aviso').value = "preencha o campo DDD";	
	document.form.ddd.value = "";
	document.form.seutelefone.value = "";
	document.form.ddd.focus();
	}
}

function checa_num(){
	if (Number(document.form.quantidade.value)){
		document.getElementById('aviso').value = "";
	}else{
		document.getElementById('aviso').value = "digite apenas números no campo quantidade";	
		document.form.quantidade.value = "";	
	}
}

function indicar(coturl,cottit,cotfot,pagi){
	if (document.form.seunome.value == "" || document.form.seuemail.value == "" || document.form.nomedestinatario.value == "" || document.form.emaildestinatario.value == ""){
	document.getElementById('aviso').value = "os campos marcados (*) são obrigatórios!";	
	}else{
		if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.form.seuemail.value)){
		document.getElementById('aviso').value = "O seu e-mail não é válido!";	
		}else{		
			if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.form.emaildestinatario.value)){
			document.getElementById('aviso').value = "O e-mail do destinatário não é válido!";	
			}else{
			enviarindic(coturl,cottit,cotfot,pagi);	
			}	
		}
	}
}

function enviarindic(indurl,indtit,indfot,indpag){
	document.getElementById('aviso').value = "enviando...";
	document.getElementById('enviarindic').disabled = true;
	ajaxRequest();
	if (Ajax){
	var dadosindic = "acao=indicar&seunome=" + encodeURI(document.form.seunome.value) + "&seuemail=" + encodeURI(document.form.seuemail.value) + "&nomedestinatario=" + document.form.nomedestinatario.value + "&emaildestinatario=" + document.form.emaildestinatario.value + "&mensagem=" + encodeURI(document.form.mensagem.value);
	Ajax.onreadystatechange = retornoAjax;
	Ajax.open('POST','indicar.php?url='+indurl+'&tctrl='+indtit+'&fctrl='+indfot+'&pag='+indpag,true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
	Ajax.setRequestHeader('Content-length', dadosindic.length); 
	Ajax.send(dadosindic);
	}else{
	document.form.submit();
	}	
}

function enviarContato(){
	if (document.form.seunome.value == "" || document.form.seuemail.value == "" || document.form.mensagem.value == ""){
	document.getElementById('aviso').value = "todos os campos são obrigatórios!";	
	}else{
		if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.form.seuemail.value)){
		document.getElementById('aviso').value = "O seu e-mail não é válido!";	
		}else{
			document.getElementById('aviso').value = "enviando...";
			document.getElementById('enviarcont').disabled = true;
			ajaxRequest();
			if (Ajax){
			var dadoscont = "acao=enviar&seunome=" + encodeURI(document.form.seunome.value) + "&seuemail=" + encodeURI(document.form.seuemail.value) + "&mensagem=" + encodeURI(document.form.mensagem.value);
			Ajax.onreadystatechange = retornoAjax;
			Ajax.open('POST','fale_conosco.php',true);
			Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
			Ajax.setRequestHeader('Content-length', dadoscont.length); 
			Ajax.send(dadoscont);
			}else{
			document.form.submit();
			}
		}
	}
}

function apagarContato(){
	document.getElementById('aviso').value = "";
	document.form.seunome.value = "";
	document.form.seuemail.value = "";
	document.form.mensagem.value = "";
}