	function show(idform) {
		
		if(idform == null)
			idform = 'formaviseme';
		document.getElementById(idform).style.display = 'block'; 
		
		 
	}
	function hide(idform) {
		
		if(idform == null)
			idform = 'formaviseme';
		document.getElementById(idform).style.display = 'none'; 
	}

	function aviseme() {
		show();
	}
	var http = null; 
	var inCall = false;
	
	function getObj(name) {
		return document.getElementById(name);
	}
	
	function createRequestObject() {
	  var reqObj;
	  var browser = navigator.appName;
	  if(browser == "Microsoft Internet Explorer"){
		reqObj = new ActiveXObject("Microsoft.XMLHTTP");
		isIE = true;
	  }else{
		reqObj = new XMLHttpRequest();
	  }
	  return reqObj;
	}
	
	function doCall(whereTo, returnTo,async){
		if (async == null)
			async = false;
	  inCall = true;
	  http = createRequestObject();
	  http.open('get', noCache(whereTo), async);
	  
	  // DO WE HAVE A FUNCTION TO CALL ONCE CALL IS COMPLETED?
	  if(returnTo.length > 0){
		eval("http.onreadystatechange = "+returnTo);
	  }
	  // SEND CALL
	  http.send(null);
	}
	
	function noCache(uri)
	{
		return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567);
	}
	
	function mostracalculafreteproduto() {
		var f = getObj('calculofreteform');
		var d = getObj('calculofretedados');
		f.style.visibility = 'visible';
		f.style.display = 'block';
		d.style.visibility = 'hidden';
		d.style.display = 'none';
		getObj('f_cep1').value = '#CEP1#';
		getObj('f_cep2').value = '#CEP2#';
		getObj('f_qtd').value = '1';
	}
	
	function calculafreteproduto(id) {
		var d = getObj('calculofretedados');
		d.innerHTML = 'Calculando frete ...';
		d.style.visibility = 'visible';
		d.style.display = 'block';
		var cep1 = getObj('f_cep1').value;
		var cep2 = getObj('f_cep2').value;
		var qtd = getObj('f_qtd').value;
		doCall('/content/calcula_frete_produto.php?id='+id+'&cep='+cep1+''+cep2+'&qtd='+qtd,'retornoCalculaFreteProduto',true);
	}
	
	function retornoCalculaFreteProduto() {
		if(http.readyState == 4) {
			 getObj('calculofretedados').innerHTML = http.responseText;
			 getObj('simulafrete').style.width = '400px';
		}
	}
	function abrijanela(url,name,params) { 
	window.open(url,name,params);
}

function abretiresuasduvidas(idp){
	abrijanela("/content/tire_suas_duvidas.php?idp="+idp,"duvidas",'width=350,height=400,toolbar=no,scrollbars=no,top=200,left=250');
}

function aviseme(idp){
		abrijanela("/content/aviseme.php?idp="+idp,"duvidas",'width=500,height=450,toolbar=no,scrollbars=no,top=200,left=250');
}

function goto(url) {
	
		var qtd = document.getElementById('qtd_enviar_carrinho').value;
		window.location.href=url + '&qtd=' + qtd;
	}
	function popup(id) {
		window.open('/content/showimage.php?id='+id,'page','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=480,height=480');
	}
	function checkw(obj) {
		if(obj.value.length == 5) {
			document.getElementById('f_cep2').value = '';
			document.getElementById('f_cep2').focus();
		}
	}
	

			
