function mostra_carrinho_ok_add(id)
{
  document.getElementById(id).style.display='';
  colorFade(id,'background','B9AC77','FFFFFF',40,8);
  return true;
}

// FADE COR
// main function to process the fade request //
function colorFade(id,element,start,end,steps,speed) {
  var startrgb,endrgb,er,eg,eb,step,rint,gint,bint,step;
  var target = document.getElementById(id);
  if(!target)
    return true;
  steps = steps || 20;
  speed = speed || 20;
  clearInterval(target.timer);
  endrgb = colorConv(end);
  er = endrgb[0];
  eg = endrgb[1];
  eb = endrgb[2];
  if(!target.r) {
    startrgb = colorConv(start);
    r = startrgb[0];
    g = startrgb[1];
    b = startrgb[2];
    target.r = r;
    target.g = g;
    target.b = b;
  }
  rint = Math.round(Math.abs(target.r-er)/steps);
  gint = Math.round(Math.abs(target.g-eg)/steps);
  bint = Math.round(Math.abs(target.b-eb)/steps);
  if(rint == 0) { rint = 1 }
  if(gint == 0) { gint = 1 }
  if(bint == 0) { bint = 1 }
  target.step = 1;
  target.timer = setInterval( function() { animateColor(id,element,steps,er,eg,eb,rint,gint,bint) }, speed);
}

// incrementally close the gap between the two colors //
function animateColor(id,element,steps,er,eg,eb,rint,gint,bint) {
  var target = document.getElementById(id);
  if(!target)
    return true;
  var color;
  if(target.step <= steps) {
    var r = target.r;
    var g = target.g;
    var b = target.b;
    if(r >= er) {
      r = r - rint;
    } else {
      r = parseInt(r) + parseInt(rint);
    }
    if(g >= eg) {
      g = g - gint;
    } else {
      g = parseInt(g) + parseInt(gint);
    }
    if(b >= eb) {
      b = b - bint;
    } else {
      b = parseInt(b) + parseInt(bint);
    }
    color = 'rgb(' + r + ',' + g + ',' + b + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
    target.r = r;
    target.g = g;
    target.b = b;
    target.step = target.step + 1;
  } else {
    clearInterval(target.timer);
    color = 'rgb(' + er + ',' + eg + ',' + eb + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
  }
}

// convert the color to rgb from hex //
function colorConv(color) {
  var rgb = [parseInt(color.substring(0,2),16), 
    parseInt(color.substring(2,4),16), 
    parseInt(color.substring(4,6),16)];
  return rgb;
}



   var http_request = false;
   function enviarCarrinho(url, parameters) {
	url = "../env_carrinho.inc.php";
	// alert(url+parameters);
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari, Opera...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Actualize o seu Explorador para uma melhor navegacao neste site!');
         return false;
      }
      http_request.onreadystatechange = actualizarCarrinho;

      http_request.open('GET', url + parameters, true);
      http_request.send(null);
   }

   function actualizarCarrinho() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            resultado = http_request.responseText;
            document.getElementById('caixa_carrinho').innerHTML = resultado;
	    //window.scrollTo(0,0);
			//document.getElementsByTagName('html')[0].style.height='100%';
			//document.getElementsByTagName('html')[0].style.overflow='hidden';
			//document.getElementById('light').style.display='block';
			//document.getElementById('fade').style.display='block';
			//			if(document.getElementById('flash_flag_sim').style.display!='none')
			if(document.getElementById('flash_flag_sim'))
			  {
			    document.getElementById('flash_flag_sim').style.display='none';
			    document.getElementById('flash_flag_nao').style.display='block';
			  }

         } else {
            alert('Ocorreu um erro, por favor verifique que tem a vers&atilde;o mais recente do seu Navegador e o Javascript ligado.');
         }
      }
   }
   
   function get(obj) {
      var getstr = "?";
      enviarCarrinho('../env_carrinho.inc.php', getstr);
   }

