  $(document).ready(function(){

       // If there is a Bulletin, display that feed

       $.getFeed({
            url: '/web/feeds/bulletins.rss',
            success: function(feed) {
            var html = '';
                        var cnt = 0;
            for(var i = 0; i < feed.items.length && i < 4; i++) {
                                cnt++;
                var item = feed.items[i];
                html += '<p class="uni-news-head"><strong><a href="' + item.link + '">' + item.title + '</a></strong></p><p class="uni-news-body">' + item.description  + '</p>';
            }

            if (cnt >0) {
               $('#bulletin-title').append("<h1>University Bulletins</h1>")
               $('#bulletins').append(html);
            }
            }
        });


       // $('.slide .hideonload').css('display','block'};
        $.getFeed({
            url: '/yfile/rss/yfile_homepage_tag.rss',
            success: function(feed) {
            var html = '';
            var pubDate = '';
            var m_names = new Array("January", "February", "March",
            "April", "May", "June", "July", "August", "September",
            "October", "November", "December");

            for(var i = 0; i < feed.items.length && i < 3 ; i++) {
                var item = feed.items[i];
                var d  = new Date(item.updated);
                var curr_date = d.getDate();
                var curr_month = d.getMonth();
                curr_month++;
                var curr_year = d.getFullYear();
                var pubDate = m_names[curr_month-1] + " " + curr_date + ", " + curr_year + ' - '; 

                html += '<p class="uni-news-head"><strong><a href="' + item.link + '">' + item.title + '</a>' + '</strong></p><p class="uni-news-body">' + item.description + '</p>';
            } 
            jQuery('#yfile-news').append(html);
            jQuery('#yfile-news').append('<a id="yfile-link" target="_blank" href="http://yfile.news.yorku.ca/" style="color:#CC0000; text-transform:uppercase; font-size:0.7em;">More University News >></a>')}
        });
		
        $.getFeed({
            url: '/yuevents/rssfeeds/private_180.rss',
            success: function(feed) {
            var html = '';
            for(var i = 0; i < feed.items.length && i < 4; i++) {
                var item = feed.items[i];
                html += '<div class="slide"><p><strong>' + '<a href="' + item.link + '">' + item.title + '</a>' + '</strong></p></div>';
            }
            $('#events-feed').append(html);
			$("#events").slides( {
				preload: false,
				preloadImage: 'images/loading.gif',
				play: 9000,
				pause: 3500,
				hoverPause: true,
				generatePagination: false,
				pagination: false
			}); 
				  
	    }
        });


        $.getFeed({
            url: '/web/feeds/spotlight.xml',
            success: function(feed) {
            var html = '';
            for(var i = 0; i < feed.items.length && i < 10; i++) { 
                var item = feed.items[i];
		html += '<div class="slide"><p><strong><a href="' + item.link + '">' + item.title + '</a></strong><br />' + item.description  + '</p></div>';
	    }
            $('#spotlight-feed').append(html);
			
			$("#spotlight").slides( {
				preload: false,
				preloadImage: 'images/loading.gif',
				play: 8000,
				pause: 2500,
				hoverPause: true,
				generatePagination: false,
				pagination: false
			});
						
			
			//$('#spotlight').flips( { stop_autorun: true, direction: 'left'});
			    
	    }
        });

		

   	 $("#slides").slides( {

				preload: false,
				crossfade: true,
				effect: 'fade',
				preloadImage: 'images/loading.gif',
				play: 8000,
				pause: 2500,
				hoverPause: true,
				animationStart: function(current){
					//$('.caption').animate({
					//	bottom:-35
					//},100);
					if (window.console && console.log) {
						// example return of current slide number
						//console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					//$('.caption').animate({
					//	bottom:0
					//},200);
					if (window.console && console.log) {
						// example return of current slide number
						//console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					//$('.caption').animate({
					//	bottom:0
					//},200);
				}

	}); 
	 
	 
	 	$("#spotlight-feed a").live('click',function(event) {  

                testURL = this.href;
                if ( testURL.indexOf("youtube.com") == -1) {
                   return true;
		} else {
			
		  $.fancybox({
			'padding'		: 5,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 480,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true',
				'autoplay'	: 'true'
			}
		  });
	          return false;
	       }
	});
		
  });


