(function($, window, document, undefined)
{
    /**
     * BigMan3D object.
     */
    var BigMan3D = {

        thumbnailCrossHatchAnimationSpeed : 400,
        postShowHideSpeed: "fast",

        largeImageOverlaySpeed: "fast",

        thumbnailRotateSpeed : 500,
        thumbnailRotateDuration : 1000,
        thumbnailRotateCallback: null,

        logoCount: 0,

        /**
         * Document ready function.
         */
        ready:
            function()
            {
                Loader.init();
                if (showreel == 1){
                    $('.menu li').each(function(){
                        var current = $(this);
                        var id = current.find('a').attr('lang');
                        if (id == 77){
                            current.find('a').addClass("active");
                        }
                    });
                }

                /**
                 *  Properties.
                 */
                BigMan3D.body           = $("body");
                BigMan3D.thumbnailList  = $("ul#jqThumbnailList");
                BigMan3D.thumbnailListOffset  = BigMan3D.thumbnailList.position();
                BigMan3D.thumbnailLI    = BigMan3D.thumbnailList.find("li");
                BigMan3D.thumbnails     = BigMan3D.thumbnailList.find("div.jqThumbnailContainer");
                BigMan3D.logos          = $("div.jqLogo");
                BigMan3D.logoCount      = BigMan3D.logos.length;
                BigMan3D.logos.not(":first").hide();

                BigMan3D.fixPostHeight();

                $("li#jqWeAreBigMan").data("Page", true);

                BigMan3D.thumbnailLI.find("div.jqPostContent").find('img').attr({'title': 'Click to view larger image'});

                /**
                 * Thumbnail mouse hover.
                 */
                BigMan3D.thumbnails.mouseenter(BigMan3D.thumbnailMouseEnter)
                                   .mouseleave(BigMan3D.thumbnailMouseLeave);

                $(document).click(BigMan3D.rotateLogo);

                $("a.jqGlossaryTermLink").live("click", BigMan3D.showGlossaryPopup);
                $("a.jqGlossaryPopupClose").live("click", BigMan3D.hideGlossaryPopup);

               

                /**
                 * Page/Thumbnail link click.
                 */
                $("a.jqLinkShowPost").mousedown(BigMan3D.postContent);

                $("a.jqLinkShowPage").click(BigMan3D.showPage);
                
                /**
                 * Close post/page
                 */
                BigMan3D.thumbnailList.delegate("a.jqClosePost", "click", BigMan3D.hidePost)
                                      .delegate("div.jqPostContent a:has(img)", "click", BigMan3D.showLargeImage);

                BigMan3D.body.delegate("a.jqCloseLargeImageOverlay", "click", BigMan3D.closeLargeImage);

                $(window).resize(BigMan3D.windowResize);
            },

        /**
         * Thumbnail mouse enter.
         */
        thumbnailMouseEnter:
            function()
            {
                var current             = $(this);
                var thumbnailContainer  = current.closest("div.jqThumbnailContainer"); 
                thumbnailContainer.find("div.jqThumbnail:eq(1)").hide().end().find("div.jqThumbnail:eq(0)").show(); 
            },

        /**
         * Thumbnail mouse leave.
         */
        thumbnailMouseLeave:
            function()
            {
                var current     = $(this);
                var thumbnailContainer  = current.closest("div.jqThumbnailContainer");
               
                thumbnailContainer.find("div.jqThumbnail:eq(0)").hide().end().find("div.jqThumbnail:eq(1)").show();

            },

        /**
         * Category wise post thumbnails.
         */
        categoryPosts:
            function()
            {
                BigMan3D.rotateLogo();
                
                var current     = $(this);
                var currentId   = current.attr("id");
                $("a.jqPostCategoryLink.active").removeClass("active");
                current.addClass("active");

                /*Renji*/

                if ($(".jqLargeImageOverlay").is(":visible")){
                    $(".jqLargeImageOverlay").hide();
                    BigMan3D.thumbnailList.fadeIn(BigMan3D.largeImageOverlaySpeed);
                }

                BigMan3D.thumbnailLI.filter("li.jqRelocated").removeClass("jqRelocated").removeAttr("style");
                /*Renji*/

                
                $("#jqThumbnailList").find('li.container').remove();
                BigMan3D.thumbnailLI.show().not("." + currentId).hide();

                return false;
            },
        postContent:
            function()
            {
                var current             = $(this);
                var thumbnailContainer  = current.closest("div.jqThumbnailContainer");
                var thumbnailLI         = thumbnailContainer.closest("li.jqPostThumbnailLI");
                var id                  = current.attr("tabindex");
                var postContent         = thumbnailLI.find("div.jqPostContent");

                if(postContent.length > 0)
                {
                    BigMan3D.showPost(thumbnailLI, thumbnailContainer, postContent);
                    return false;
                }
                else
                {
                    $.ajax({
                            type:       'post',
                            dataType:   'json',
                            url:        destinationUrl,
                            data:       {id : id},
                            beforeSend: function()
                                        {
                                            Loader.show(thumbnailContainer);
                                        },
                            complete:   Loader.hide,
                            success:    function(reply)
                                        {
                                            if(reply)
                                            {
                                                var postContent = $(unescape(reply.success)).hide();
                                                postContent.find('img').attr({'title': 'Click to view larger image'});
                                                thumbnailLI.append(postContent);
                                                BigMan3D.showPost(thumbnailLI, thumbnailContainer, postContent);
                                            }
                                        }
                    });
                }
                
                return false;
            },
        showPost:
            function(thumbnailLI, thumbnailContainer, postContent)
            {   
                BigMan3D.hidePost();

                if ($(".jqGlossaryPopupContainer").is(":visible")){
                    $(".jqGlossaryPopupContainer").hide();
                }
                /*16-mar-2011*/
                BigMan3D.hidePost();
                BigMan3D.relocateThumbnails(thumbnailLI);
                /*16-mar-2011*/

                thumbnailContainer.fadeOut(BigMan3D.postShowHideSpeed,
                    function()
                    {
                        /*16-mar-2011*/
                        BigMan3D.hidePost();
                        BigMan3D.relocateThumbnails(thumbnailLI);
                        /*16-mar-2011*/

                        var postContentHeight = postContent.outerHeight();
                        var additionalHeight    = (postContentHeight % 200) > 0 ? 200 - (postContentHeight % 200) : 0;
                        var liHeight = postContentHeight + additionalHeight;
                        
                        postContent.height(postContent.height() + additionalHeight);
                        postContent.show();
                        thumbnailLI.removeClass("list")
                                   .addClass("container")
                                   .animate({
                                               width: 600,
                                               height: liHeight
                                            },BigMan3D.postShowHideSpeed,
                                            function()
                                            {
                                                BigMan3D.relocateThumbnails(thumbnailLI);
                                                var postContentPosition = postContent.position();
                                                $(document).scrollTop(postContentPosition.top);
                                            });
                        

                        
                    });

                    return false;
            },

        showPage:
            function()
            {
                var current             = $(this);
                
                var id                  = current.attr("lang");

                /*Renji*/
                if ($(".jqLargeImageOverlay").is(":visible")){
                    $(".jqLargeImageOverlay").hide();
                    BigMan3D.thumbnailList.show();
                }
                if ($(".jqGlossaryPopupContainer").is(":visible")){
                    $(".jqGlossaryPopupContainer").hide();
                }
                /*Renji*/

                var pageLI = $("<li class='list jqPostThumbnailLI' style='width:1px;height:1px;'></li>");

                pageLI.data("Page", true);

                $.ajax({
                            type:       'post',
                            dataType:   'json',
                            url:        destinationUrl,
                            data:       {id : id},
                            beforeSend: function()
                                        {
                                            BigMan3D.hidePost();
                                            BigMan3D.thumbnailList.prepend(pageLI);
                                            pageLI.animate({
                                                width:200,
                                                height:200
                                            },"fast", function(){
                                                Loader.show(pageLI);
                                            });
                                            
                                        },
                            complete:   Loader.hide,
                            success:    function(reply)
                                        {
                                            if(reply)
                                            {
                                                $("a.jqLinkShowPage.active").removeClass("active");
                                                current.addClass('active');
                                                var pageContent = $(unescape(reply.success)).hide();
                                                pageContent.find('img').attr({'title': 'Click to view larger image'});
                                                //pageContent.find('div.feature-box-content p:first').css({'display': 'none'});
                                                pageLI.append(pageContent);
                                                BigMan3D.showPost(pageLI, $("<span></span>"), pageContent);
                                            }
                                        }
                    });

                return false;
            },

        relocateThumbnails:
            function(currentThumb)
            {
                var prevThumb           = currentThumb.prev("li.jqPostThumbnailLI");
                var nextThumb           = currentThumb.next("li.jqPostThumbnailLI");
                var prevThumbCache      = prevThumb;
                var currentThumbCache   = currentThumb;

//                if(prevThumb.length > 0 && nextThumb.length > 0)
//                {
                    while(BigMan3D.relocatePreviousThumbnail(prevThumb, currentThumb, nextThumb))
                    {
                        prevThumb = nextThumb;
                        nextThumb = nextThumb.next("li.jqPostThumbnailLI");
                    }
//                }

                var currentThumbOffset  = currentThumb.position();//currentThumb.offset();
                var currentThumbWidth   = currentThumb.outerWidth();

                var rightSpaceWidth     = (BigMan3D.thumbnailListOffset.left + BigMan3D.thumbnailList.outerWidth()) - (currentThumbOffset.left + currentThumbWidth);
                var rightBoxColumns     = Math.floor(rightSpaceWidth/200);

                var leftSpaceWidth      = currentThumbOffset.left - BigMan3D.thumbnailListOffset.left;
                var leftSpaceHeight     = currentThumbCache.outerHeight() - 200;

                var leftBoxColumns      = Math.floor(leftSpaceWidth / 200);
                var leftBoxRows         = Math.floor(leftSpaceHeight / 200);

                if(leftBoxColumns > 0 && leftBoxRows > 0)
                {
                    var nextTumbOffset  = nextThumb.position();//nextThumb.offset();

                    while(nextThumb.length > 0 && nextTumbOffset.top == currentThumbOffset.top)
                    {
                        nextThumb = nextThumb.next("li.jqPostThumbnailLI");
                        nextTumbOffset  = nextThumb.position();//nextThumb.offset();
                    }

                    var newThumbTop     = currentThumbOffset.top + 200;
                    var newThumbLeft    = BigMan3D.thumbnailListOffset.left;

                    for(var j= leftBoxRows; j >  0; j--)
                    {
                        for(var i = leftBoxColumns; i > 0; i--)
                        {
                            if(nextThumb.length > 0)
                            {
                                nextThumb.css({
                                    position:   "absolute",
                                    left:       newThumbLeft,
                                    top:        newThumbTop
                                }).addClass("jqRelocated");

                                newThumbLeft += 200;
                                nextThumb = nextThumb.next("li.jqPostThumbnailLI");
                            }
                            else
                            {
                                break;
                            }
                        }

                        for(var r = 0; r < rightBoxColumns; r++)
                        {
                            if(nextThumb.length > 0)
                            {
                                nextThumb = nextThumb.next("li.jqPostThumbnailLI");
                            }
                        }

                        newThumbTop += 200;
                        newThumbLeft    = BigMan3D.thumbnailListOffset.left;
                    }

                }

                return false;
            },

        relocatePreviousThumbnail:
            function(prevThumb, currentThumb, nextThumb)
            {
                if(prevThumb.length > 0 && nextThumb.length > 0)
                {
                     var currentThumbOffset  = currentThumb.position();//currentThumb.offset();
                    var currentThumbWidth   = currentThumb.outerWidth();
                    var currentThumbRight   = currentThumbOffset.left + currentThumbWidth;
                    
                    var listContainerWidth = BigMan3D.thumbnailList.outerWidth();

                    if($.browser.msie)
                    {
                        if(($(window).width() - listContainerWidth) > 50)
                        {
                            listContainerWidth = $(window).width() - 50;
                        }
                    }


                    var listContainerRight = BigMan3D.thumbnailListOffset.left + listContainerWidth;

                    var prevThumbOffset = prevThumb.position();//prevThumb.offset();
                    var prevThumbWidth = prevThumb.outerWidth();
                    var prevThumbRight = prevThumbOffset.left + prevThumbWidth;

                    if(prevThumbOffset.top == currentThumbOffset.top)
                    {
                        
                    }
                    else
                    {
                        if((listContainerRight - prevThumbRight) >= 200)
                        {
                            nextThumb.css({
                                        position:   "absolute",
                                        left:       prevThumbRight,
                                        top:        prevThumbOffset.top
                                    }).addClass("jqRelocated");

                            return true;
                        }
                    }
                }

                return false;
            },

        hidePost:
            function()
            {
                BigMan3D.rotateLogo();
                BigMan3D.thumbnailLI.filter("li.jqRelocated").removeClass("jqRelocated").removeAttr("style");
                var current = $(this);
                
                if(arguments.length == 0)
                {
                    current = $("div.jqPostContent:visible a.jqClosePost")
                }
                
                var postContent         = current.closest("div.jqPostContent");
                var thumbnailLI         = postContent.closest("li.jqPostThumbnailLI");
                var thumbnailContainer  = thumbnailLI.find("div.jqThumbnailContainer:first");

                /*10-sept-2010*/
                var isPage = $("#hidPage").val();
                if ($(".jqGlossaryPopupContainer").is(":visible")){
                    $(".jqGlossaryPopupContainer").hide();
                }
                /*10-sept-2010*/

                if(thumbnailLI.data("Page") === true || isPage == 1)
                {
                        thumbnailLI.animate({
                            width: 1,
                            height: 1
                        },BigMan3D.postShowHideSpeed,
                        function()
                        {
                            thumbnailLI.remove();
                        });
                        $("a.jqLinkShowPage.active").removeClass("active");
                }
                else
                {
                    thumbnailLI.animate({
                            width: 200,
                            height: 200
                        },BigMan3D.postShowHideSpeed,
                        function()
                        {
                            thumbnailLI.removeClass("container").addClass("list");
                            /*postContent.hide();*/
                            postContent.remove();
                            thumbnailContainer.fadeIn(BigMan3D.postShowHideSpeed);
                        });
                }
                    
                return false;
            },
        closeLargeImage:
            function()
            {
                BigMan3D.rotateLogo();
                
                $(this).closest("div.jqLargeImageOverlay").fadeOut(BigMan3D.largeImageOverlaySpeed,     function(){$(this).remove();});

                
                BigMan3D.thumbnailList.fadeIn(BigMan3D.largeImageOverlaySpeed,
                    function()
                    {
                        BigMan3D.relocatePostDetail();
                        
                    });


                return false;
            },
        showLargeImage:
            function()
            {
                BigMan3D.rotateLogo();

                var current = $(this);
                var currentUrl = current.attr("href");

                if(currentUrl != "#" && currentUrl != "")
                {
                    $.ajax({
                        url: current.attr("href"),
                        dataType: "html",
                        beforeSend: function()
                                    {
                                        Loader.show(current.find("img"), false);
                                    },
                        complete:   Loader.hide,
                        success: function(data)
                        {
                            var imageOverlay = $(data);
                            if(imageOverlay.is("div.jqLargeImageOverlay"))
                            {
                                BigMan3D.thumbnailList.hide();
                                
                                imageOverlay.hide();

                                BigMan3D.body.find("div.jqLargeImageHome").append(imageOverlay);

                                //imageOverlay.fadeIn(400);
                                
                                var largeImage = imageOverlay.children("img:first");

                                largeImage.attr({'title' : ''});
                                
                                var largeImageWidth = parseInt(largeImage.attr("width"));
                                var largeImageHeight = parseInt(largeImage.attr("height"));

                                if(largeImageWidth == 0)
                                {
                                    largeImageWidth = parseInt(largeImage.css("width"));
                                }

                                if(largeImageHeight == 0)
                                {
                                    largeImageHeight = parseInt(largeImage.css("height"));
                                }

                                if(largeImageWidth > 0 && largeImageHeight > 0)
                                {
                                    var allowedWidth    = $(window).width() - 50;
                                    var allowedHeight    = $(window).height() - 110;

                                    var allowedMaxWidth     = Math.max(200, (allowedWidth - (allowedWidth%200)));
                                    var allowedMaxHeight    = allowedHeight;

                                    var resizeRatio         = Math.min(allowedMaxWidth/largeImageWidth, allowedMaxHeight/largeImageHeight);

                                    var newWidth       = Math.min(largeImageWidth, largeImageWidth * resizeRatio);
                                    var newHeight       = Math.min(largeImageHeight, largeImageHeight * resizeRatio);

                                    //largeImage.height(newHeight).width(newWidth);
                                    largeImage.css({
                                        width : newWidth,
                                        height: newHeight
                                    });

                                    largeImage.data("Width", largeImageWidth);
                                    largeImage.data("Height", largeImageHeight);
//                                    imageOverlay.show();
                                }

                                imageOverlay.show();
                                
                            }
                            else
                            {
                                
                            }
                        }
                    });
                }

                return false;
                
            },

        rotateLogo:
            function()
            {
                if(BigMan3D.logos.length > 1)
                {
                    var randomNumber    = Math.floor(Math.random()*(BigMan3D.logoCount - 1));
                    var visibleLogo     = BigMan3D.logos.filter(":visible");
                    var randomLogo      = BigMan3D.logos.filter(":hidden").eq(randomNumber);

//                    if(BigMan3D.logos.index(visibleLogo) != randomNumber)
//                    {
                        visibleLogo.fadeOut("fast");
                        randomLogo.fadeIn("fast");
//                    }

                }
            },

        relocatePostDetail:
            function()
            {
                var postDetailLI = BigMan3D.thumbnailList.find("div.jqPostContent:visible").closest("li");

                if(postDetailLI.length > 0)
                {
                    BigMan3D.thumbnailLI.filter("li.jqRelocated").removeClass("jqRelocated").removeAttr("style");
                    BigMan3D.relocateThumbnails(postDetailLI);
                }

                var postDetails = $("div.jqPostContent");

                
            },

        windowResize:
            function()
            {
                
                BigMan3D.relocatePostDetail();

                var largeImageOverlay   = $("div.jqLargeImageOverlay");

                if(largeImageOverlay.length > 0)
                {
                    var largeImage = largeImageOverlay.children("img:first");

                    var largeImageWidth = parseInt(largeImage.data("Width"));
                    var largeImageHeight = parseInt(largeImage.data("Height"));

                    if(largeImageWidth > 0 && largeImageHeight > 0)
                    {
                        var allowedWidth    = $(window).width() - 50;
                        var allowedHeight    = $(window).height() - 110;

                        var allowedMaxWidth     = Math.max(200, (allowedWidth - (allowedWidth%200)));
                        var allowedMaxHeight    = allowedHeight;

                        var resizeRatio         = Math.min(allowedMaxWidth/largeImageWidth, allowedMaxHeight/largeImageHeight);

                        var newWidth       = Math.min(largeImageWidth, largeImageWidth * resizeRatio);
                        var newHeight       = Math.min(largeImageHeight, largeImageHeight * resizeRatio);

                        //largeImage.height(newHeight).width(newWidth);
                        largeImage.css({
                            width : newWidth,
                            height: newHeight
                        });

                        largeImage.data("Width", largeImageWidth);
                        largeImage.data("Height", largeImageHeight);
                    }
                }
            },
       fixPostHeight:
            function()
            {
                    var postContent = $("div.jqPostContent:visible:first");

                    if(postContent.length > 0)
                    {
                        var thumbnailLI = postContent.closest("li.jqPostThumbnailLI");

                        var postContentHeight = postContent.outerHeight();
                        var additionalHeight    = (postContentHeight % 200) > 0 ? 200 - (postContentHeight % 200) : 0;
                        var liHeight = postContentHeight + additionalHeight;

                        postContent.height(postContent.height() + additionalHeight);

                        thumbnailLI.css({
                                               height: liHeight
                                            });
                    }
              },
         showGlossaryPopup:
            function()
            {
                var visibleGlossaryPopups   = $("div.jqGlossaryPopupContainer:visible");
                var visibleGalleryPopupsToHide  = visibleGlossaryPopups;

                var current                 = $(this);
                var documentScrollTop       = document.documentElement.scrollTop ? document.documentElement.scrollTop : (document.body.scrollTop ? document.body.scrollTop : 0);
                // edited for testing.
                var windowBottom = documentScrollTop + $(window).height();
                visibleGlossaryPopups.each(function(){
                var current = $(this);
                var currentOffset = current.position();//current.offset();

                if(currentOffset.top > windowBottom || (currentOffset.top + current.outerHeight()) < documentScrollTop)
                {
                    visibleGlossaryPopups = visibleGlossaryPopups.not(current);
                }
                });

                var existingGlossaryPopup   = visibleGlossaryPopups.filter("[name='" + current.attr("name") + "']");

                if(visibleGlossaryPopups.filter(":last").is("[name='" + current.attr("name") + "']"))
                {
                    return false;
                }

                if(existingGlossaryPopup.length > 0)
                {
                    existingGlossaryPopup.appendTo("body");
                }
                else
                {
                var pageContainer           = current.closest(".jqPostContent");
                var pageContainerOffset     = pageContainer.position();//pageContainer.offset();

                var glossaryPopup           = $("#jqGlossaryPopupContainer").clone(true).removeAttr("id");

                var popupTop                = 0;
                var popupLeft               = 0;
                var postID                  = current.attr("id");


                $.ajax({
                            type:       'post',
                            dataType:   'json',
                            url:        glossaryPopupUrl,
                            data:       {id : postID, title : current.attr("name")},
                            beforeSend: function()
                                        {
                                            Loader.show($("div.jqPostContent"));
                                        },
                            complete:   Loader.hide,
                            success:    function(reply)
                                        {
                                            if(reply)
                                            {

                                                glossaryPopup.appendTo("body:first")
                                                     .attr("name", current.attr("name"))
                                                     .find(".jqGlossaryPopupContent")
                                                     .html($(unescape(reply.success)))
                                                     .end()
                                                     .find(".jqGlossaryPopupTitle")
                                                     .html(current.attr("name"));


                                                    if(visibleGlossaryPopups.length == 1)
                                                    {
                                                        var lastVisibleGlossaryPopup = visibleGlossaryPopups.filter(":last");
                                                        var lastVisibleGlossaryPopupOffset  = lastVisibleGlossaryPopup.offset();
                                                        popupTop                = lastVisibleGlossaryPopupOffset.top + 40;
                                                        popupLeft               = lastVisibleGlossaryPopupOffset.left + 40;
                                                    }
                                                    else if(visibleGlossaryPopups.length > 1)
                                                    {
                                                        var firstVisibleGlossaryPopup = visibleGlossaryPopups.filter(":first");
                                                        var firstVisibleGlossaryPopupOffset  = firstVisibleGlossaryPopup.offset();
                                                        popupTop                = firstVisibleGlossaryPopupOffset.top;
                                                        popupLeft               = firstVisibleGlossaryPopupOffset.left;
                                                    }
                                                    else
                                                    {
                                                        var pageVisibleAreaBottom   = Math.min($(window).height() + documentScrollTop, pageContainerOffset.top + pageContainer.outerHeight());
                                                        var pageVisibleAreaTop      = Math.max(pageContainerOffset.top, documentScrollTop);
                                                        var pageVisibleCenter       = Math.max(pageContainerOffset.top, documentScrollTop) + ((pageVisibleAreaBottom - pageVisibleAreaTop) - glossaryPopup.outerHeight()) /2;
                                                        popupTop                    = Math.max(pageVisibleCenter, documentScrollTop, pageContainerOffset.top);
                                                        popupLeft                   = pageContainerOffset.left + (pageContainer.outerWidth() - glossaryPopup.outerWidth())/2;
                                                    }

                                                    if(visibleGalleryPopupsToHide.length > 1)
                                                    {
                                                        visibleGalleryPopupsToHide.filter(":not(:last)").hide();

                                                    }
                                                    glossaryPopup.css({
                                                            position: "absolute",
                                                            'z-index' : '10000',
                                                            top : popupTop,
                                                            left: popupLeft
                                                    }).show();
                                              }
                                        }
                    });
                }

                return false;

            },
         hideGlossaryPopup:
            function()
            {
                $(this).closest("div.jqGlossaryPopupContainer").hide('fast', function(){ $(this).remove(); });
                return false;
                /*var glossaryPopup           = $("#jqGlossaryPopupContainer");
                glossaryPopup.fadeOut("slow");*/
            }

    };


    var Loader  = {
        id:     "jqLoader",
        loader: null,
        height: 9,
        width: 60,
        init:
            function()
            {
                Loader.loader   = $("#" + Loader.id).css({
                                                        display: "none",
                                                        position: "absolute",
                                                        left: 0,
                                                        top: 0,
                                                        "z-index": 1000
                                                    });
//                Loader.height   = Loader.loader.outerHeight();
//                Loader.width    = Loader.loader.outerWidth();
            },
        show:
            function()
            {
                var container = document;
                var append    = true;

                if(arguments.length > 0)
                {
                    container = arguments[0];
                }

                if(arguments.length > 1)
                {
                    append = arguments[1];
                }

                if(arguments.length > 0 && append == true)
                {
                    container.append(Loader.loader);
                }
                else
                {
                    $("body").append(Loader.loader);
                }

                var containerHeight = container.outerHeight() > 0 ? container.outerHeight() : container.parent().outerHeight();
                var containerWidth  = container.outerWidth() > 0 ? container.outerWidth() : container.parent().outerWidth();

                var loaderTop       = (containerHeight - Loader.height) / 2;
                var loaderLeft      = (containerWidth - Loader.width) / 2;

                if(append == false)
                {
                    var containerOffset = container.offset();
                    
                    loaderTop += containerOffset.top;
                    loaderLeft += containerOffset.left;
                }
                
                Loader.loader.css({
                    left: loaderLeft,
                    top: loaderTop
                }).show();
            },
        hide:
            function()
            {
                if(Loader.loader.is(":visible"))
                {
                    Loader.loader.hide();
                }
            }
    };


    /**
     * Document ready.
     */
    $(BigMan3D.ready);


})(jQuery, this, this.document);

