var limit = 3; var xmlhttp = null; var domObj = null; var start = 0; var MSXML_XMLHTTP_PROGIDS = new Array( 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP' ); function xmlGetObj() { for (var i = 0; i < MSXML_XMLHTTP_PROGIDS.length; i++) { try { xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]); return xmlhttp; } catch (e) {} } if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } function xmlRequest(uri) { xmlhttp.open("GET", uri, false); xmlhttp.send(null); if ( xmlhttp.status != 200 ) alert ("XML request failed"); else domObj = xmlhttp.responseXML; } function printNews(val) { var anchor, x, div; start += val; div = getObj('news'); if(div && domObj ) { var items = domObj.getElementsByTagName('item'); while(x = div.firstChild) div.removeChild(x); if (items.length) { for (var i = start; (i < items.length) && (i < start + limit); i++) { anchor = document.createElement('a'); anchor.title = 'read more...' anchor.href = items[i].getElementsByTagName('link')[0].firstChild.nodeValue; anchor.style.borderBottom = 0; anchor.appendChild(document.createTextNode( (i+1) + '. ' + items[i].getElementsByTagName('title')[0].firstChild.nodeValue)); div.appendChild(anchor); div.appendChild(document.createElement('br')); div.appendChild(document.createTextNode( 'on ' + items[i].getElementsByTagName('pubDate')[0].firstChild.nodeValue.substr(5, 11) )); div.appendChild(document.createElement('br')); } div.appendChild(document.createElement('br')); if(start >= limit) { anchor = document.createElement('a'); anchor.href = '#'; anchor.onclick = function() { return printNews(-limit); } anchor.title = 'prev'; anchor.appendChild(document.createTextNode('<< ')); div.appendChild(anchor); } anchor = document.createElement('a'); anchor.href = 'g.php?f=news'; anchor.appendChild(document.createTextNode('all news...')); div.appendChild(anchor); if(start + limit < items.length) { anchor = document.createElement('a'); anchor.href = '#'; anchor.onclick = function() { return printNews(limit); } anchor.title = 'next'; anchor.appendChild(document.createTextNode(' >>')); div.appendChild(anchor); } } } return false; } function GetXmlNews() { if(xmlGetObj()) xmlRequest('g.php?f=xml/en.xml'); printNews(start); }