var req;

function loadXMLDocOfertas(url,valor)
{
    req = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChangeOfertas;
        req.open("GET", url+'?of='+valor, true);
        req.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChangeOfertas;
            req.open("GET", url+'?of='+valor, true);
            req.send();
        }
    }
}

function processReqChangeOfertas()
{
    document.getElementById('ofertas').innerHTML = '<table style=\"height:45px; color:#FFF; width:95%; text-align:left; margin-left:20px;\"><tr><td>Carregando...</td></tr></table>';
    if (req.readyState == 4) {
        if (req.status == 200) {
            document.getElementById('ofertas').innerHTML = req.responseText;
        } else {
            alert("Houve um problema ao obter os dados:\n" + req.statusText);
        }
    }
}

function jsOfertas(valor)
{
	var abasel = "aba"+valor;
	var abaimg = "./images/aba"+valor+"a.png";
	
    document.getElementById('aba1').src = "./images/aba1b.png";
    document.getElementById('aba2').src = "./images/aba2b.png";
    document.getElementById('aba3').src = "./images/aba3b.png";
	
	if(valor==1){
      document.getElementById('ofertas').style.height = "72px";
	} else if(valor==2){
      document.getElementById('ofertas').style.height = "146px";
	} else if(valor==3){
      document.getElementById('ofertas').style.height = "72px";
	} else {
      document.getElementById('ofertas').style.height = "146px";
	}
	
    document.getElementById(abasel).src = abaimg;
    loadXMLDocOfertas("js_ofertas.php",valor);
}
