$(document).ready(function() {

    // Add pdf icons to pdf links
    $("a[href$='.pdf']").addClass("pdf");
 
    // Add txt icons to document links (doc)
    $("a[href$='.doc'], a[href$='.docx']").addClass("doc");
    
    $("a[href$='.txt'], a[href$='.rft']").addClass("txt");
 
    // Add zip icons to Zip file links (zip, rar)
    $("a[href$='.zip'], a[href$='.rar']").addClass("zip");
 
    // Add email icons to email links
    $("a[href$='.xls'], a[href$='.xlsx']").addClass("excel");

    $("#news-fading-image").hover(function() {
       $(".next").animate({opacity: "show"}, "fast");
     }, function() {
       $(".next").animate({opacity: "hide"});
     });
    

		 
	$("#embed").replaceWith("<div id ='play-video'></div>");
	$.getJSON("http://gdata.youtube.com/feeds/api/users/footyefl/uploads?max-results=1&orderby=published&v=2&alt=jsonc&callback=?", function(data) {
		var dataContainer = $("#play-video");
		$.each(data.data.items, function(i, val) {
			if (typeof(val.player) !== 'undefined' && typeof(val.title) !== 'undefined') {
				dataContainer.append("<iframe width='284' height='220' src='http://www.youtube.com/embed/"+val.id+"?rel=0&autohide=1&amp;wmode=transparent' frameborder='0' name='vid-frame' id='vid-fade' allowfullscreen></iframe>");
			}
        });
    });
    $("#videos").replaceWith("<div id ='thumbs'></div>");
    $.getJSON("http://gdata.youtube.com/feeds/api/users/footyefl/uploads?max-results=4&orderby=published&v=2&alt=jsonc&callback=?", function(data) {
        var dataContainer = $("#thumbs");
        $.each(data.data.items, function(i, val) {
            if (typeof(val.player) !== 'undefined' && typeof(val.title) !== 'undefined') {
                dataContainer.append("<div class='vid-thumb thumb-id-"+ (i+1) +"'><a href = 'http://www.youtube.com/embed/"+val.id+"?rel=0' target = 'vid-frame' id='click-vid'><img src='"+val.thumbnail.sqDefault+"' width='68'></a></div>");
			}
        });
    });	 
});

$(function(){
    $('#news-fading-image').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 5000,
        prev:   '#prev',
        next:   '#next',
        cleartype: 1,
        pager:  '#news-fading-list',
        pagerEvent: 'mouseover'
    });
    $('#rss-1 #twrss_table').cycle({
	fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
    $('#rss-2 #twrss_table').cycle({
	fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
});
