function xmlOBJ() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function montaTemperaturadoUs(obj) {
    xml = new xmlOBJ();
    
    xml.open("POST", "http://ultimosegundo.ig.com.br/xml/ig.xml", true);
    xml.onreadystatechange = function () {
        if(xml.readyState == 4) {
            if(xml.status == '200') {
                clima = xml.responseXML.getElementsByTagName("lista")[0];
                dados = clima.getElementsByTagName("dados")[0];

                iconeSP  = dados.getElementsByTagName("icosp")[0].firstChild.nodeValue;
                minimaSP = dados.getElementsByTagName("t1")[0].firstChild.nodeValue;
                maximaSP = dados.getElementsByTagName("t2")[0].firstChild.nodeValue;
                
                iconeRJ = dados.getElementsByTagName("icorj")[0].firstChild.nodeValue;
                minimaRJ = dados.getElementsByTagName("t3")[0].firstChild.nodeValue;
                maximaRJ = dados.getElementsByTagName("t4")[0].firstChild.nodeValue;


                var html = "<table border='0' cellpadding=0 cellspacing=0 width=151 height=95 bgcolor=#f1f1f3>";
                html+= "<tr><td colspan=3><img src=http://image.ig.com.br/us/climatempo/transp.gif height=5></td></tr>";
                html+= "<tr>";
                html+= "<td><img src=http://image.ig.com.br/us/climatempo/transp.gif width=5 align='absmiddle'><font class=usi><b>São Paulo</td>";
                html+= "<td><img src=http://image.ig.com.br/us/climatempo/transp.gif width=10></td>";
                html+= "<td><font class=usi><b>Rio de Janeiro</td>";
                html+= "</tr>";
                html+= "<tr><td colspan=3><img src=http://image.ig.com.br/us/climatempo/transp.gif height=5></td></tr>";
                html+= "<tr>";
                html+= "<td height=31 width=70 align='right'>";
                html+= "<table border=0 cellpadding=2 cellspacing=2 width=65 bgcolor=#FFFFFF>";
                html+= "<tr>";
                html+= "<td rowspan=2><a href='http://www4.climatempo.com.br/ig/ig/espelho.php?pg=estado&estados=SP&cidade=São_Paulo'><img src=http://image.ig.com.br/us/climatempo/" + iconeSP + " border=0 alt='Previsão SP'></a></td>";
                html+= "<td><font color=#707bb3 size=1 face=verdana><b>" + minimaSP + "</td>";
                html+= "</tr>";
                html+= "<tr><td><font color=#c62f58 size=1 face=verdana><b>" + maximaSP + "</c>º</td></tr>";
                html+= "</table>";
                html+= "</td>";
                html+= "<td><img src=http://image.ig.com.br/us/climatempo/transp.gif width=10></td>";
                html+= "<td height=31>";
                html+= "<table border=0  cellpadding=2 cellspacing=2 width=67 bgcolor=#FFFFFF>";
                html+= "<tr>";
                html+= "<td rowspan=2><a href='http://www4.climatempo.com.br/ig/ig/espelho.php?pg=estado&estados=RJ&cidade=Rio_de_Janeiro'><img src=http://image.ig.com.br/us/climatempo/" + iconeRJ + " border=0 alt='Previsão RJ'></a></td>";
                html+= "<td><font color=#707bb3 size=1 face=verdana><b>" + minimaRJ + "</td>";
                html+= "</tr>";
                html+= "<tr><td><font color=#c62f58 size=1 face=verdana><b>" + maximaSP + "</c>º</td></tr>";
                html+= "</table>";
                html+= "</td>";
                html+= "</tr>";
                html+= "<tr>";
                html+= "<td width='151' valign=top align='center' colspan=4>";
                html+= "<form action='http://www4.climatempo.com.br/ig/ig/ig.php' method=post valign=center target=_blank>";
                html+= "<table>";
                html+= "<tr><td><img src=http://image.ig.com.br/us/climatempo/transp.gif height=5></td></tr>";
                html+= "<tr><td>";
                html+= "<input type=hidden name=pc value='us'>";
                html+= "<input type=text name=cep_in value='Digite cidade ou CEP' size=20 class=campoformulario2>";
                html+= "</td>";
                html+= "<td width='30' valign='top' align='center' valign=botton>";
                html+= "<input type=image src=http://image.ig.com.br/us/climatempo/botao_ig.gif value=submit  name='image'>";
                html+= "</td></td></td></table>";
                html+= "<td>";
                html+= "</tr>";
                html+= "</table>";
                html+= "</form>";

                document.getElementById(obj).innerHTML = html;
            }
        }
    };
    xml.send(null);
}
