﻿

$(document).ready(function()
{
    // turn off border line around nav links
    $('#nav li.active').next().addClass('bgoff');
    $('#nav li').not('.active').children('a').hover(
        function() {
            var li = $(this).parents('li');
            li.next().addClass('bgoff');
            li.addClass('bgoff');
        },
        function() {
            var li = $(this).parents('li');
            li.next().removeClass('bgoff');
            
            // keep bg off for active
            if (li.prev().hasClass('active') == false) {
                li.removeClass('bgoff');
            }
        }
    );
    
    // onrollover button for form submit image buttons - toggle "ovr" to the filename
    $("form input[type='image'][src*='css/images/form_submit-']").hover(
        function () {
            $(this).attr('src', function() {
                return this.src.replace('.png', '_ovr.png');
            });
        },
        function () {
            $(this).attr('src', function() {
                return this.src.replace('_ovr', '');
            });
        }
    );  
    
});

function feed_load(){
	var feed = new google.feeds.Feed("http://www.greenpeace.org.uk/rss/gobeyondoil.xml");
	feed.load(function(result) {
	  if (!result.error) {
	  var container = document.getElementById("result");
	  for (var i = 0; i < result.feed.entries.length; i++) {
	  var entry = result.feed.entries[i];
	  var div = document.createElement("li");
	  var time = jQuery.timeago(new Date(entry.publishedDate));
	  var html = "<h3><a href='" + entry.link + "' class='title'>";
		  html += entry.title + "</a></h3>";
		  html += "<p>" + entry.contentSnippet;
		  html += "<span class='date'>" + time + "</span></p>";
		  div.innerHTML = html;
		  container.appendChild(div);
		 }
	  }
	});  
}
