jQuery(function($) {



    $('#profile').click( function() {
	if($(this).hasClass('closed')) {
	    $('#globalwrapper').animate({"marginLeft": "+=190px"}, "slow", "linear", function() {
		$('#globalwrapper').css('margin-left',"270px");
		$('#profile').removeClass('closed').addClass('open');
	    });
	}
	
	if($(this).hasClass('open')) {
	    $('#globalwrapper').animate({"marginLeft": "-=190px"}, "slow", "linear", function() {
		$('#globalwrapper').css('margin-left',"70px");
		$('#profile').removeClass('open').addClass('closed');
	    });
	}
    });
    
    $('.trackevent').click( function() {
	if($(this).attr('rel') != "") {
	    pageTracker._trackEvent('click', '/'+$(this).attr('rel'));
	}
    });
    
    fillBookmarks("bookmarks","http://www.google.com/reader/public/javascript/user/16526000983254420641/state/com.google/broadcast?n=4&callback=?");
});


function fillBookmarks(catid, url) {
   $.getJSON(url,
      function(json){
               i= 1;
    	       $(json.items).each( function() {
                  first= "";
                  if(i == 1) {
                     first= " first ";
                  }
                  content= this.annotations;

                  block= "";
                  block+= "<a class='bookmark' href='"+this.alternate.href+"'>"+this.title+"</a>";
                  
                  $("#"+catid).append(jQuery(block));
                  
                  
                  if ( i == 5 ) { return false; }
                  i++;
               });
   });
}