var reqAH;

function retrieveAllasHirdet(url) {

	if (url != '') {
		if (window.XMLHttpRequest) { // Non-IE browsers
		reqAH = new XMLHttpRequest();
		reqAH.onreadystatechange = processStateChangeAllasHirdet;
		try {
				reqAH.open('GET', url, true);
		}
		catch (e) {
			alert(e);
		}
		reqAH.send(null);
		}
		
		else if (window.ActiveXObject) { // IE
			reqAH = new ActiveXObject('Microsoft.XMLHTTP');
			if (reqAH) {
				reqAH.onreadystatechange = processStateChangeAllasHirdet;
				reqAH.open('GET', url, true);
				reqAH.send();
			}
		}
	}
	

}


function processStateChangeAllasHirdet() {

	if (reqAH.readyState == 1) { 
		//document.getElementById('allasHirdet').innerHTML = 'betöltés folyamatban...';
	}
	
	else if (reqAH.readyState == 4) { 
		
		if (reqAH.status == 200) { 

			xml = reqAH.responseXML;
			hirdetHtml = '<h3>Friss álláshirdetések</h3><ul>';	// teljes tartalom
			
			if (xml.getElementsByTagName('file')) {
			
				for (i=0; i<3; i++) {
					hirdetLink = xml.getElementsByTagName('file')[i];
					hirdetLinkCim = hirdetLink.getElementsByTagName('position')[0];
					hirdetLinkCim = hirdetLinkCim.firstChild.data;
					hirdetLinkOwn = hirdetLink.getElementsByTagName('owner')[0];
					hirdetLinkOwn = hirdetLinkOwn.firstChild.data;
					hirdetLinkUrl = hirdetLink.getElementsByTagName('url')[0];
					hirdetLinkUrl = hirdetLinkUrl.firstChild.data;
					
					hirdetHtml += '<li><a href="'+hirdetLinkUrl+'" class="bold" title="'+hirdetLinkCim+'" target="_blank">'+hirdetLinkCim+' ('+hirdetLinkOwn+')</a></li>';
			
				}
				hirdetHtml += '</ul><a href="http://allas.origo.hu" class="megtobb" target="_blank">Még több friss álláshirdetés</a>';
				//alert (RateHtml)
				if (document.getElementById('allasHirdet')) {
						document.getElementById('allasHirdet').innerHTML = hirdetHtml;
				}
			}
		}
		else {
				//document.getElementById('allasHirdet').innerHTML ="az xml nem található";
		}
	}
}
	
function allasHirdet() {
	retrieveAllasHirdet('/patok/szerk3/allas/allas_friss.xml');
}
