Safari = false;
if (navigator.userAgent.indexOf("Safari") > -1) Safari = true;
function rssSearch()
{
	httpObj = createXMLHttpRequest(displayData);
	if (httpObj)
	{
		httpObj.open("GET","/news/rss/index.rdf",true);
		httpObj.send(null);
	}
}
function displayData()
{
	if ((httpObj.readyState == 4) && (httpObj.status == 200))
	{
			parseRSS1(httpObj.responseXML);
	}else{
		$("result").innerHTML = "<FONT STYLE=\"font-size:10px; font-weight:600;\">LOADING ...</FONT>";
	}
}
// RSS 1.0 (RDF) 
var cnum = "";
var i = "0";
function parseRSS1(sXML)
{
	var resultText = rssTitle = rssLink = rssText = rssDate = "";
	var itemList = sXML.getElementsByTagName("item");
	if (i == itemList.length - 1)
	{
		document.next.style.display = 'none';
	}
	if (Safari)
	{
		rssTitle = itemList[0].childNodes[1].childNodes[0].nodeValue;
		rssLink = itemList[0].childNodes[3].childNodes[0].nodeValue;
		try { rssText = itemList[0].childNodes[5].childNodes[0].nodeValue; }catch(e){ rssText = "" }
	}else{
		rssDate = itemList[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue;
		rssTitle = itemList[0].getElementsByTagName("title")[0].childNodes[0].nodeValue;
		rssLink = itemList[0].getElementsByTagName("link")[0].childNodes[0].nodeValue;
		try { rssText = itemList[0].getElementsByTagName("description")[0].childNodes[0].nodeValue; }
		catch(e){ rssText = "" }
	}
	resultText = '<a href="' + rssLink + '" CLASS="white">' + rssTitle + '</a> ' + '<SPAN STYLE=\"font-size:10px; color:#A0A0A0;\">[' + rssDate + ']</SPAN><BR>';
	$("result").innerHTML = resultText;
}


function loadNext()
{
	httpObj = createXMLHttpRequest(displayNext);
	if (httpObj)
	{
		httpObj.open("GET","/news/rss/index.rdf",true);
		httpObj.send(null);
	}
}
function displayNext()
{
	if ((httpObj.readyState == 4) && (httpObj.status == 200))
	{
			parseRSS2(httpObj.responseXML);
	}else{
		$("result").innerHTML = "<FONT STYLE=\"font-size:10px; font-weight:600; color:white;\">LOADING ...</FONT>";
	}
}

function parseRSS2(sXML)
{
	var resultText = rssTitle = rssLink = rssText = rssDate = "";
	var itemList = sXML.getElementsByTagName("item");
	cnum = parseInt(i,10) + 1;
	i = cnum.toString(10);
	i = i.substr(i.length - 4, 4);
	document.pre.style.display = 'block';
	if (i == 0)
	{
		document.pre.style.display = 'none';
	}
	if (i == itemList.length - 1)
	{
		document.next.style.display = 'none';
	}

	if (Safari)
	{
		rssTitle = itemList[i].childNodes[1].childNodes[0].nodeValue;
		rssLink = itemList[i].childNodes[3].childNodes[0].nodeValue;
		try { rssText = itemList[i].childNodes[5].childNodes[0].nodeValue; }catch(e){ rssText = "" }
	}else{
		rssDate = itemList[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue;
		rssTitle = itemList[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
		rssLink = itemList[i].getElementsByTagName("link")[0].childNodes[0].nodeValue;
		try { rssText = itemList[i].getElementsByTagName("description")[0].childNodes[0].nodeValue; }
		catch(e){ rssText = "" }
	}
	resultText = '<a href="' + rssLink + '" CLASS="white">' + rssTitle + '</a> ' + '<SPAN STYLE=\"font-size:10px; color:#A0A0A0;\">[' + rssDate + ']</SPAN><BR>';
	$("result").innerHTML = resultText;
}
function loadPrev()
{
	httpObj = createXMLHttpRequest(displayPrev);
	if (httpObj)
	{
		httpObj.open("GET","/news/rss/index.rdf",true);
		httpObj.send(null);
	}
}
function displayPrev()
{
	if ((httpObj.readyState == 4) && (httpObj.status == 200))
	{
			parseRSS3(httpObj.responseXML);
	}else{
		$("result").innerHTML = "<FONT STYLE=\"font-size:10px; font-weight:600;\">LOADING ...</FONT>";
	}
}

function parseRSS3(sXML)
{
	var resultText = rssTitle = rssLink = rssText = rssDate = "";
	var itemList = sXML.getElementsByTagName("item");
	cnum = parseInt(i,10) - 1;
	i = "0" + cnum.toString(10);
	i = i.substr(i.length - 4, 4);
	if (i == 0)
	{
		document.pre.style.display = 'none';
	}
	if (i == itemList.length - 1)
	{
		document.next.style.display = 'none';
	} else if (i < itemList.length - 1) {
		document.next.style.display = 'block';
	}
	if (Safari)
	{
		rssTitle = itemList[i].childNodes[1].childNodes[0].nodeValue;
		rssLink = itemList[i].childNodes[3].childNodes[0].nodeValue;
		try { rssText = itemList[i].childNodes[5].childNodes[0].nodeValue; }catch(e){ rssText = "" }
	}else{
		rssDate = itemList[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue;
		rssTitle = itemList[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
		rssLink = itemList[i].getElementsByTagName("link")[0].childNodes[0].nodeValue;
		try { rssText = itemList[i].getElementsByTagName("description")[0].childNodes[0].nodeValue; }
		catch(e){ rssText = "" }
	}
	resultText = '<a href="' + rssLink + '" CLASS="white">' + rssTitle + '</a> ' + '<SPAN STYLE=\"font-size:10px; color:#A0A0A0;\">[' + rssDate + ']</SPAN><BR>';
	$("result").innerHTML = resultText;
}
