
/*   
 *   
 *   TTTTTTTT EEEEE  CCCC
 *      TT    E     C    C
 *      TT    EEE   C
 *      TT    E     C    
 *      TT    EEEEE  CCCCC  DIGITAL MEDIA HUB
 *   
 *   _______ function definitions ___________
 *   
 *   
*/




ACTIONS.Branding.Show = function(self) {
    $('div#branding').animate({
        top: '0px',
        queue: false
    }, 1000, SETTINGS.Visuals.BrandingSlideDownEasingEffect);
    $('div#stage div#search').animate({top: '287px', queue: false}, 1000, SETTINGS.Visuals.BrandingSlideDownEasingEffect);
};

ACTIONS.Branding.Hide = function(self) {
    $('div#branding').animate({
        top: '-289px',
        queue: false
    }, 1000, SETTINGS.Visuals.BrandingSlideDownEasingEffect);
    $('div#stage div#search').animate({top: '-2px', queue: false}, 1000, SETTINGS.Visuals.BrandingSlideDownEasingEffect);
};

ACTIONS.Branding.ToggleVisible = function() {
    //var self = $('div#stage div#search');
    if ( $('div#branding').css('top') <= '-320px' ) {
        ACTIONS.Branding.Show();
    }
    else {
        ACTIONS.Branding.Hide();
    }
};




/*
 * LIVE LIVE LIVE
 * triggers when you click the link with the ID
 * of "videoCPLShowLive" - lists LIVE videos only
 *
 */
ACTIONS.VIDEO.ShowLive = function() {
    // hide the chat window, if it's open
    ACTIONS.CHAT.Hide();
    var currentVideoID = -1;
    if ( arguments.length >= 1 ) {
        currentVideoID = arguments[0]; // ignore the rest, we just want the one, optionally
    }
    $('div#videoInformation div#videoCPL').empty().html(
        '<img src="' + SETTINGS.Visuals.LoadingIconURL + '" border="0" />'
    );
    // show the info for the CURRENTLY playing vid
    var shtml = '';
    $.get( baseURL + 'import/videos_live.import.php', {format:'live'}, function(objJSON) {
        // FAILSAFE in case there are no live streams, since this will try to load VOD anyway
        if ( objJSON.collectionType == 'vod' ) {
            $('div#videoInformation div#videoCPL').empty().html(
                '<h1 id="currentVODTitle">No Live Streams</h1>' +
                "\n<p class=\"currentVODDescriptionEN\">" + 'There are currently no live streams available. Check out our <a href="javascript:void(0);" onclick="$(\'#videoCPLShowVOD\').click();">&quot;on demand&quot;</a> videos and catch up with what\'s been going on!</p>'
            );
            return;
        }
        // END FAILSAFE
        if ( objJSON.videos.length >= 1 ) {
            for ( var i = 0; i < objJSON.videos.length; i++ ) { 
                // if this item in the loop is the CURRENT vid, refunk it's info pls thx
                if ( i == VIDEOS.CurrentLiveID ) { VIDEOS.CurrentLiveInfo = objJSON.videos[i]; }
                //trace('VID: ' + i);
                shtml += "\n" + '<a href="' + unescape(objJSON.videos[i].vod_url_en) + '" ' +
                    'class="videoThumbnail liveVideo" id="video_' + objJSON.videos[i].id + '" title="' + unescape(objJSON.videos[i].title) +
                    '"><div class="thumbMask"></div><img src="' + unescape(objJSON.videos[i].thumbnail_url) + '" border="0" /></a>';
            }
        }
        // build the info about the video
        var moreMessage = ( objJSON.videos.length == 1 ) ? 'Current Live' : 'More Live';
        shtml = '<h1 id="currentVODTitle">' + VIDEOS.CurrentLiveInfo.title + '</h1>' +
            '<p class="currentVODDescriptionEN">' + VIDEOS.CurrentLiveInfo.description_en + '<br /></p>' +
            '<div id="moreLiveWrap"><h2>' + moreMessage + '</h2>' + shtml + '</div>';
        /*
         * UPDATE the kontent
         */
        $('div#videoInformation div#videoCPL').empty().html( shtml );
        ACTIONS.VIDEO.AttachThumbnailHandlers();
        $('#videoCPL').supersleight();
        //}
    }, 'json' ); // ABSOFRIGGINLUTELY NEED the content return type!!
    
};





/*
 * VOD VOD VOD
 * triggers when you click the link with the ID
 * of "videoCPLShowVOD" - lists VOD videos only
 * *** takes 1 arg, the offset variable ***
 */
ACTIONS.VIDEO.ShowVOD = function() {
    var offsetVOD = '';
    if ( arguments.length > 0 ) {
        offsetVOD = arguments[0];
        SETTINGS.Visuals.VODCurrentOffset = offsetVOD;
    }
    // hide the chat window, if it's open
    ACTIONS.CHAT.Hide();
    $('div#videoInformation div#videoCPL').empty().html(
        '<img src="' + SETTINGS.Visuals.LoadingIconURL + '" border="0" />'
    );
    $.get( baseURL + 'import/videos_live.import.php', {format:'vod', limit:SETTINGS.Policies.VideoCPL.MaximumThumbnailsAtOnce, offset:offsetVOD}, function(objJSON) {
        var shtml = '';
        if ( objJSON.videos.length >= 1 ) {
            for ( var i = 0; i < objJSON.videos.length; i++ ) {
                // if this item in the loop is the CURRENT vid, refunk it's info pls thx
                if ( objJSON.videos[i].id == VIDEOS.CurrentVODID ) { VIDEOS.CurrentVODInfo = objJSON.videos[i]; }
                shtml += "\n" + '<a href="' + unescape(objJSON.videos[i].vod_url_en) + '" ' +
                    'class="videoThumbnail" id="video_' + objJSON.videos[i].id + '" title="' + unescape(objJSON.videos[i].title) +
                    '"><div class="thumbMask"></div><img src="' + unescape(objJSON.videos[i].thumbnail_url) + '" border="0" /></a>';
            }
            /*// debug - pagination!!? ???
            shtml += "\n" + '<a href="#" ' +
                'style="display:block;width:50px;height:10px;margin-top:40px;float:left;text-align:right;" id="VODPaginationNext" title="Show more videos">More &rarr;</a>';*/
        }
        // build the info about the video
        // if we still dont have a current vid by now, set it to the first one
        if ( VIDEOS.CurrentVODID <= -1 ) {
            VIDEOS.CurrentVODID = 0;
            VIDEOS.CurrentVODInfo = objJSON.videos[0];
        }
        // spank the spanish url
        var spanishUrlGivingMeTrouble = VIDEOS.CurrentVODInfo.vod_url_sp.trim();
        if ( spanishUrlGivingMeTrouble.length <= 0) {
            spanishUrlGivingMeTrouble = '';
        }
        else {
            //spanishUrlGivingMeTrouble = '<li><a class="switchVid" href="' + spanishUrlGivingMeTrouble + '">&rarr; Escuchar en Espa&#241;ol</a></li>';
            spanishUrlGivingMeTrouble = '<li><a title="video_' + VIDEOS.CurrentVODInfo.id + '" class="switchVid" href="' + spanishUrlGivingMeTrouble + '">&rarr; Escuchar en Espa&#241;ol</a></li>';
        }
        shtml = '<h1 id="currentVODTitle">' + ((VIDEOS.CurrentVODInfo.title === '') ? 'Videos OnDemand' : VIDEOS.CurrentVODInfo.title) + '</h1>' +
                spanishUrlGivingMeTrouble +
                '<p class="currentVODDescriptionEN">' + ((VIDEOS.CurrentVODInfo.description_en === undefined) ? '' : VIDEOS.CurrentVODInfo.description_en) + '</p>' +
                '<p class="currentVODDescriptionSP">' + ((VIDEOS.CurrentVODInfo.description_sp === undefined) ? '' : VIDEOS.CurrentVODInfo.description_sp) + '<br /></p>' +
            '<div id="vodWrap"><h2>More on demand</h2><div id="VODThumbnails">' + shtml + '</div></div>';
        // update the content
        $('div#videoInformation div#videoCPL').empty().html( shtml );
        // reenable clicking
        ACTIONS.VIDEO.AttachThumbnailHandlers();
        $('#videoCPL').supersleight();
        $('div#present div#videoInformation div#videoCPL div#VODThumbnails').jScrollPane({reinitialiseOnImageLoad: true});
    }, 'json' ); // ABSOFRIGGINLUTELY NEED the content return type!!
};


UPDATE.TwitterOfficialLoad = function() {
    /*
    Twitter Official can update whenever it wants
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    */
    var firstLoad = false;
    if ( arguments.length >= 1 ) {
        if ( arguments[0] === true ) {
            firstLoad = true;
            UPDATE.InProgress.TwitterOfficial = false;
        }
    }
    if ( UPDATE.InProgress.TwitterOfficial ) {
        return false;
    }
    else {
        UPDATE.InProgress.TwitterOfficial = true;
    }
    $.get( 'import/twitter_official.import.php', {format: 'html'}, function(objJSON) {
        FEEDS.TwitterOfficial = objJSON;
        if ( firstLoad ) { UPDATE.TwitterOfficialDisplay(); }
        UPDATE.InProgress.TwitterOfficial = false;
    }, 'json');
};


UPDATE.TwitterOfficialDisplay = function() {
    //if ( SETTINGS.PauseLiveUpdates ) { return; }
    var randomIndex = Math.floor( Math.random() * FEEDS.TwitterOfficial.length );
    // prevent infinite loop please
    if ( (FEEDS.TwitterOfficial.length >= 1) && (randomIndex >= 0) ) {
        // don't show the same item twice in a row
        var _prevent_freeze = 0;
        while ( (_prevent_freeze <= 100) && (randomIndex == SETTINGS.Visuals.TwitterOfficialLastIndex) ) {
            randomIndex = Math.floor( Math.random() * FEEDS.TwitterOfficial.length );
            _prevent_freeze++;
        }
        if ( _prevent_freeze >= 99 ) {
            randomIndex = 0;
        }
        SETTINGS.Visuals.TwitterOfficialLastIndex = randomIndex;
        $('div#notify p').ready( function() {
            $('div#notify p').animate({ opacity: '0' }, 200, 'easeOutCirc', function() {
                $('div#notify p').html(
                    /* repetition not intentional but jquery was getting hung up =/ */
                    unescape(FEEDS.TwitterOfficial[randomIndex].message).replace('q=#', 'q=%23')
                );
            }).animate({ opacity: '1' }, 200, 'easeInCirc');
        });
    }
};


UPDATE.ELifeLoad = function() {
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    $.get( 'import/elife.import.php', {format: 'html'}, function(objJSON) {
        FEEDS.ELife = eval( objJSON );
        SETTINGS.SingleServingMode = false;
        ACTIONS.FEEDS.ActivityStreamReload();
    });
};


ACTIONS.CHAT.Show = function() {
    // show the chat
    $('div#tecChatLog').animate({
        height: '234px',
        opacity: '1.0'
    }, 800, 'easeOutCirc' );
    $('div#tecChat').animate({
        height: '286px',
        queue: false
    }, 1000, 'easeOutCirc', function() {
        $('input#tecChatMessage').animate({
            width: '239px',
            queue: true
        }, 800, 'easeOutCirc' );
    });
    SETTINGS.Visuals.ChatVisible = true;
};

ACTIONS.CHAT.Hide = function() {
    // hide the chat
    $('div#tecChatLog').animate({
        height: '1px',
        opacity: '0'
    }, 800, 'easeOutCirc' );
    $('div#tecChat').animate({
        height: '29px',
        queue: false
    }, 1000, 'easeOutCirc', function() {
        $('input#tecChatMessage').animate({
            width: '179px',
            queue: true
        }, 800, 'easeOutCirc' );
    });
    SETTINGS.Visuals.ChatVisible = false;
};

ACTIONS.CHAT.ToggleVisibility = function() {
    if ( $('div#tecChat').height() < 254 ) {
        ACTIONS.CHAT.Show();
        $('span#tecChatToggle').css(
            'backgroundPosition', '0 -9px'
        );
        $('#sb_msg').show();
    }
    else {
        ACTIONS.CHAT.Hide();
        $('span#tecChatToggle').css(
            'backgroundPosition', '0 0'
        );
        $('#sb_msg').hide();
    }
};



UPDATE.TwitterUnofficialLoad = function() {
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    $.get( 'import/twitter_unofficial_scrape.import.php', {format:'html'}, function(data) {
        FEEDS.TwitterUnofficial = eval( data );
        ACTIONS.FEEDS.ActivityStreamReload();
        SETTINGS.SingleServingMode = false;
    }, 'json' );
};


UPDATE.OfficialBlogsLoad = function() {
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    $.get( 'import/official_blogs.import.php', {format: 'html'}, function(data) {
        FEEDS.OfficialBlogs = eval( data );
        var ob = '';
        for ( var i = 0; i < FEEDS.OfficialBlogs.length; i++ ) {
            ob += "\n" + '<li class="' + FEEDS.OfficialBlogs[i].type + '"><a href="' + unescape(FEEDS.OfficialBlogs[i].url) +
                '" target="_blank">' + FEEDS.OfficialBlogs[i].message + '</a></li>';
        }
        var currentContent = $('div#officialBlogs.module ul.moduleContent').html();
        currentContent = currentContent.toString();
        if ( currentContent != ob ) {
            $('div#officialBlogs.module ul.moduleContent').empty().html( ob );
        }
        SETTINGS.SingleServingMode = false;
    });
};


UPDATE.NewsCoverageLoad = function() {
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    $.get( 'import/news_coverage.import.php', {format: 'html'}, function(data) {
        FEEDS.NewsCoverage = eval( data );
        var ob = '';
        for ( var i = 0; i < FEEDS.NewsCoverage.length; i++ ) {
            ob += "\n" + '<li class="typeTEC"><a href="' + unescape(FEEDS.NewsCoverage[i].url) +
                '" target="_blank">' + FEEDS.NewsCoverage[i].title + '</a></li>';
        }
        var currentContent = $('div#newsCoverage.module ul.moduleContent').html();
        currentContent = currentContent.toString();
        if ( currentContent != ob ) {
            $('div#newsCoverage.module ul.moduleContent').empty().html( ob );
        }
        SETTINGS.SingleServingMode = false;
    });
};


UPDATE.FunFactsFAQLoad = function() {
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    $.get( 'import/fun_facts_faq.import.php', {format: 'html'}, function(data) {
        FEEDS.FunFactsFAQ = eval( data );
        var ob = '';
        for ( var i = 0; i < FEEDS.FunFactsFAQ.length; i++ ) {
            ob += "\n" + '<li class="typeTEC">' +
                ((FEEDS.FunFactsFAQ[i].url !== '') ? '<a href="' + unescape(FEEDS.FunFactsFAQ[i].url) + '" target="_blank">' : '') +
                FEEDS.FunFactsFAQ[i].title + ((FEEDS.FunFactsFAQ[i].url !== '') ? '</a>' : '') + '</li>';
        }
        var currentContent = $('div#FunFactsFAQ.module ul.moduleContent').html();
        currentContent = currentContent.toString();
        if ( currentContent != ob ) {
            $('div#FunFactsFAQ.module ul.moduleContent').empty().html( ob );
        }
        SETTINGS.SingleServingMode = false;
    });
};



/*
 * UPDATES the activity stream whoa!
 * by combining all the aggregated streams into one, then updating the div
 *
 */
ACTIONS.FEEDS.ActivityStreamReload = function() {
    
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    var agro = [];
    
    var includeFeeds = [
        FEEDS.TwitterUnofficial
    ];
    
    for ( var o in includeFeeds ) {
        if ( includeFeeds[o].length >= 1 ) {
            for ( var i = 0; i < includeFeeds[o].length; i++ ) {
                try {
                    agro.push( includeFeeds[o][i] );
                }
                catch (e) {
                    //debug('** ActivityStream : Feed "' + includeFeeds[o] + '" has no property');
                }
            }
        }
        /*else {
            debug('error: includefeeds is empty');
        }*/
    }
    
    
    // not doing a while-loop here adds some latency to the updates,
    // since otherwise they change somewhat maniacly
    if ( SETTINGS.Policies.ActivityStream.RandomizeFeeds ) {
        agro.sort( function() {
            /* randomize array */
            return ( Math.round(Math.random()) - 0.5 );
        });
    }
    
    // build the html
    if ( agro.length >= 1 ) {
        
        var h = '';
        var limit = 2;
        //limit = ( agro.length >= limit ) ? limit : agro.length;
        for ( i = 0; i < agro.length; i++ ) {
            if ( (agro[i].message !== undefined) && (agro[i].message !== '') ) {
                /*var existing = [];
                $('div#activityStream.module ul.moduleContent li').each( function() {
                    existing.push( $(this).text() );
                    //debug( $(this).text() );
                });*/
                // pre-emptively kill dupes
                //if ( !in_array(agro[i].message, existing) ) {
                    h += "\n" + '<li class="' + agro[i].type + '">';
                    h += "\n\t" + agro[i].message + "...\n\t<span class=\"moduleReadMore\"><a target=\"_blank\" href=\"" + agro[i].url + "\">more</a></span>\n";
                    h += "</li>";
                /*}
                else {
                    debug('ALREADY IN NEWS FEED: ' + agro[i].message);
                }*/
            }
        }
        
        // add the new 2 to the top
        $('div#activityStream.module ul.moduleContent').prepend( h );
        //$(h).hide().prependTo('div#activityStream.module ul.moduleContent').fadeIn(slow);
        
        // remove the last 2
        var items = $('div#activityStream.module ul.moduleContent li');
        while ( (items.length - 2) > 25 ) {
            $(items[items.length - 1]).hide(50).remove();
            items = $('div#activityStream.module ul.moduleContent li');
        }
        
    }
    
    $('ul.moduleContent').jScrollPane({
        reinitialiseOnImageLoad: true
    });
    
};

/*
 * hey, play a video! yay
 *
 */
ACTIONS.VIDEO.PlayVideo = function( videoURL, boolLive ) {
    SETTINGS.Autoplay.VideoPlayerFirstLoad = true;
    SETTINGS.PauseLiveUpdates = true;
    /*debug*///$('#v2').empty().html('Live Updates are PAUSED');
    flowplayer( 'flowplayer', {src: 'js/flowplayer-3.1.1.swf', wmode: 'opaque'}, {
        clip: {
            url: videoURL,
            autoPlay: true,
            autoBuffering: true,
            bufferLength: 8, /* seconds */
            live: boolLive,
            
            /* try to pause live-updating the feeds when playing video */
            /*onStart: function(){SETTINGS.PauseLiveUpdates = true;},
            onBegin: function(){SETTINGS.PauseLiveUpdates = true;},
            onResume: function(){SETTINGS.PauseLiveUpdates = true;},
            
            onPause: function(){SETTINGS.PauseLiveUpdates = false;},
            onFinish: function(){SETTINGS.PauseLiveUpdates = false;},
            onStop: function(){SETTINGS.PauseLiveUpdates = false;}*/
            onStart: pause,
            onBegin: pause,
            onResume: pause,
            
            onPause: unpause,
            onFinish: unpause,
            onStop: unpause
        },
        plugins: {
            controls: {
                bottom: 0,
                opacity: 0.85,
                fullscreen: false,
                autoHide: 'always',
                hideDelay: 1000
            }
        },
        onLoad: function() {
            this.setVolume( 90 );
        }
    });
};

var pause = function(){
    SETTINGS.PauseLiveUpdates = true
    /*debug*///$('#v2').empty().html('Live Updates are PAUSED');
};
var unpause = function(){
    SETTINGS.PauseLiveUpdates = false
    /*debug*///$('#v2').empty().html('Live Updates are LIVE');
};

/*
 * do the special magic with the videos
 * both LIVE and ONDEMAND
 *
 */
ACTIONS.VIDEO.AttachThumbnailHandlers = function() {
    $('div#videoCPL a.videoThumbnail, div#videoCPL a.switchVid').click( function(e) {
        e.preventDefault();
        e.stopPropagation();
        $('div#videoPlayer a#flowplayer').attr( 'href', $(this).attr('href') );
        $('#flowplayer').empty();
        var isLive = $(this).hasClass('liveVideo');
        ACTIONS.VIDEO.PlayVideo( $(this).attr('href'), isLive );
        // ** IMPORTANT ** set this video as the current vid
        var videoID = $(this).attr('id');
        videoID = videoID.replace('video_', '');
        // update our global with the video info
        ACTIONS.VIDEO.GetVideoInfo( videoID );
        // make sure we dont reprocess the initial click to play function of the player
        SETTINGS.Autoplay.VideoPlayerFirstLoad = true;
    });
};


/*
 * gets video info from db
 * 
 * needs: video ID
 * returns: JSON object
 *
 */
ACTIONS.VIDEO.GetVideoInfo = function( id ) {
    $.get( 'import/video_info.import.php', {videoID:id, format:'html'}, function(objJSON) {
        VIDEOS.CurrentVODID = objJSON.id;
        VIDEOS.CurrentVODInfo = objJSON;
        // change the meta info
        $('div#present div#videoInformation div#videoCPL h1#currentVODTitle').empty().html( VIDEOS.CurrentVODInfo.title );
        $('div#present div#videoInformation div#videoCPL p.currentVODDescriptionEN').empty().html( VIDEOS.CurrentVODInfo.description_en );
        if ( VIDEOS.CurrentVODInfo.description_sp.length >= 1 ) {
            $('div#present div#videoInformation div#videoCPL p.currentVODDescriptionSP').empty().html( VIDEOS.CurrentVODInfo.description_sp );
        }
    }, 'json' );
};




UPDATE.CalendarLoad = function() {
    
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    
    
    // GC2009 Special Functions List.csv
    //date, group name & event, time, comments
    $.get( 'inc/calendar_json.js', {}, function(calendarJSON) {
        
        FEEDS.Calendar = [];
        FEEDS.Calendar = calendarJSON.Events;
        // easist way to get calendar onload for first time
        // otherwise gotta rewrite stuff in php bah x_x
        UPDATE.CalendarDisplay();
        
        SETTINGS.SingleServingMode = false;
    }, 'json' );
    
};


UPDATE.CalendarDisplay = function() {
    
    // JS doesn't like dashed dates, so use fwd slsh ///
    var today = new Date();
    today = today.getFullYear() + '/' + today.getMonth() + '/' + today.getDay();
    //today = Date.parse( today.toString() );
    
    if ( FEEDS.Calendar.length >= SETTINGS.Policies.Calendar.MinimumDisplayItems ) {
        var h = '';
        var limit = 0;
        if ( SETTINGS.Policies.Calendar.EnforceLimit ) {
            limit = SETTINGS.Policies.Calendar.MaximumDisplayItems;
        }
        else {
            limit = FEEDS.Calendar.length;
        }
        for ( var event = 0; event < limit; event++ ) {
            var eventDate = Date.parse( FEEDS.Calendar[event].Date );
            //trace(FEEDS.Calendar[event].Date + "\n" + today.toString());
            if ( (SETTINGS.Policies.Calendar.EnforceTodayOnly && (eventDate == Date.parse(today.toString()))) || !SETTINGS.Policies.Calendar.EnforceTodayOnly ) {
                h += "\n<li class=\"typeCalendar\">";
                h += "\n<span class=\"" + FEEDS.Calendar[event].Icon + '">';
                h += FEEDS.Calendar[event].StartTime + '</span>';
                h += "\n" + FEEDS.Calendar[event].Title + "\n</li>";
            }
        }
        // terrible guess & check error handling
        if ( h.length >= 20 ) {
            $('div#Calendar.module ul.moduleContent').empty().html( h );
        }
    }
    
};



ACTIONS.MODULES.Toggle = function( module ) {
    
    if ( $(module).height() <= '24' ) {
        switch ( $(module).attr('id') ) {
            case 'activityStream':
                $(module).animate({height: SETTINGS.Defaults.ActivityStream.Height});
                break;
            case 'Calendar':
                $(module).animate({height: SETTINGS.Defaults.Calendar.Height});
                break;
            case 'featuredMultimedia':
                $(module).animate({height: SETTINGS.Defaults.FeaturedMultimedia.Height});
                break;
            case 'legislationTracker':
                $(module).animate({height: SETTINGS.Defaults.LegislationTracker.Height});
                break;
            case 'conventionResources':
                $(module).animate({height: SETTINGS.Defaults.ConventionResources.Height});
                break;
        }
    }
    else {
        switch ( $(module).attr('id') ) {
            case 'activityStream':
                $(module).animate({height: '24px'});
                break;
            case 'Calendar':
                $(module).animate({height: '24px'});
                break;
            case 'featuredMultimedia':
                $(module).animate({height: '24px'});
                break;
            case 'legislationTracker':
                $(module).animate({height: '24px'});
                break;
            case 'conventionResources':
                $(module).animate({height: '24px'});
                break;
        }
    }
    
};



UPDATE.ConventionResourcesLoad = function() {
    if ( SETTINGS.PauseLiveUpdates ) { return; }
    
    $.get( 'import/convention_resources.import.php', {format: 'html'}, function(objJSON) {
        var res = '';
        //debug('total of ' + objJSON.length + ' convention resources loaded');
        for ( var i = 0; i < objJSON.length; i++ ) {
            // dunno how else to deal with this right now, so set all resources to links
            res += "\n" + '<li class="typeLink"><a href="' + ((objJSON[i].shadowbox === true) ? 'javascript:void(0);' : objJSON[i].url) + '"' +
                ( (objJSON[i].newwindow === true) ? ' target="_blank"' : '') +
                ( (objJSON[i].shadowbox === true) ? ' onclick="sbIframeFromURL(\'' + objJSON[i].url + '\')"' : '') +
                '>' + objJSON[i].title + '</a></li>';
        }
        $('div#conventionResources.module ul.moduleContent').empty().html( res );
        SETTINGS.SingleServingMode = false;
    }, 'json' );
};




/* legislation tracker intelligent inline search w00t */
ACTIONS.SEARCH.Legislation = function() {
    // TODO: this should be replaced with a RegEx, case-insensitive query... 
    var query = $('div#legislationTracker.module div.moduleLegend input#legislationSearch').val();
    query = query.toString().toLowerCase();
    if ( query == SETTINGS.Defaults.LegislationTracker.SearchText.toLowerCase() ) { return; }
    $('div#legislationTracker.module ul.moduleContent li').each( function() {
        var current = $(this).html();
        current = current.toString().toLowerCase();
        if ( current.indexOf(query) >= 0 ) {
            $(this).css({
                display: 'block',
                visibility: 'visible'
            });
        }
        else {
            $(this).css({
                display: 'none',
                visibility: 'hidden'
            });
        }
    });
};



/* some helper functions - these may need to be moved ;p - GM */
var setCookie = function(name, value, expireDate) {
    document.cookie = name + '=' + escape(value) + '; path=/' + 
        ( (expireDate === null) ? '' : '; expires='+expireDate.toGMTString() );
};

serializeWidgets = function() {
    $('.module').each(function(){
        trace($(this).attr('id') + ' / ' +
            $(this).parent().attr('id')
        );
    });
};