var http_request = false;

function xReqMake(url,activator)
	{
	http_request = false;

	if (window.XMLHttpRequest)
		{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
			{
			http_request.overrideMimeType('text/xml');
			}
		}
	 else if (window.ActiveXObject)
		{
		try
			{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch (e)
			{
			try
				{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch (e)
				{}
			}
		}

	if (!http_request)
		{
		//alert('no XMLHTTP instance created');
		return false;
		}
	
	http_request.onreadystatechange = activator;
	http_request.open('GET', url, true);
	http_request.send(null);
	}


function catPane()
	{
	if (http_request.readyState == 4)
		{
		if (http_request.status == 200)
			{
			var targetDiv = document.getElementById('catPane0');
			targetDiv.innerHTML = '';

			var xmlPane = http_request.responseXML.getElementsByTagName('root').item(0).getElementsByTagName('e');
			var cntE = xmlPane.length;

			for (var i=0; i<cntE; i++)
				{
				var e = xmlPane.item(i);
				var listingElement = document.createElement('li');
				listingElement.innerHTML = e.getElementsByTagName('time').item(0).firstChild.nodeValue + '&nbsp;&nbsp; <a href="haber.php?haber_id=' + e.getElementsByTagName('id').item(0).firstChild.nodeValue + '">' + e.getElementsByTagName('title').item(0).firstChild.nodeValue + '</a>' ;

				targetDiv.appendChild( listingElement );
				}

			document.getElementById('catPane').innerHTML=targetDiv.innerHTML;
			document.getElementById('catPane').style.display = 'block';
			}
		}
	else
		{
		return true;
		}
	}


function fillUpYorum()
	{
	if (http_request.readyState == 4)
		{
		if (http_request.status == 200)
			{
			var xmlYorum = http_request.responseXML.getElementsByTagName('root').item(0).getElementsByTagName('yorum');
			var cntYorum = xmlYorum.length;

			var targetDiv = document.getElementById('yorumItems');
			targetDiv.innerHTML = '';

			for (var i=0; i<cntYorum; i++)
				{
				var yorum = xmlYorum.item(i);
				var listingElement = document.createElement('li');

				var title = document.createElement('h1');
				var content = document.createElement('div');
				var info = document.createElement('span');


				title.innerHTML = yorum.getElementsByTagName('title').item(0).firstChild.nodeValue;
				content.innerHTML = yorum.getElementsByTagName('content').item(0).firstChild.nodeValue;
				info.innerHTML = yorum.getElementsByTagName('name').item(0).firstChild.nodeValue + ' tarafindan ' + yorum.getElementsByTagName('datetime').item(0).firstChild.nodeValue + ' tarihinde';


				listingElement.appendChild(title);
				listingElement.appendChild(content);
				listingElement.appendChild(info);

				targetDiv.appendChild( listingElement );
				}


			}
		else
			{
			return true;
			//alert('problem with the request.');
			}
		}
	}


function waitingMessage()
	{
	document.getElementById('yorumItems').innerHTML = "<center><br /><img src='http://image.haber7.com/processing.gif' alt='waiting' /> <br /><br />Yorumlar yüklenirken lütfen bekleyiniz...<br /><br /></center>";
	}

function doneFetching()
	{
	document.getElementById('yorumLabel0').style.display = 'none';
	document.getElementById('yorumLabel1').style.display = 'block';
	}

function conceal(element_id)
    {
    document.getElementById(element_id).style.display = 'none';
    }


function reveal(element_id)
    {
    document.getElementById(element_id).style.display = 'block';
    }




function fillUpAds()
	{
	if (http_request.readyState == 4)
		{
		if (http_request.status == 200)
			{
			var xmlAds = http_request.responseXML.getElementsByTagName('root').item(0).getElementsByTagName('adsZone');
			for (var i=0; i<16; i++)
				{
				if (document.getElementById('adsZone_'+i))
					document.getElementById('adsZone_'+i).innerHTML=xmlAds.item(i).getElementsByTagName('content').item(0).firstChild.nodeValue;
				}


			}
		else
			{
			return true;
			//alert('problem with the request.');
			}
		}
	}



