
xmlHTTP = {
    GET_COUNT:
        3
    ,
    FILE_PATH:
        './hot_news/?feed=rss2'
    ,
    FUNCTION:
        null
    ,
    SRC:
        0
    ,
	load:
        function (fName, func) {
            xmlHTTP.FUNCTION = func;
			xmlHTTP.SRC = xmlHTTP.createRequest(xmlHTTP.execute);
            var src = xmlHTTP.SRC;
			if (src){
				src.open("GET", fName, true);
				src.send(null);
			}
		}
    ,
	createRequest:
        function (func) {
			var src = null;
			try{
				src = new XMLHttpRequest();
			}catch(e){
				try{
					src = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e){
					try{
						src = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){
						return null;
					}
				}
			}
			if (src) {
                src.onreadystatechange = func;
            }
			return src;
		}
    ,
    execute:
        function() {
            var src = xmlHTTP.SRC;
			if ((src.readyState == 4) && (src.status == 200)){
                 xmlHTTP.FUNCTION(src.responseXML);
			} else {
				 //not implements.
			}
        }
}

xmlHTTP.load(xmlHTTP.FILE_PATH, function(src) {
    var titles = src.getElementsByTagName("title");
    var links = src.getElementsByTagName("link");
    var pubDates = src.getElementsByTagName("pubDate");
    var str = "";
    var monthHash = {Jan:'01',Feb:'02',Mar:'03',Apr:'04',May:'05',Jun:'06',Jul:'07',Aug:'08',Sep:'09',Oct:'10',Nov:'11',Dec:'12'};
    try {
	    for (var i = 1; i < xmlHTTP.GET_COUNT + 1; i++) {
            var dateObj = pubDates[i - 1].firstChild.nodeValue.split(" ");
            var date = dateObj[3] + "." + eval("monthHash." + dateObj[2]) + "." + dateObj[1];
		    str += '<li><span>' + date + '</span>&nbsp;&nbsp;';
            var url = "";
            if (links[i].firstChild == null) {
                url = links[i].nodeValue;
            } else {
                url = links[i].firstChild.nodeValue;
            }
		    str += '<strong><a href="' + url + '" target="_blank">';
		    str += titles[i].firstChild.nodeValue + '</a></strong></li>';
	    }
    } catch(e) {
        //not implements.
    }
	document.getElementById("xmlhttp").innerHTML = str;
});

