function loadXml(url,id,horizontal) {
	this.xml = new xmlObj( {
			url: url,
			args: { id:id, horizontal:horizontal }
		} );
}

function loadMe(args) {

    var xmlDoc = args.xml;
	var xmlDate = xmlDoc.getElementsByTagName("pubDate");
    var xmlTitle = xmlDoc.getElementsByTagName("title");
	var xmlLink = xmlDoc.getElementsByTagName("link");
	var xmlCategoria = xmlDoc.getElementsByTagName("category");

	var htm = '';
	
	var contTitle = 2;
	
	var diasSemana = ["DOM", "SEG", "TER", "QUA", "QUIN", "SEX", "SAB"];
	
		htm+='<div class="box-plantao noticias">';
		htm+='<h3>/ <a href="http://g1.globo.com/Noticias/0,,GVP0-5597-5597,00.html" title="plant&atilde;o" target="_blank">plant&atilde;o</a> <a href="http://g1.globo.com/" title="G1" target="_blank"><img src="http://g1.globo.com/Portal/G1V2/img/logo_g1_badge.gif" width="24" height="20" alt="G1" /></a></h3>';
		htm+='<ol>';
		
		var date = new Date(xmlDate[0].childNodes[0].nodeValue);			
		var dia = date.getDate()<10? "0"+date.getDate(): date.getDate();
		var mes = ((date.getMonth()+1)<10)? "0"+(date.getMonth()+1): (date.getMonth()+1);
		
//		htm+='<li class="dia-plantao">';			
//		htm+=diasSemana[date.getDay()]+", "+dia+"/"+mes+"/"+date.getFullYear();
//		htm+='</li>';
		
		for(var i = 0; i < 2; i++){
			
			htm+='<li>';
			htm+='<p class="hora">';
			htm+=xmlDate[i].childNodes[0].nodeValue.substring(17,22).replace(":","h");
			htm+='<span> |';
			htm+=xmlCategoria[i].childNodes[0].nodeValue.substring(4,50);
			htm+='</span>';
			htm+='</p>';
			htm+='<h4><a href=';
		 	htm+=xmlLink[contTitle].childNodes[0].nodeValue;
			htm+=' target="blank">';
			htm+=xmlTitle[contTitle].childNodes[0].nodeValue;
			htm+='</a></h4></li>';
			contTitle++;
	   	}
		htm+='</ol>';   
	   	htm+='<br /><p class="rodape"><a href="http://g1.globo.com/Noticias/0,,GVP0-5597-5597,00.html" title="todas as not&iacute;cias">&raquo; todas as not&iacute;cias </a></p></div>';		
	
	
	document.getElementById(args.id).innerHTML = htm;

}

function xmlObj(args) {
	this._args = args;
	this.load();
}

xmlObj.prototype.load = function() {
	this._request = this._getXMLHTTPRequest();
	var _this = this;
	this._request.onreadystatechange = function(){_this._onData()};
	this._request.open("GET",this._args.url, true);
	this._request.send(null);
}

xmlObj.prototype._onData = function() {
	if(this._request.readyState == 4) {
		if(this._request.status == "200") {
			var args = this._args.args;
			args.xml = this._request.responseXML
			loadMe(args);
		}
		delete this._request;
	}
}

xmlObj.prototype._getXMLHTTPRequest = function(){
	var xmlHttp;
	try	{
		xmlHttp = new ActiveXObject("Msxml2.XMLHttp");
	} catch(e) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
		} catch(e2) {}
	}
	if(xmlHttp == undefined && (typeof XMLHttpRequest != 'undefined')) {
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}