$(document).ready(function (){

    /**
     * Partners block events
	 */
    var partnersBlock = {
        //-- Original HTML code, set by init
        orgHtml: false,

        //-- If set to true, it will try to get content from ajax
        //-- You're list item should have a unique id number
        useAjax: true,

        //-- The url to use for the ajax request
        ajaxUrl: 'partners/description/',

        //-- The post variable to use to pass the unique id
        ajaxProp: 'id',

        //-- Image for the loader when ajax is used
        ajaxLoader: 'images/loader.gif',

        init: function (){
            partnersBlock.orgHtml = $("#textblock").html();

            //-- Bind events to all list items
            $("#partners > ul > li").each(function() {

                //-- Hover method
                $(this).bind('mouseenter', function(){
                    if(!partnersBlock.useAjax)
                    {
                        //-- Find span object
                        var container = $(this).find('span');
                        //-- Change html to span html
                        if (container.html() != null) $('#textblock').html(container.html());
                    } else {
                        var myId = $(this).attr('id');

                        //-- Do nothing when no id is provided
                        if (!myId) return false;

                        //-- Use ajax request
                        $.ajax({
                            type: 'POST',
                            url: partnersBlock.ajaxUrl,
                            dataType: 'html',
                            data: "" + partnersBlock.ajaxProp + "=" + myId,
                            beforeSend: function (){
                                //-- Ajax loader implementation
                                $('#textblock').html('<img src="'+ partnersBlock.ajaxLoader +'">');
                            },

                            success: function (returnHtml) {
                                $('#textblock').html(returnHtml);
                            }
                        });
                    }

                });

                //-- Change html back to original
                $(this).bind('mouseleave', function(){
                    $('#textblock').html(partnersBlock.orgHtml);
                });
            });
        }
    };

    //-- Init partnersblock
    partnersBlock.init();
});
