var Loading = {
	//html: '<div id="loading_screen" style="position: absolute; display: none; z-index: 100; background-color: #fff; height: 20px; padding: 10px;"><center><img src="/images/ajax-loader.gif" alt="loading" /> Loading</center></div>',
	loading: false,
	opacity: 0.5,
    id: false,

    createMe: function()
	{
		var el = document.createElement( 'div' );
		el.innerHTML = '<center style="color: #fff"><img src="/images/ajax-loader.gif" alt="loading" align="absmiddle" /> Loading</center>';
		el.className = "loading_screen";
		el.style.position = "absolute";
		el.style.display = "none";
		el.style.zIndex = "100";
		el.style.backgroundColor = "#fff";
		el.style.height = "20px";
		el.setAttribute( 'id', 'loading_screen' );

		document.body.appendChild( el );
	},

	init: function()
	{
		var el = document.getElementById( 'loading_screen' );
		if( !el )
		{
			this.createMe();
			el = document.getElementById( 'loading_screen' );
			if( !el )
				return false;
		}
		this.loading = el;

		return true;
	},

	show: function( element )
	{
		if( !this.loading )
			if( !this.init() )
				return;

        if( this.loading.style.display == "block" )
            return;

        this.id = element;

        var ex = Utils.findPosX( element );
		var ey = Utils.findPosY( element );
		var ew = Utils.getWidth( element );
		var eh = Utils.getHeight( element );

		this.loading.style.top = ey + 'px';
		this.loading.style.left = ex + 'px';
		this.loading.style.width = ew + 'px';
		this.loading.style.height = eh + 'px';
		this.loading.style.lineHeight = eh + "px";
		this.loading.style.backgroundColor = "#666";
		this.loading.style.display = "block";


		// Set opacity to the percentage given
		this.loading.style.opacity = this.opacity;
		this.loading.style.filter = "alpha(opacity="+(this.opacity*100)+")";
	},

	hide: function( element )
	{
		if( !this.loading )
			if( !this.init() )
				return;

		if( element != -1 )
		{
			if( this.id != element )
				return;
		}

        this.loading.style.display = "none";
	}
}
