﻿// ---------------------------------------------------------------------
// Description:		Master.js
//					ClientSide Script for master.aspx.js
// 
// Autor:			Herbert Granofszky
// Date:			30.10.2007
// 
// (c) by team ModulAcht. All rights reserved
// ---------------------------------------------------------------------

var Master =
{
    ajaxLoaderElementId : null,
    images : new Array(),
    
    initialize : function()
    {
        this._ajaxLoaderIconElement = $(this.ajaxLoaderElementId);
        this._preloadImages(this.images);
        window.onerror = this._onError.bind(this);
    },
    
    registerPreloadImage : function(argPath)
    {
        this.images.push(argPath);
    },
    
    setAjaxLoaderIconVisible : function(argVisible)
    {
        if (this._ajaxLoaderIconElement == null)
        {
            // in case it was initialized too early -> try to get it now
            if (this.ajaxLoaderElementId != null)
            {
                this._ajaxLoaderIconElement = $(this.ajaxLoaderElementId);
            }
            if (this._ajaxLoaderIconElement == null)
            {
                return;
            }
        }
        
        if (argVisible)
        {
            this._ajaxLoaderIconElement.show();  
        }
        else
        {
            this._ajaxLoaderIconElement.hide();
        }
    },
    
    _preloadImages : function(argImageFilenames)
    {
        for (var i=0; i < argImageFilenames.length; i++)
        {
            var tempImage = new Image();
            tempImage.src = argImageFilenames[i];
        }
    },
    
    _onError : function()
    {
        return false;
    }
};
