
    jQuery(document).ready(function () {
            FBCMS_CreateScroller('fb_events_scrollingContent');
        });


    function setTabs(tabObj){

        if(tabObj.className == 'active'){
            return;
            stop;
        }

        var tabs = document.getElementById('tabs').getElementsByTagName('a');

        for(i=0;i<tabs.length;i++){
            document.getElementById('tab_'+i).className = 'inactive';
            document.getElementById('tabContent_'+i).style.display = 'none';
        }
        tabObj.className = 'active';
        document.getElementById('tabContent_'+tabObj.id.split('_')[1]).style.display = 'block';

    }

///////////////////////////////////////////////////////////////////////////////

    function MM_findObj(n, d) { //v4.01
        var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
            d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
        if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

///////////////////////////////////////////////////////////////////////////////

    function MM_preloadImages() { //v3.0
        var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

///////////////////////////////////////////////////////////////////////////////

    function showDate(yearOnly){
        var mydate=new Date();
        var year=mydate.getYear();
        if (year < 1000){year+=1900};
        var day=mydate.getDay();
        var month=mydate.getMonth();
        var daym=mydate.getDate();
        var dayEnd = "th";
        if (daym == 1 || daym == 21 || daym == 31){dayEnd = "st";}
        if (daym == 2 || daym == 22){dayEnd = "nd";}
        if (daym == 3 || daym == 23){dayEnd = "rd";}
        var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
        var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
        if(yearOnly){
            document.write(year);
        }
        else{
        document.write(dayarray[day]+", "+montharray[month]+" "+daym+dayEnd+", "+year);
        }
    }

///////////////////////////////////////////////////////////////////////////////

    function fixFlashInIE(){
        objects = document.getElementsByTagName("object");
        for (var i = 0; i < objects.length; i++){
            objects[i].outerHTML = objects[i].outerHTML;
        }
    }

///////////////////////////////////////////////////////////////////////////////

    function interactWithSearchField(fieldId,binSwitch,defaultText){
        var searchField = document.getElementById(fieldId);
        var fieldContents = searchField.value;
        if(binSwitch == 1 && fieldContents == defaultText){
            searchField.value = '';
            searchField.className = '';
        }
        if(binSwitch == 0 && fieldContents == ''){
            searchField.value = defaultText;
            searchField.className = 'empty';
        }
    }

///////////////////////////////////////////////////////////////////////////////

function showPopulatedClass(parentId,childElType,childClass){
    var checkArray = getElementsByClassName(document.getElementById(parentId),childElType,childClass);
    if(checkArray.length > 0){
        for(i=0;i<checkArray.length;i++){
            elementContents = checkArray[i].innerHTML;
            if(stripChars(elementContents,' ') != ''){
                checkArray[i].style.display = "block";
            }
        }
    }
}

///////////////////////////////////////////////////////////////////////////////

function hideEmptyClass(parentId,childElType,childClass){
    var checkArray = getElementsByClassName(document.getElementById(parentId),childElType,childClass);
    if(checkArray.length > 0){
        for(i=0;i<checkArray.length;i++){
            elementContents = checkArray[i].innerHTML;
            if(stripChars(elementContents,' ') == ''){
                checkArray[i].style.display = "none";
            }
        }
    }
}

///////////////////////////////////////////////////////////////////////////////


function stripChars(words,character){
//documentation for this script at http://www.shawnolson.net/a/499/
    var chars = words.length;
    for(var x = 0; x<chars; x++){
     words = words.replace(character, "");
 }
 return words;
    }

///////////////////////////////////////////////////////////////////////////////

function getElementsByClassName(oElm, strTagName, oClassNames){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    var arrRegExpClassNames = new Array();
    if(typeof oClassNames == "object"){
        for(var i=0; i<oClassNames.length; i++){
            arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
        }
    }
    else{
        arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
    }
    var oElement;
    var bMatchesAll;
    for(var j=0; j<arrElements.length; j++){
        oElement = arrElements[j];
        bMatchesAll = true;
        for(var k=0; k<arrRegExpClassNames.length; k++){
            if(!arrRegExpClassNames[k].test(oElement.className)){
                bMatchesAll = false;
                break;
            }

        }
        if(bMatchesAll){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}


///////////////////////////////////////////////////////////////////////////////



/* ---------------------------------------------- */
//
// Create a scroller for the content in the
// container with the id given.
//
// STYLING NOTES:
// The parent of the container must have its
// height set in css.
//
// PARAMETERS
//  container_id - id of the object that contains
//    the content to scroll.  If not set, the
//    function does nothing.
//
// OPTIONAL PARAMETERS
//  control_location - location of the controls
//    relative to the content ("left" or "right").
//    [default: "right"]
//  scroll_speed - distance to move the content
//    per interation.
//    [default: 10]
//  scroll_interval - number of milliseconds
//    between scroll interations.
//    [default: 50]
//
/* ---------------------------------------------- */
function FBCMS_CreateScroller(container_id, control_location, scroll_speed, scroll_interval)
{

    jQuery(document).ready(function()
    {

        if (!container_id) { return; }

        if (jQuery('body.home').length == 0)
        {
            return;
        }

        // retrieve the height of the parent container.
        var parent_height = jQuery('#'+container_id).parent().css("height");
        if (parent_height == null || parent_height == '' || parent_height == 'auto')
        {
            return;
        }

        //** CONFIGURATION VALUES. **//

        // position of the scroller controls.
        //var control_location = "right";
        if (!control_location) { control_location = "right"; }

        // distance to move per interation.
        //var scroll_speed = 10;
        if (!scroll_speed) { scroll_speed = 10; }

        // time between interations.
        //var scroll_interval = 50;
        if (!scroll_interval) { scroll_interval = 50; }


        //** WORKING VALUES. **//
        // interval value.
        var int = null;
        // current scroller velocity. (speed & direction)
        var current_scroll_value = null;

        // height of the content.
        var scroller_height = parseInt(parent_height);

        // grab the content and clear it out,
        // this div will become the container for the scroller aparatus.
        var content = jQuery('#'+container_id).html();
        jQuery('#'+container_id).html('');
        jQuery('#'+container_id).addClass('fb_scroller_parent');

        // add the controls.
        jQuery('#'+container_id).append('<div id="'+container_id+'_control" class="fb_scroller_control"></div>');
        jQuery('#'+container_id+'_control').append('<div id="'+container_id+'_top" class="fb_scroller_control_button top"><span>Up</span></div>');
        jQuery('#'+container_id+'_control').append('<div id="'+container_id+'_bottom" class="fb_scroller_control_button bottom"><span>Down</span></div>');

        // load button sizes, or defaults if none are styled.
        var button_height = parseInt(jQuery('.fb_scroller_control_button').css("height"));
        var button_width = parseInt(jQuery('.fb_scroller_control_button').css("width"));
        var button_border_width = parseInt(jQuery('.fb_scroller_control').css("border-width"));
        if (!button_height) { button_height = 10; }
        if (!button_width) { button_width = 10; }
        if (!button_border_width) { button_border_width = 0; }  //BUGBUG always seems to use this value...

        // style the control container.
        jQuery('#'+container_id+'_control').css("float", control_location);
        jQuery('#'+container_id+'_control').css("height", scroller_height+"px");
        jQuery('#'+container_id+'_control').css("width", (button_width + (button_border_width * -2))+"px");

        // style the control buttons.
        jQuery('#'+container_id+'_control .fb_scroller_control_button').css("float", control_location);
        jQuery('#'+container_id+'_control .fb_scroller_control_button').css("height", button_height);
        jQuery('#'+container_id+'_control .fb_scroller_control_button').css("width", button_width+"px");

        var margin_adjust = "margin-right";
        if ( BrowserDetect.browser == 'Explorer' && BrowserDetect.version == 7 )
        {
            margin_adjust = "margin-left";
        }
        jQuery('#'+container_id+'_control .fb_scroller_control_button').css(margin_adjust, (button_border_width * -1)+"px");

        jQuery('#'+container_id+'_top').css("margin-top", (button_border_width * -1)+"px");
        jQuery('#'+container_id+'_bottom').css("margin-top", scroller_height - ((button_border_width * -2) + (button_height*2)) + "px");

        // set the control hover function.
        jQuery('#'+container_id+'_control .fb_scroller_control_button').hover(function() {
                current_scroll_value = (jQuery(this).attr("id") == container_id+"_top") ? scroll_speed : -1*scroll_speed;
                int = setInterval(scrollContent, scroll_interval);
            }, function() {
                clearInterval(int);
        });


        // put the content back in.
        jQuery('#'+container_id).append('<div id="'+container_id+'_fixed" class="fb_scroller_fixed"><div id="'+container_id+'_content" class="fb_scroller_content">'+content+'</div></div>');

        // style the content holder.
        jQuery('#'+container_id+'_fixed').css("height", scroller_height+"px");
        jQuery('#'+container_id+'_fixed').css("overflow", "hidden");


        // the function to be run upon hover over the
        function scrollContent()
        {
            // calculate the new margin.
            var new_margin = parseInt(jQuery("#"+container_id+"_content").css("margin-top"))+current_scroll_value;
            // get the height of the content.
            var content_height = parseInt(jQuery("#"+container_id+"_content").height());

            //alert('new_margin: "' + new_margin + '", scroller_height: "' + scroller_height + '", content_height: "' + content_height + '"');

            // if it's not a valid number, set it to -1;
            if (isNaN(new_margin))
            {
                new_margin = -1;
            }

            if (new_margin > 0)
            {
                // stop scrolling upward if the content is up as far as it can go.
                new_margin = 0;
                // disable the top button.
                jQuery('#'+container_id+'_top').addClass("disabled");
            }
            else if (content_height < scroller_height)
            {
                new_margin = 0;
                // disable the bottom button if the content is shorter than the scroller.
                jQuery('#'+container_id+'_bottom').addClass("disabled");
            }
            else if ((content_height + new_margin) < scroller_height)
            {
                // stop scrolling downward if the content is down as far as it can go.
                new_margin = scroller_height - content_height;
                // disable the bottom button
                jQuery('#'+container_id+'_bottom').addClass("disabled");
            }
            else
            {
                // otherwise, make sure both buttons are enabled.
                jQuery('#'+container_id+'_top').removeClass("disabled");
                jQuery('#'+container_id+'_bottom').removeClass("disabled");
            }
            // write the new margin.
            jQuery("#"+container_id+"_content").css("margin-top", new_margin + "px");
        }//end scrollContent


        var use_compatibility = false;

        var versionNum = parseFloat(BrowserDetect.version);
        if (isNaN(versionNum))
        {
            versionNum = BrowserDetect.version;
        }

        if (BrowserDetect.browser == 'Firefox' && versionNum < 3.5)
        {
            use_compatibility = true;
        }

        if (use_compatibility)
        {
            jQuery('#fb_more_link_vis .fb_more_link').addClass('fb_more_link_compatibility');
        }
    });

}//end FBCMS_CreateScroller

