
function FoxAjaxContent()
{
};


// "Static" Variables
//////////////////////////////////////////////////////////////////////////////////////////////////
//   Variables defined here are used by all fox ajax content instances on the page.

// class of the div wrapper
FoxAjaxContent.loading_class = "fb_ajax_loading";
FoxAjaxContent.content_class = "fb_ajax_content";

FoxAjaxContent.support_animate = true;

//////////////////////////////////////////////////////////////////////////////////////////////////


// "Static" Methods
//////////////////////////////////////////////////////////////////////////////////////////////////
//   Functions defined here are used by all fox ajax content instances on the page.

FoxAjaxContent.createFoxAjaxContent = function(content_id, section, url)
{
    if (typeof(content_id) == "undefined")
    {
        return null;
    }
    if (typeof(section) == "undefined")
    {
        return null;
    }
    if (typeof(url) == "undefined")
    {
        return null;
    }

    if (jQuery.browser.msie)
    {
        FoxAjaxContent.support_animate = false;
    }

    var my_content = new FoxAjaxContent();
    my_content['content_id'] = content_id;
    my_content['section'] = section;
    my_content['url'] = url;
    return my_content;
}


// "Object" Variables
//////////////////////////////////////////////////////////////////////////////////////////////////
//    Variables defined here are used as unique copies in each instance of fox ajax content.
//    they are defined with these defaults, and may be modified after being instanciated
//    without effecting others.


// id of the div where content is to be placed.
FoxAjaxContent.prototype.content_id = null;
// name of the section which the contains the content.
FoxAjaxContent.prototype.section = null;
// url where the section is found (usually the current url)
FoxAjaxContent.prototype.url = null;


// "Object" Methods
//////////////////////////////////////////////////////////////////////////////////////////////////

// Loads the requested content into the area, sending along requested parameters, if any.
FoxAjaxContent.prototype.loadRequestedContent = function(params)
{
    var content_selector = '#' + this.content_id + ' .' + FoxAjaxContent.content_class;
    var loading_selector = '#' + this.content_id + ' .' + FoxAjaxContent.loading_class;

    // animate fade out.
    if ( FoxAjaxContent.support_animate )
    {
        jQuery(content_selector).animate(
                { opacity : 0.4 },
                { duration : 250 });
    }
    jQuery(loading_selector).show(250);

    var url = this.url;
    var data =
        {
            fco : '1',
            sec : this.section
        };

    if (typeof(params) != "undefined")
    {
        if (typeof(params) == "object" && typeof(params) != null)
        {
            for(prop in params)
            {
                data[prop] = params[prop];
            }//endfor
        }
        else if (typeof(params) == "function")
        {
            // function
        }
        else
        {
            // number, string, or boolean
        }
    }

    jQuery(content_selector).load(url, data, function()
    {
        // animate fade back
        if ( FoxAjaxContent.support_animate )
        {
            jQuery(content_selector).animate(
                    { opacity : 1.0 },
                    { duration : 250 } );
        }
        jQuery(loading_selector).hide(250);
    });
}//end loadRequestedContent
