EscrevaCookie();
function EscrevaCookie(){
	var hoje = new Date();
	var data = new Date("December 31, 2023");
	var cookie_data = data.toGMTString();
	var o_cookie = "resolucao="+ screen.width;
	var o_cookie = o_cookie + ";expires=" + cookie_data;
	document.cookie=o_cookie
}
function fonte(to){
	if(to=="fonte1"){ 
		document.getElementById('fonte1').style.fontSize='16px';
		//document.getElementById('fonte1').style.border='1px solid red';
		//document.getElementById("rimg").src="";
		//document.getElementById("sub_img").src="imagens_site/fim_conteudo.jpg";
}
	else if(to=="fonte2"){ document.getElementById('fonte1').style.fontSize='10px'; }
	else if(to=="fonte3"){ 
		document.getElementById('fonte1').style.fontSize='12px'; 
		document.getElementById('fonte1').style.textAlign='left';
		document.getElementById('fonte_eng').style.fontSize='12px'; 
		document.getElementById('fonte_eng').style.textAlign='left';		
		document.getElementById('conteudo_interna').style.display='block'; 
		document.getElementById('conteudo_interna2').style.display='none'; 
	}
}
function fonte_eng(to){
	if(to=="fonte1"){ document.getElementById('fonte_eng').style.fontSize='16px'; }
	else if(to=="fonte2"){ document.getElementById('fonte_eng').style.fontSize='10px'; }
	else if(to=="fonte3"){ 
		document.getElementById('fonte1').style.fontSize='12px'; 
		document.getElementById('fonte1').style.textAlign='left';
		document.getElementById('conteudo_interna').style.display='block'; 
		document.getElementById('conteudo_interna2').style.display='none'; 
	}
}

if (screen.width==1024) {
	var d=("<link href='layout/css/css_interna_1024.css' type='text/css' rel='stylesheet'  />");
	document.write(d);
}
else if(screen.width==1280){
	var d=("<link href='layout/css/css_interna_1280.css' type='text/css' rel='stylesheet'  />");
	document.write(d);
}
else{
	var d=("<link href='layout/css/css_interna_800.css' type='text/css' rel='stylesheet'  />");
	document.write(d);
}
var xmlhttp;
var box;
function clarear(core){
	document.getElementById("escon").style.filter='alpha(opacity='+core+')';
	var ncore=parseInt(core);
	ncore=ncore/100;
	document.getElementById("escon").style.opacity=ncore;
}
function exe_esmaece(esmaece, id){
	document.getElementById("esma"+id).style.filter='alpha(opacity='+esmaece+')';
	var nesmaece=parseInt(esmaece);
	nesmaece=nesmaece/100;
	document.getElementById("esma"+id).style.opacity=nesmaece;	
	document.getElementById("esma"+id).style.color='#000000';
	document.getElementById("esma"+id).style.border='1px solid #06547B';
}
function esmaecer(id){
	exe_esmaece('100', id);	
	setTimeout("exe_esmaece('90', '"+id+"')",100);
	setTimeout("exe_esmaece('80', '"+id+"')",200);	
	setTimeout("exe_esmaece('70', '"+id+"')",300);
	setTimeout("exe_esmaece('60', '"+id+"')",400);	
//	setTimeout("exe_esmaece('50', '"+id+"')",500);
//	setTimeout("exe_esmaece('40', '"+id+"')",600);	
//	setTimeout("exe_esmaece('30', '"+id+"')",700);
//	setTimeout("exe_esmaece('20', '"+id+"')",800);
//	setTimeout("exe_esmaece('10','"+id+"')",900);
}
function ocultar(){
	//alert(document.getElementById("escon"));
	document.getElementById("escon").style.display='none';	
}
function esmaecer_mensagem(core){
	document.getElementById("mens_erro").style.filter='alpha(opacity='+core+')';
	var ncore=parseInt(core);
	ncore=ncore/100;
	document.getElementById("mens_erro").style.opacity=ncore;
}
function mensagem_exec(){
	esmaecer_mensagem('10');
	//setTimeout("clarear('10')",1000);
	setTimeout("esmaecer_mensagem('20')",100);	
	setTimeout("esmaecer_mensagem('30')",200);	
	setTimeout("esmaecer_mensagem('40')",300);
	setTimeout("esmaecer_mensagem('50')",400);	
	setTimeout("esmaecer_mensagem('60')",500);
	setTimeout("esmaecer_mensagem('70')",600);	
	setTimeout("esmaecer_mensagem('80')",700);
	setTimeout("esmaecer_mensagem('90')",800);
	setTimeout("esmaecer_mensagem('100')",900);	
}
function stateChanged(){ 
	if (xmlhttp.readyState==4){ 
		document.getElementById(box).innerHTML=xmlhttp.responseText;
	}
}
function GetXmlHttpObject(){
	if (window.XMLHttpRequest){
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject){
		//code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
function clear_link(){ 
	document.getElementById("efeito_fechar").src="imagens_site/fechar_claro.gif";
}
function dark_link(){
	document.getElementById("efeito_fechar").src="imagens_site/fechar_escuro.gif";
}
function idioma(id){
	if(id=="eng"){ 
		document.getElementById('conteudo_interna').style.display='none'; 
		document.getElementById('conteudo_interna2').style.display='block'; 
	}
	else if(id=="por"){ 
		document.getElementById('conteudo_interna').style.display='block'; 
		document.getElementById('conteudo_interna2').style.display='none'; 
	}
}
function alinhar(lado){
	if(lado=="dir"){ 
		document.getElementById('fonte1').style.textAlign='right';
		document.getElementById('esq_border').style.border='0px solid #000000';
		document.getElementById('esq_border').style.padding='0px';
		document.getElementById('dir_border').style.border='1px solid #000000';
		document.getElementById('dir_border').style.padding='1px';
		document.getElementById('center_border').style.border='0px solid #000000';
		document.getElementById('center_border').style.padding='0px';		
	}
	else if(lado=="esq"){ 
		document.getElementById('fonte1').style.textAlign='left';
		document.getElementById('esq_border').style.border='1px solid #000000';
		document.getElementById('esq_border').style.padding='1px';
		document.getElementById('dir_border').style.border='0px solid #000000';
		document.getElementById('dir_border').style.padding='0px';
		document.getElementById('center_border').style.border='0px solid #000000';
		document.getElementById('center_border').style.padding='0px';		
	}
	else if(lado=="center"){
		document.getElementById('fonte1').style.textAlign='center';
		document.getElementById('esq_border').style.border='0px solid #000000';
		document.getElementById('esq_border').style.padding='0px';
		document.getElementById('dir_border').style.border='0px solid #000000';
		document.getElementById('dir_border').style.padding='0px';
		document.getElementById('center_border').style.border='1px solid #000000';
		document.getElementById('center_border').style.padding='1px';		
	}
	//else if(lado=="fonte3"){ document.getElementById('fonte1').style.fontSize='12px'; }
}
function alinhar_eng(lado){
	if(lado=="dir"){ 
		document.getElementById('fonte_eng').style.textAlign='right';
		document.getElementById('esq_border_eng').style.border='0px solid #000000';
		document.getElementById('esq_border_eng').style.padding='0px';
		document.getElementById('dir_border').style.border='1px solid #000000';
		document.getElementById('dir_border').style.padding='1px';
		document.getElementById('center_border').style.border='0px solid #000000';
		document.getElementById('center_border').style.padding='0px';		
	}
	else if(lado=="esq"){
		document.getElementById('fonte_eng').style.textAlign='left';
		document.getElementById('esq_border_eng').style.border='1px solid #000000';
		document.getElementById('esq_border_eng').style.padding='1px';
		document.getElementById('dir_border').style.border='0px solid #000000';
		document.getElementById('dir_border').style.padding='0px';
		document.getElementById('center_border').style.border='0px solid #000000';
		document.getElementById('center_border').style.padding='0px';		
	}
	else if(lado=="center"){
		document.getElementById('fonte_eng').style.textAlign='center';
		document.getElementById('esq_border_eng').style.border='0px solid #000000';
		document.getElementById('esq_border_eng').style.padding='0px';
		document.getElementById('dir_border').style.border='0px solid #000000';
		document.getElementById('dir_border').style.padding='0px';
		document.getElementById('center_border').style.border='1px solid #000000';
		document.getElementById('center_border').style.padding='1px';		
	}
	//else if(lado=="fonte3"){ document.getElementById('fonte1').style.fontSize='12px'; }
}
function fechar_estados(){
	document.getElementById("corpicho").style.overflow='auto';
	document.getElementById("esmaecer_tudo").style.display='none';
	document.getElementById("texto_esmaecer_tudo").style.display='none';
}
function funca(){
	document.getElementById('aaaa').src='imagens_site/bandeira_usa.gif';
}
function calcular(obj){
	var total=0;
	var controle=document.getElementById("controle").value;
	controle=parseInt(controle)+1;
	for(i=1;i<controle;i++){
		valor=document.getElementById("v"+i).value;
		qts=document.getElementById("q"+i).value;
		if(qts>0){ total=parseInt(total)+(parseInt(valor)*parseInt(qts)); }
	}
	document.getElementById("inp_total").value="R$"+total+",00";
}
function contato(ven){
	var movido=xScrollTop();
	var topinho=parseInt(movido)+130;
	document.getElementById("corpicho").style.overflow='hidden';
	document.getElementById("esmaecer_tudo").style.display="block";
	var texto_esmaecido=document.getElementById('texto_esmaecer_tudo');
	document.getElementById("texto_esmaecer_tudo").style.display='block';
	topinho = topinho+'px';
	var bx=document.getElementById("esmaecer_tudo");
	bx.style.top=movido+'px';
	bx.style.width=screen.width;
	bx.style.height=screen.height;
	document.getElementById('texto_esmaecer_tudo').style.top=topinho; 
	showEstado(ven);

}
function comprar(vin, aid){
	var movido=xScrollTop();
	var topinho=parseInt(movido)+80;
	document.getElementById("corpicho").style.overflow='hidden';
	document.getElementById("esmaecer_tudo").style.display="block";
	var texto_esmaecido=document.getElementById('texto_esmaecer_tudo');
	document.getElementById("texto_esmaecer_tudo").style.display='block';
	topinho = topinho+'px';
	var bx=document.getElementById("esmaecer_tudo");
	bx.style.top=movido+'px';
	bx.style.width=screen.width;
	bx.style.height=screen.height;
	document.getElementById('texto_esmaecer_tudo').style.top=topinho; 
	showmodelo(vin, aid);
}
function comprar2(vin, aid){
	var movido=xScrollTop();
	var topinho=parseInt(movido)+80;
	document.getElementById("corpicho").style.overflow='hidden';
	document.getElementById("esmaecer_tudo").style.display="block";
	var texto_esmaecido=document.getElementById('texto_esmaecer_tudo');
	document.getElementById("texto_esmaecer_tudo").style.display='block';
	topinho = topinho+'px';
	var bx=document.getElementById("esmaecer_tudo");
	bx.style.top=movido+'px';
	bx.style.width=screen.width;
	bx.style.height=screen.height;
	document.getElementById('texto_esmaecer_tudo').style.top=topinho; 
	showmodelo2(vin, aid);
}
function sele_comprar(sid){
	var quantidade=document.getElementById("qtd_c").value;
	document.getElementById("corpicho").style.overflow='auto';
	document.getElementById("esmaecer_tudo").style.display='none';
	document.getElementById("texto_esmaecer_tudo").style.display='none';
	document.getElementById("q"+sid).value=quantidade;
	var qtd=document.getElementById("q"+sid);
	document.getElementById("q"+sid).select();

}
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}
function execmascara(){ v_obj.value=v_fun(v_obj.value); }
function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}
function soNumeros(v){ return v.replace(/\D/g,"") }

var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
	var i=xUA.indexOf('opera');
	if(i!=-1){var v=parseInt(xUA.charAt(i+6));
		xOp7Up=v>=7;xOp6Dn=v<7;
	}
}else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){
	xIE4Up=parseFloat(navigator.appVersion)>=4;
	xIE4=xUA.indexOf('msie 4')!=-1;
	xIE5=xUA.indexOf('msie 5')!=-1;
}else if(document.layers){
	xNN4=true;
}
xMac=xUA.indexOf('mac')!=-1;
function xDef(){
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])=='undefined') return false;
	}
	return true;
}
function xGetElementById(e){
	if(typeof(e)=='string') {
		if(document.getElementById) e=document.getElementById(e);
		else if(document.all) e=document.all[e];else e=null;
	}
	return e;
}
function xLeft(e, iX){
	if(!(e=xGetElementById(e))) return 0;
	var css=xDef(e.style);
	if (css && xStr(e.style.left)) {
		if(xNum(iX)) e.style.left=iX+'px';
		else {iX=parseInt(e.style.left);if(isNaN(iX)) iX=0;}
	}
	else if(css && xDef(e.style.pixelLeft)) {
		if(xNum(iX)) e.style.pixelLeft=iX;
		else iX=e.style.pixelLeft;
	}
	return iX;
}
function xMoveTo(e,x,y){
	xLeft(e,x);
	xTop(e,y);
}
function xNum(){
	for(var i=0; i<arguments.length; ++i){
		if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;
	}
	return true;
}
function xScrollTop(e, bWin){
	var offset=0;
	if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
		var w = window;
		if (bWin && e) w = e;
		if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
		else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
	}
	else {
		e = xGetElementById(e);
		if (e && xNum(e.scrollTop)) offset = e.scrollTop;
	}
	return offset;
}
function xStr(s){for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}return true;}
function xTop(e, iY){if(!(e=xGetElementById(e))) return 0;var css=xDef(e.style);if(css && xStr(e.style.top)) {if(xNum(iY)) e.style.top=iY+'px';else {iY=parseInt(e.style.top);if(isNaN(iY)) iY=0;}}else if(css && xDef(e.style.pixelTop)) {if(xNum(iY)) e.style.pixelTop=iY;else iY=e.style.pixelTop;}return iY;}

function showEstado(estado){
//Id da div
	box='texto_esmaecer_tudo';
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	if(estado=="acre"){	var url="ac.html"; }
	else if(estado=="distrito_federal"){ var url="df.html"; }
	else if(estado=="goias"){ var url="go.html"; }
	else if(estado=="mato_grosso"){ var url="mt.html"; }
	else if(estado=="mato_grosso_do_sul"){ var url="ms.html"; }	
	else if(estado=="minas_gerais"){ var url="mg.html"; }	
	else if(estado=="parana"){ var url="pr.html"; }	
	else if(estado=="rio_de_janeiro"){ var url="rj.html"; }	
	else if(estado=="rio_grande_do_sul"){ var url="rs.html"; }	
	else if(estado=="rondonia"){ var url="ro.html"; }
	else if(estado=="sao_paulo"){ var url="sp.html"; }
	else if(estado=="santa_catarina"){ var url="sc.html"; }	
	else if(estado=="tocantins"){ var url="to.html"; }		
	//url=url+"?id="+id+"&pos="+pos;
	//url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}


function showmodelo(est, oid){
//Id da div
//	alert(estado);
	box='texto_esmaecer_tudo';
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="../../obs_produtor.php?modelo="+est+"&sid="+oid;
	//url=url+"?id="+id+"&pos="+pos;
	//url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function showmodelo2(est, oid){
//Id da div
//	alert(estado);
	box='texto_esmaecer_tudo';
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="../../obs_produtor2.php?modelo="+est+"&sid="+oid;
	//url=url+"?id="+id+"&pos="+pos;
	//url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
/*********************************************
Configuracao do Ajax
***********************************************/
var xmlhttp;
var box;
function stateChanged(){ 
	if(xmlhttp.responseText=='no'){
		location.href='login.php';
	}
	if (xmlhttp.readyState==4){ 
		document.getElementById(box).innerHTML=xmlhttp.responseText;
	}
}

function GetXmlHttpObject(){
	if (window.XMLHttpRequest){
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject){
		//code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
function imprimir_conteudo(pagina, valu){
	if(valu==1){ var vara = 1; }
	else{ var vara = 0; }
	var altura = 500;
	var largura = 600;
	var a = (screen.height/2)-(altura/2);
	var l = (screen.width/0)-(largura/0);
	window.open(pagina,'imprimir_conteudo','width='+largura+',height='+altura+',top='+a+',left='+l+',scrollbars=1'+vara+'');
}

/*********************************************
Configuracao do Ajax
***********************************************/
