google.load("feeds", "1") //Load Google Ajax Feed API (version 1)

function rssdisplayer(divid, url, feedlimit, showoptions){
this.showoptions=showoptions || "" //get string of options to show ("date" and/or "description")
var feedpointer=new google.feeds.Feed(url) //create new instance of Google Ajax Feed API
feedpointer.setNumEntries(feedlimit) //set number of items to display
document.write('<div id="'+divid+'">Loading feed...</div>')
this.feedcontainer=document.getElementById(divid)
var displayer=this
feedpointer.load(function(r){displayer.formatoutput(r)}) //call Feed.load() to retrieve and output RSS feed
}




rssdisplayer.prototype.formatdate=function(datestr){
var itemdate=new Date(datestr)
return "<span class='dater'>"+itemdate.toLocaleString()+"</span>"
}

rssdisplayer.prototype.formatoutput=function(result){
if (!result.error){ //if RSS feed successfully fetched
var thefeeds=result.feed.entries //get all feed entries as a JSON array
var rssoutput="<div class=\"feed\">"
for (var i=0; i<thefeeds.length; i++){ //loop through entries
var itemtitle="<a class=\"titl\" href=\"" + thefeeds[i].link + "\"  target=\"_blank\">" + thefeeds[i].title + "<\/a>"
var itemdate=/date/i.test(this.showoptions)? this.formatdate(thefeeds[i].publishedDate) : ""
var itemdescription=/description/i.test(this.showoptions)? ""+thefeeds[i].content : ""
rssoutput+="<div class=\"descriptee\">" + "<div class=\"inner\">" + itemdate + " " + itemtitle + itemdescription + "<\/div>" + "<\/div>"
}
rssoutput+="<\/div>"
this.feedcontainer.innerHTML=rssoutput
}



else //else, output error
alert("Error fetching feeds: "+result.error.message)
}




$( function() {


 shortcut("u",function() {
    
    		$.scrollTo( '#begin', 333 );
       	
        
    });

    var current=1;
    shortcut("j",function() {
        if ($('#item_'+(current+1))[0]) {
    		current++;
    		$.scrollTo( '#item_'+current, 333 );
        }	
    	return false;
    });

    shortcut("k",function() {
    	if (current>1) {
    		current--;
    		$.scrollTo( '#item_'+current, 333 );
       		return false;
        }
    });

    pager_re=/page\=(\d+)/;

    shortcut("h",function() {
        var elem=$('.next');
        if (elem[0]) {
            window.location=elem.attr('href');
        }
        return false;
    });



    shortcut("l",function() {
        var elem=$('.prev');
        if (elem[0]) {
            window.location=elem.attr('href');
        }
    });
   

})




function showResult(str)
{
if (str.length==0)
  { 
  document.getElementById("livesearch").innerHTML="";
  document.getElementById("livesearch").style.border="0px";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
    document.getElementById("livesearch").style.border="1px solid #A5ACB2";
    }
  }
xmlhttp.open("GET","livesearch.php?q="+str,true);
xmlhttp.send();
}

$(document).ready(function(){
	$(".trigger_tw_affairs").click(function(){
		$(".panel_tw_affairs").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});


$(document).ready(function(){
	$(".trigger").click(function(){
		$(".panel").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});

$(document).ready(function(){
	$(".trigger_tw_design").click(function(){
		$(".panel_tw_design").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});

$(document).ready(function(){
	$(".trigger_tw_literary").click(function(){
		$(".panel_tw_literary").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});

$(document).ready(function(){
	$(".trigger_tw_commenters").click(function(){
		$(".panel_tw_commenters").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});







$(document).ready(function(){
	$(".m_literary").click(function(){
		$(".panel_m_literary").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});


$(document).ready(function(){
	$(".m_design").click(function(){
		$(".panel_m_design").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});

$(document).ready(function(){
	$(".m_music").click(function(){
		$(".panel_m_music").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});

$(document).ready(function(){
	$(".m_science").click(function(){
		$(".panel_m_science").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});

$(document).ready(function(){
	$(".m_socialsciences").click(function(){
		$(".panel_m_socialsciences").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});

$(document).ready(function(){
	$(".m_religious").click(function(){
		$(".panel_m_religious").slideToggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});



$(document).ready(function(){
 $(window).scroll(function(){
  // get the height of #wrap
  var h = $('#wrapper').height();
  var y = $(window).scrollTop();
if( y >= (h*.05) && y < (h*.99) ){
   // if we are show keyboardTips
   $("#clicknav").slideDown("slow");
  } else {
   $('#clicknav').slideUp('slow');
  }
 });
})

