EZDATA.searchQ_init = function(){
    // fix img src
    ezQuery(".ez-spotlights .ez-bio img").each(function() {
        var src = "http://static.foxsports.com" + ezQuery(this).attr("src");
        this.onerror = "";
        
        var errorFunc = function(){
            if (this.src == src){
                this.src='http://static.foxsports.com/fe/images/defaultPlayer140x170.jpg';
            }else if (this.src == 'http://static.foxsports.com/fe/images/defaultPlayer140x170.jpg'){
                ezQuery(this).hide();
            }else{
                this.src = src;
            }
        };
        
        ezQuery(this).bind("error", errorFunc);
    });
    // fix img dimensions
    ezQuery(".ez-spotlights #playerHeadshotImg img").attr("width", "140");
    ezQuery(".ez-spotlights #playerHeadshotImg img").attr("height", "170");
    ezQuery(".ez-spotlights #teamLogo img").attr("width", "80");
    ezQuery(".ez-spotlights #teamLogo img").attr("height", "80");
    
    // create header year into table.
    ezQuery(".ez-spotlights #playerHeadshotStats table").each(function(){
    	var firstTR = ezQuery("tr:first", this);
    	var statYearText = ezQuery(".ez-spotlights #playerHeadshotYear").html();
    	var statYearTitle = statYearText.replace(/season/i, "<b>STATS</b>");
    	firstTR.before(ezQuery('<tr><td colspan="4" class="statsYearBottom"><div class="snapshotTitle">'+statYearTitle+'</div></td></tr>'));
    });
    // move team name
    ezQuery(".ez-spotlights .ez-links").each(function(){
        var linksEl = ezQuery(this);
        linksEl.after(ezQuery("#teamName", linksEl.parent().parent()));
    });
    // move team name from team card and replace br tag and remove bold tag.
    ezQuery(".ez-spotlights .ez-team .ez-name").each(function(){
        var linksEl = ezQuery(".ez-spotlights .ez-team #teamRecord");
        var oldTeamTags = ezQuery("#teamName").html();
        var teamTags = oldTeamTags.replace(/<br[^>]*>/gi,"&nbsp;").replace(/\<b\/?\>/gi,"");
        ezQuery("#teamName").html(teamTags);
        linksEl.before(ezQuery("#teamName"));
    });
    
    // add bio label
    ezQuery(".ez-spotlights #teamRecord").each(function(){
        var linkElFirst = ezQuery("a:first", this);
        linkElFirst.before(ezQuery('<div class="gray200HdrTitle">Team Bio:</div>'));
    });
    // wrap img with href
    ezQuery(".ez-spotlights #playerHeadshotImg img").each(function() {
    	var linkHref = ezQuery(".ez-spotlights .ez-player .ez-bio .ez-bio-info .ez-playerName a").attr("href");
    	ezQuery(this).wrap('<a href="' + linkHref + '" />');
    });
    // fix link hrefs
    ezQuery(".ez-spotlights .ez-team #playerHeaderBody a").each(function() {
        var linkHref = ezQuery(this).attr("href");
        ezQuery(this).attr("href", "http://msn.foxsports.com" + linkHref);
    });
    
};

ezQuery(document).ready(function(){
    //Add click functionality to the description layovers of the more video section
    ezQuery(".ez-thumbs a",".ez-relatedVideos").each(function(){
        var thumb = ezQuery(this);
        thumb.attr("title", "");
        var desc = ezQuery(".ez-main .ez-desc", thumb.parent().parent());
        desc.bind("click", function(){
                window.location = thumb.attr("href");
        });
    });
    //dimensions for layover descriptions
    ezQuery(".ez-relatedVideos .ez-itemMod-item .ez-desc").each(function(){
        var hl = ezQuery(this);
        var tn = ezQuery(".ez-thumbs", hl.parent().parent());
        hl.css("width", (tn.width() - 10) + "px");
        hl.css("height", (tn.height() - 59) + "px");
    });
});

ezQuery(window).bind('load', function() {
    // player default image
    var playerImage = ezQuery(".ez-mainContent .ez-itemMod li[class*=Player] .ez-thumbs img");
    playerImage.each(function(){
        if((typeof this.naturalWidth != "undefined" &&
                this.naturalWidth == 0 ) 
                || this.readyState == 'uninitialized' ) {
            ezQuery(this).attr('src', 'http://static.foxsports.com/fe/images/defaultPlayer140x170.jpg');
        }
    });
    playerImage.attr('style', 'width:45px;height:60px;');
});

EZDATA.searchPage_show_relatedVideos = function(){
    ezQuery(".ez-page-search-google .ez-itemMod.ez-relatedVideos").show();
};

