Cufon.replace('.lnk-donation, .module-nav > ul > li > a, h1, h2, h3, .avatar-text h4, .module-tabs a, .lnk-more, h3.event-byline, h4, .bg-holder a, .program-format', { fontFamily: 'GeometricSlab', hover: true, ignoreClass: 'nocufon' });


$(document).ready(function () {
    $("body").prepend($('.onair-rollover'));
    $("a.onair").mouseover(function () {
        $('.onair-rollover').animate({ opacity: 1 }).css('top', (e.pageY + 20) + 'px').css('left', e.pageX);
    }).mouseout(function () {
        $('.onair-rollover').stop().animate({ opacity: 0 });
    }).mousemove(function (e) {
        $('.onair-rollover').css('top', (e.pageY + 20) + 'px');
        $('.onair-rollover').css('left', e.pageX);
    });
    $(".days-list li:last-child, .program-times li:last-child").addClass("last-child");
    $(".program-day-container div:last-child").addClass("last-child");


    $('input.datepicker').live('click', function () {
        $(this).datepicker({ showOn: 'focus',
            changeMonth: true,
            changeYear: true,
            dateFormat: 'dd/mm/yy'
        }).focus();
    });

    $('input.timepicker').timeEntry({ spinnerImage: '' });

    $('input.timepicker').live('click', function () {
        $(this).focus();
        $(this).timeEntry({ spinnerImage: '' });
    });
});

jQuery.fn.equalCols = function () {
    var sortNumber = function (a, b) { return b - a; };
    var heights = [];
    $(this).each(function () {
        heights.push($(this).height());
    });
    heights.sort(sortNumber);
    var maxHeight = heights[0]+10;
    return this.each(function () {
        $(this).css({ 'min-height': maxHeight }); // Do a fix for IE
        if ($.browser.msie && $.browser.version == "6.0") {
            $(this).css({ 'height': maxHeight }); // Do a fix for IE6
        }
    });
};

function showArtistPlayList(page) {
    var resultContainre = $('.playlist_content');
    $.ajax({
        type: "POST",
        url: '/Artists/PlayList',
        data: ({ artistId: $('#artistId').val(), page: Number($('#page').val()) + Number(page), date: $('#date').val() }),
        dataType: "html",
        cache: false,
        success: function (msg) {
            $(resultContainre).html(msg);
            Cufon.replace('.module-event-info h2')
            return false;
        },
        error: function (x, e) {
            alert('An error has occured. Please refresh the page and try again.');
        }
    });
    return false;
};

    function checkClear() {
        if (document.getElementById('ctl00_ctlGloEventSearch_txtSearch').value == 'Search') 
            document.getElementById('ctl00_ctlGloEventSearch_txtSearch').value = '';
    }
    
    //onblur="if(this.value=='') this.value='Search';" onfocus="if(this.value=='Search')this.value='';"
    //UPDATE: fbi wishlist 5/5/2011 removal of search options
    $(document).ready(function () {
        //$("#searchType").hide();
        searchFunctions.init('kwd', 'searchType');
        $('.search-results li').equalCols();
    });

    var searchFunctions = {
        searchFieldObj: '',
        //searchTypeCtrObj: '',
        searchClickFromTypes: 0,
        init: function(srchFieldId, srchTypeCtrId) {
            searchFunctions.searchFieldObj = $('#' + srchFieldId);
            //searchFunctions.searchTypeCtrObj = $('#' + srchTypeCtrId);
            //alert(searchFunctions.searchTypeCtrObj.height());
            //var searchTypeHeight = searchFunctions.searchTypeCtrObj.height() - 10;
            //searchFunctions.searchTypeCtrObj.css('bottom', '-' + searchTypeHeight + 'px');
            searchFunctions.bindEvents();
        },
        bindEvents: function() {
            //searchFunctions.bindClickEvent();
            //searchFunctions.bindBlurEvent();
            searchFunctions.bindFocusEvent();
        },
        bindClickEvent: function() {
            searchFunctions.searchTypeCtrObj.find(':radio').click(function() {
                searchFunctions.searchClickFromTypes = 1;
                searchFunctions.searchFieldObj.focus();
            });
        },
        bindBlurEvent: function() {
            searchFunctions.searchFieldObj.blur(function(e) {
                setTimeout('searchFunctions.hideSearchTypes()', 300);
            });
        },
        hideSearchTypes: function() {
            if (searchFunctions.searchClickFromTypes == 0) {
                if (searchFunctions.searchFieldObj.val() == '') searchFunctions.searchFieldObj.val('Search');
                searchFunctions.searchTypeCtrObj.fadeOut(100);
            }
            searchFunctions.searchClickFromTypes = 0;
        },
        bindFocusEvent: function() {
            searchFunctions.searchFieldObj.focus(function() {
                if (searchFunctions.searchFieldObj.val() == 'Search') searchFunctions.searchFieldObj.val('');
//                if (searchFunctions.searchTypeCtrObj.is(':hidden')) {
//                    searchFunctions.searchTypeCtrObj.css('display', 'inline');
//                    searchFunctions.searchTypeCtrObj.hide();
//                    searchFunctions.searchTypeCtrObj.fadeIn(100);
//                }
            });

        }
    };

    function formatMyDate(dateStr) {
        return dateStr.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i, '$1,$2$4$3');
    };

    function removeGMTorUTC(dateStr) {
        var noGMT = dateStr.replace(/^(.*)(:\d\d GMT+)(.*)$/i, '$1');  // Trim string like 'Thu Apr 21 2011 14:08:46 GMT+1000 (AUS Eastern Standard Time)'
        var noUTC = noGMT.replace(/^(.*)(:\d\d UTC+)(.*)$/i, '$1');    // Trim string like 'Thu Apr 21 14:08:46 UTC+1000 2011'
        return noUTC;
    };

    $(function () {
        // Module Twitter
        var tweetCount = 1;
        jQuery('.twitter-feed').jTweetsAnywhere({
            username: _tweeterUserName,
            count: 30,
            searchParams: ['q=from%3A' + _tweeterUserName],
            tweetTimestampDecorator: function (tweet, options) {
                var tweetDate = new Date(Date.parse(formatMyDate(tweet.created_at)));
                var dateString = removeGMTorUTC(tweetDate.toString());
                return '<p class="twitter-date">' + dateString + '</p>';
            },
            tweetDecorator: function (tweet, options) {
                var html = '';
                // Show only the tweets that are not replies or oldstyle retweets:
                //if (!(tweet.in_reply_to_screen_name || /^RT/i.test(tweet.text))) {
                if (tweetCount <= 4 && (!(tweet.to_user || /^RT/i.test(tweet.text)))) {
                    tweetCount++;
                    html = '<li class="jta-tweet-list-item">';
                    if (options.tweetProfileImagePresent)
                        html += options.tweetProfileImageDecorator(tweet, options);
                    if (options.tweetBodyDecorator)
                        html += options.tweetBodyDecorator(tweet, options);
                    html += '<div class="jta-clear">&nbsp;</div>';
                    html += '</li>';
                }
                return html;
            }
        });
    });


    
