/* RSS functions */
/* Copyright 2005, Douglas E. Greathouse */

url="http://www.sinclair.edu/centers/wc/pub/rss/"

// Screen object

document.write("<center><fieldset style='width=350px'><legend align='center'><b>Writing Center RSS Feed</b></legend><br />");
document.write("<a href='" + url + "rssfeed.xml'><img border='0' src='" + url + "xml.gif'><img border='0' src='" + url + "xrss.gif'></a>");
document.write("&nbsp;&nbsp;<button onclick=\"readRSS('" + url + "rssfeed.xml')\">View Feed</button>");
document.write("&nbsp;&nbsp;<button onclick=\"whatisthis()\">What is this?</button>");
document.write("<br /><br /></fieldset></center>" );





// What is this function

function whatisthis() {

//Set window size
	intWidth = 500;
	intHeight = 500;

//If window height or width are greater than screen size, adjust to maximum size available 
	intWidth>screen.availWidth ? intWidth = screen.availWidth : intWidth=intWidth;
	intHeight>screen.availHeight ? intHeight = screen.availHeight : intHeight=intHeight;

//Compute offset to center window on screen
	intLeft = (screen.availWidth - intWidth) / 2;
	intTop = (screen.availHeight - intHeight) / 2;

//Set window features
	strWinFeatures = "width=" + intWidth;
	strWinFeatures += ",height=" + intHeight;
	strWinFeatures += ",left=" + intLeft;
	strWinFeatures += ",top=" + intTop;
	strWinFeatures += ",directories=no";
	strWinFeatures += ",location=no";
	strWinFeatures += ",menubar=no";
	strWinFeatures += ",resizable=yes";
	strWinFeatures += ",scrollbars=yes";
	strWinFeatures += ",status=no";
	strWinFeatures += ",toolbar=no";
	strWinFeatures += ",titlebar=yes";
	strWinFeatures += ",personalbar=no";

//Create unique instance
strDate = new Date();
strWinName = strDate.getDate() + strDate.getHours() + strDate.getMinutes() + strDate.getSeconds();

var display=window.open('', strWinName , strWinFeatures);
  
display.document.write('<html><head><title>What\'s this? About RSS</title></head><body>');

display.document.write('<table border="0" cellpadding="10" width="100%">');

display.document.write('<p><b>What is RSS?</b></p>');

display.document.write('<blockquote><p><u><b>R</b></u>eally <b><u>S</u></b>imple <b><u>S</u></b>yndication (RSS) feeds are free information feeds from Internet web sites like this one which contain article headlines and summaries along with links to the full-text web content.</p></blockquote>');

display.document.write('<p><b>What are the benefits of using RSS?</b></p>');

display.document.write('<blockquote><p>RSS provides an incredibly easy way to be alerted when content of interest appears on a particular website. Instead of periodically visiting a particular Web site to browse for new articles and features, RSS automatically tells you when something new is posted.</p></blockquote>');

display.document.write('<p><b>What do I need to use RSS?</b></p>');

display.document.write('<blockquote><p>To start using RSS, you need a special newsreader (sometimes called an aggregator) that displays RSS content feeds from the web sites you select. There are a variety of different newsreaders available, many of which are free of charge. Most are available as desktop software that can be downloaded and installed on your computer; however, several web-based news readers are available as well.</p>');

display.document.write('<p><a href="http://dir.yahoo.com/Computers_and_Internet/Data_Formats/XML__eXtensible_Markup_Language_/RSS/Aggregators/" target="_blank">Yahoo\'s list of RSS newsreaders</a><br />');

display.document.write('<a href="http://directory.google.com/Top/Reference/Libraries/Library_and_Information_Science/Technical_Services/Cataloguing/Metadata/RDF/Applications/RSS/News_Readers/" target="_blank">Google\'s list of RSS newsreaders</a></p>');

display.document.write('<p>Once you have installed the newsreader software, simply subscribe to the RSS feeds you want.</p></blockquote>');

display.document.write('<p><b>How can I subscribe to RSS feeds from this website?</b></p>');

display.document.write('<blockquote><p>To subscribe to the RSS feeds from a website, simply right click on the orange <span style="background-color: #ff6600" title="Extensible Markup Language">');

display.document.write('<font color="#ffffff"><b>&nbsp;XML&nbsp;</b></font></span> button or the blue <b><span style="background-color: #0066ff" title="Really Simple Syndication">');

display.document.write('<font color="#ffffff">&nbsp;RSS&nbsp;</font></span></b> button and save the url. Next, paste the saved url into the RSS reader according to its instructions.');

display.document.write(' Once subscribed, the current feed will be displayed in the newsreader\'s window and will automatically remain updated as new content is published.</p></blockquote>');

display.document.write('</table>');

display.document.write('<table border="0" cellpadding="10" width="100%">');

display.document.write('<tr>');
display.document.write('<td align="center"><input type="button" value="CLOSE" name="btnClose" onclick="return window.close();"></td>');
display.document.write('<td align="center"><input type="button" value="PRINT" name="btnPrint" onclick="return window.print();"></td>');
display.document.write('</tr>');

display.document.write('<tr>');
display.document.write('<td colspan="2" align="center"><h6>&copy; 2005 Sinclair Community College. All rights reserved.</h6></td>');
display.document.write('</tr>');

display.document.write('</table>');

display.document.write('</body></html>');

display.document.close();

}

// Display RSS feed function

function readRSS(URI) {

//Set window size
	intWidth = 500;
	intHeight = 500;

//If window height or width are greater than screen size, adjust to maximum size available 
	intWidth>screen.availWidth ? intWidth = screen.availWidth : intWidth=intWidth;
	intHeight>screen.availHeight ? intHeight = screen.availHeight : intHeight=intHeight;

//Compute offset to center window on screen
	intLeft = (screen.availWidth - intWidth) / 2;
	intTop = (screen.availHeight - intHeight) / 2;

//Set window features
	strWinFeatures = "width=" + intWidth;
	strWinFeatures += ",height=" + intHeight;
	strWinFeatures += ",left=" + intLeft;
	strWinFeatures += ",top=" + intTop;
	strWinFeatures += ",directories=no";
	strWinFeatures += ",location=no";
	strWinFeatures += ",menubar=no";
	strWinFeatures += ",resizable=yes";
	strWinFeatures += ",scrollbars=yes";
	strWinFeatures += ",status=no";
	strWinFeatures += ",toolbar=no";
	strWinFeatures += ",titlebar=yes";
	strWinFeatures += ",personalbar=no";

//Create unique instance
strDate = new Date();
strWinName = strDate.getDate() + strDate.getHours() + strDate.getMinutes() + strDate.getSeconds();

//Create a named window
var display=window.open('', strWinName , strWinFeatures);




if(window.ActiveXObject) {
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async=false;
	while(xmlDoc.readyState!=4) display.document.write('Loading...');
	}
else if(document.implementation&&document.implementation.createDocument)
	xmlDoc=document.implementation.createDocument("","doc",null);
	xmlDoc.load(URI);
	items=xmlDoc;
	function verify() {if(xmlDoc.readyState!=4) return false;}

function formatRSS() {
var items_count=items.getElementsByTagName('item').length;
var pubDate=new Array(), date=new Array, link=new Array(), title=new Array(), description=new Array(), guid=new Array();

for(var i=0; i<items_count; i++) {
	if(items.getElementsByTagName('item')[i].getElementsByTagName('pubDate').length==1)
		pubDate[i]=items.getElementsByTagName('item')[i].getElementsByTagName('pubDate')[0];
	if(items.getElementsByTagName('item')[i].getElementsByTagName('dc:date').length==1)
		date[i]=items.getElementsByTagName('item')[i].getElementsByTagName('dc:date')[0];
	if(items.getElementsByTagName('item')[i].getElementsByTagName('link').length==1)
		link[i]=items.getElementsByTagName('item')[i].getElementsByTagName('link')[0];
	if(items.getElementsByTagName('item')[i].getElementsByTagName('guid').length==1)
		guid[i]=items.getElementsByTagName('item')[i].getElementsByTagName('guid')[0];
	if(items.getElementsByTagName('item')[i].getElementsByTagName('title').length==1)
		title[i]=items.getElementsByTagName('item')[i].getElementsByTagName('title')[0];
	if(items.getElementsByTagName('item')[i].getElementsByTagName('description').length==1)
		description[i]=items.getElementsByTagName('item')[i].getElementsByTagName('description')[0];
	}


if((description.length==0)&&(title.length==0)) return false;

	display.document.write('<html><head><title>'+xmlDoc.getElementsByTagName('title')[0].firstChild.nodeValue+'</title></head><body>');
	display.document.write('<span style="font-family:verdana,arial,helvetica; font-size:8pt">');
	display.document.write('<a href="'+xmlDoc.getElementsByTagName('link')[0].firstChild.nodeValue+'"><h3 align="center">' + 		xmlDoc.getElementsByTagName('title')[0].firstChild.nodeValue +'</h3></a>');
	display.document.write('<p>'+xmlDoc.getElementsByTagName('description')[0].firstChild.nodeValue+'</p>');
	var ws=/\S/; 

	for(var i=0; i<items_count; i++) {
		var pubDate_w, title_w, link_w;
		pubDate_w=(pubDate.length>0)?pubDate[i].firstChild.nodeValue:"<i>Date NA</i>";
			if(document.all)
				title_w=(title.length>0)?title[i].text:"<i>Untitled</i>";
			else
				title_w=(title.length>0)?title[i].firstChild.nodeValue:"<i>Untitled</i>";

			link_w=(link.length>0)?link[i].firstChild.nodeValue:"";
			if(link.length==0) link_w=(guid.length>0)?guid[i].firstChild.nodeValue:"";
			if(title.length>0) title_w=(!ws.test(title_w))?"<i>Untitled</i>":title_w;
			if(pubDate.length==0) pubDate_w=(date.length>0)?date[i].firstChild.nodeValue:"<i>Date NA</i>";
			display.document.write('<a target="_blank" href="'+link_w+'"><b>'+title_w+'</b></a> <b>['+pubDate_w+']</b><br>');
			if(description.length>0)
				display.document.write('<font size="-1">'+description[i].firstChild.nodeValue+'</font><br><br>');
		}
display.document.write('<table border="0" cellpadding="10" width="100%">');
display.document.write('<tr>');
display.document.write('<td align="center"><input type="button" value="CLOSE" name="btnClose" onclick="return window.close();"></td>');
display.document.write('<td align="center"><input type="button" value="PRINT" name="btnPrint" onclick="return window.print();"></td>');
display.document.write('</tr>');
display.document.write('<tr>');
display.document.write('<td colspan="2" align="center"><h6>&copy; 2005 Sinclair Community College. All rights reserved.</h6></td>');
display.document.write('</tr>');
display.document.write('</table>');
display.document.write('</span></body></html>');
display.document.close();
	}

if(typeof(xmlDoc)!="undefined") {
	if(window.ActiveXObject) formatRSS();
	else xmlDoc.onload=formatRSS;
	}
}






