var XmlHttp;
var xmlDoc;
var mydd;
var wind;
function CreateXmlHttp()
{
	
    //Creating object of XMLHTTP in IE
    try
    {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			XmlHttp.overrideMimeType('text/xml');
        }
        catch(ex)
        {
            XmlHttp = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari
    if(!XmlHttp && typeof XMLHttpRequest != "undefined")
    {
        XmlHttp = new XMLHttpRequest();		
    }    
	//XmlHttp.setRequestHeader("Cache-Control", "no-cache");
}

function getData(dd){
	targ = document.getElementById(dd);	
	//targ.disabled=true;
	CreateXmlHttp();
	mydd=dd;	
	//wind=win;
    if(XmlHttp)
    {    
        XmlHttp.onreadystatechange = HandleResponse;
		var currentTime = new Date();
        XmlHttp.open("GET", "http://www.aokerkyra.com/rss/rssxml.php?salt="+currentTime,  true);
		//XmlHttp.overrideMimeType('text/xml');
        XmlHttp.send(null);           
    }
}

function HandleResponse()
{	
	//alert(XmlHttp.readyState);
    if(XmlHttp.readyState == 4)
    {
    	
        if(XmlHttp.status == 200)
        {        			
			//alert(XmlHttp.responseText);
            xmlDoc=XmlHttp.responseXML.documentElement;	
			//xmlDoc=XmlHttp.responseXML.loadXML.documentElement; 		
            populate(mydd);           
        }
        else
        {
            alert("There was a problem retrieving data from the server." );
        }
    }else{
    	//HandleResponse();
    }
}



function populate(dd){
	targ = document.getElementById(dd);	
	while(targ.hasChildNodes()){
		targ.removeChild(targ.lastChild);
	}	
	records=xmlDoc.getElementsByTagName('item');	
	targ.innerHtml="";
	for (var i=0;i < xmlDoc.getElementsByTagName('item').length;i++){
		var fil=document.createElement('div');
		var link = document.createElement('a');
		link.setAttribute('href',records[i].getElementsByTagName('guid')[0].firstChild.nodeValue);
		link.setAttribute('target','_blank');
		var mytext=document.createTextNode(records[i].getElementsByTagName('title')[0].firstChild.nodeValue);
		link.appendChild(mytext);				
		var seperator = document.createTextNode('  |  ');
		fil.appendChild(link);
		//targ.innerHTML += records[i].getElementsByTagName('title')[0].firstChild.nodeValue+'&nbsp;&nbsp;';
		if(i>5){
			fil.style.float='right';			
		}				
		targ.appendChild(fil);
		//targ.appendChild(seperator);
	}		
}	



