function get_rss_feed(feedurl) {
	//clear the content in the div for the next feed.

	$j("#feedContent").empty();
	//use the JQuery get to grab the URL from the selected item, put the results in to an argument for parsing in the inline function called when the feed retrieval is complete
	$j.get('/cron/proxy.php?url='+feedurl, function(d) {
		
		//find each 'item' in the file and parse it
		$j(d).find('item').each(function() {
			
			//name the current found item this for this particular loop run
			var $jitem = $j(this);
			// grab the post title
			var title = $jitem.find('title').text();
			// grab the post's URL
			var link2 = $jitem.find('link').text();
			// next, the description
			var description = $jitem.find('description').text();
			//don't forget the pubdate
			var pubDate = $jitem.find('pubDate').text();
			
			var low = /low/;
			var med = /med/;
			var high = /high/;
			
			var string1 = description;
			var matchPos1 = string1.search(low);
			var matchPos2 = string1.search(med);
			var matchPos3 = string1.search(high);
			
			
			if(matchPos1 != -1) {
				var html = "<li class=\"riverlevel\" style=\"background: #FFFF99;\"><h2 class=\"postTitle\">" + title + "<\/h2>";
				html += "<em class=\"date\">" + pubDate + "</em>";
				html += "<span class=\"rssLinkListItemDesc\" name=\"level\">" + description + "</span>";
				html += "<br /><a href=\"" + link2 + "\" target=\"_blank\" alt=\"more information on "+ title +"\">More Details >><\/a><\/li>";
			}
			else if(matchPos2 != -1) {
				var html = "<li class=\"riverlevel\" style=\"background: #99FF99;\"><h2 class=\"postTitle\">" + title + "<\/h2>";
				html += "<em class=\"date\">" + pubDate + "</em>";
				html += "<span class=\"rssLinkListItemDesc\" name=\"level\">" + description + "</span>";
				html += "<br /><a href=\"" + link2 + "\" target=\"_blank\" alt=\"more information on "+ title +"\">More Details >><\/a><\/li>";
			}	
			else if(matchPos3 != -1) {
				var html = "<li class=\"riverlevel\" style=\"background: #FF9999;\"><h2 class=\"postTitle\">" + title + "<\/h2>";
				html += "<em class=\"date\">" + pubDate + "</em>";
				html += "<span class=\"rssLinkListItemDesc\" name=\"level\">" + description + "</span>";
				html += "<br /><a href=\"" + link2 + "\" target=\"_blank\" alt=\"more information on "+ title +"\">More Details >><\/a><\/li>";
			}						
			else {
				var html = "<li class=\"riverlevel\"><h2 class=\"postTitle\">" + title + "<\/h2>";
				html += "<em class=\"date\">" + pubDate + "</em>";
				html += "<span class=\"rssLinkListItemDesc\" name=\"level\">" + description + "</span>";
				html += "<br /><a href=\"" + link2 + "\" target=\"_blank\" alt=\"more information on "+ title +"\">More Details >><\/a><\/li>";
			}
			
			//put that feed content on the screen!
			$j('#feedContent').append($j(html));  
		});
	});
	
};

function navUi() {
	$j.each($j("#container-1 ul li a"), function(){
		$j("#container-1 ul li a").parent().removeClass('ui-tabs-selected');
	});		
}

$j(document).ready(function(){
var $jj = jQuery.noConflict();
						   
	get_rss_feed('http://americanwhitewater.org/content/River/state-summary/state/PA/.rss');
	
	$j("#container-1 ul li a").click(function(){
		navUi();
		$j(this).parent().addClass('ui-tabs-selected');
		var domurl = $j(this).attr('href');
		get_rss_feed(domurl);
		
		return false;
	});
});

