/***************************************************************************
*                                                                          *
*    Copyright (c) 2010 Dark Matter Studios. All rights reserved.          *
*                                                                          *
*--------------------------------------------------------------------------*
*                                                                          *
*	Name: common.js		                                                *
*    Description: js functions for the Storefront | jQuery =D.    		*
*    Date Created: 03/03/2010                                              *
*    Date Updated: 03/03/2011                                              *
*                                                                          *
****************************************************************************/

function ShowLoadingIndicator() {
    if (typeof(disableLoadingIndicator) != 'undefined' && disableLoadingIndicator) {
        return;
    }
    var windowWidth = $(window).width();
    var scrollTop;
    if(self.pageYOffset) {
        scrollTop = self.pageYOffset;
    }
    else if(document.documentElement && document.documentElement.scrollTop) {
        scrollTop = document.documentElement.scrollTop;
    }
    else if(document.body) {
        scrollTop = document.body.scrollTop;
    }
    $('#AjaxLoading').css('position', 'absolute');
    $('#AjaxLoading').css('top', scrollTop+'px');
    $('#AjaxLoading').css('left', parseInt((windowWidth-150)/2)+"px");
    $('#AjaxLoading').show();
}

function HideLoadingIndicator() {
    $('#AjaxLoading').hide();
}

$(document).ready(function() {
    $('html').ajaxStart(function() {
        ShowLoadingIndicator();
    });

    $('html').ajaxComplete(function() {
        HideLoadingIndicator();
    });
    $('.InitialFocus').focus();
});


