$(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");

    // Code to add in left/right image navigation on news START Cycle plugin must be added.
    $("#news-fading-image").hover(function() {
       $(".next").animate({opacity: "show"}, "fast");
     }, function() {
       $(".next").animate({opacity: "hide"});
     });
    
    $(".next").hide();
    
    $(".prev").hide();
    
    $("#news-fading-image").hover(function() {
          $(".prev").animate({opacity: "show"}, "fast");
      }, function() {
        $(".prev").animate({opacity: "hide"});
     });

          $("a.next-btn").hover(function() {
            $(".next").animate({opacity: "show"}, "fast");
         });

          $("a.prev-btn").hover(function() {
            $(".prev").animate({opacity: "show"}, "fast");
         });
});
    // Code to add in left/right image navigation on news END Cycle plugin must be added.
    // Code for rotating news with main image and should be pretty similar for all sites. May want to look at the fx and timeout to customize. .
$(function(){
    $('#news-fading-image').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 5000,
        prev:   '#prev',
        next:   '#next',
        cleartype: 1,
        pager:  '#news-fading-list',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#news-fading-list li:eq(' + (idx) + ') a';
        },
        pagerEvent: 'mouseover'
    });
        $('#ladder-content').cycle({
          fx:     'scrollLeft',
          speed:   300,
          timeout: 15000,
          cleartypeNoBg:   true,
          next:   '.next1',
          prev:   '.previous1'

        });    
});
// Code for rotating news with main emage and should be pretty similar for all sites. May want to look at the fx and timeout to customize. .
$(document).ready(
        function(){
          $('.sponsrotate').cycle({
            fx:    'fade',
            random: true,
            speed:  2000     
          });         
      });
// Code for auto scrolling content.  Will also need jquery.timers.js and jquery.autoScroller.js
$(window).load(function(){autoScroller('vmarquee', 2)});

// Code for search box removes the text when click there is also html5 for this but doesn't work in all browsers.
function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}

// Code for news wrap. Creates a loading bar whilst jquery is loading instead of displaying all the content down the page.
$(document).ready(function(){
$("#news-wrap").each(function(){
      $(this).removeClass("loadingcycle");
});
$(".loadingbox").each(function(){
      $(this).removeClass("loadingimage");
});
});

// TABS Code
    $(function(){
          $("ul.tabs").tabs("div.panes > div");
  });

            $(document).ready(function() {     
              $("#embed").replaceWith("<div id ='play-video'></div>");
              $.getJSON("http://gdata.youtube.com/feeds/api/users/eastlake2011/uploads?max-results=1&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='308' height='300' 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/eastlake2011/uploads?max-results=4&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>");
                  }
                });
              });   
            });  

