
// -- shadow_block_class

function shadow_block_class() {
	// rozsireni pro spravu stinu
	this.shadows = null;
	this.shadow_size = 15;
}

shadow_block_class.prototype.shadow_context = function() { return this.context == null ? context : this.context; } // globalni nebo lokalni context
shadow_block_class.prototype.shadow_container = function() { return this.container; } // vychozi this.container overridable

shadow_block_class.prototype.shadows_destroy = function() {
	if (this.shadows != null) {
		var f;
		for (f = this.shadows.length - 1; f >= 0; f--) {
			this.shadow_context().structure_destroy(this.shadows[f]);
			this.shadows[f] = null;
		}
		this.shadows = null;
	}
}

shadow_block_class.prototype.shadow_width = function() { return 0; } // overridable
shadow_block_class.prototype.shadow_height = function() { return 0; } // overridable

shadow_block_class.prototype.shadows_build = function() {

	var create;
	if (create = (this.shadows == null)) this.shadows = new Array();
	
	var s_x = new Array(0, this.shadow_size, this.shadow_width(), this.shadow_width() + this.shadow_size);
	var s_y = new Array(0, this.shadow_size, this.shadow_height(), this.shadow_height() + this.shadow_size);
	var f, sx, sy, sw, sh, el;
	var cont = this.shadow_container();
	
	for (f = 0; f < 3; f++) {
		sx = s_x[2];
		sy = s_y[f];
		sw = s_x[3] - s_x[2];
		sh = s_y[f + 1] - s_y[f];
		
		if (create) {
			el = this.shadow_context().createElement("DIV");
			el.style.position = "absolute";
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
			
			switch (f) {
				case 0 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_right_top.png')";
					else el.style.background = "url('/web/perfecto/gfx/sh_right_top.png')";
					break;
					
				case 1 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_right.png',sizingMethod='scale')";
					else el.style.background = "url('/web/perfecto/gfx/sh_right.png')";
					break;
					
				case 2 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_bottom_right.png')";
					else el.style.background = "url('/web/perfecto/gfx/sh_bottom_right.png')";
					break;
			}
			
			cont.appendChild(el);
			this.shadows[this.shadows.length] = el;
		} else {
			el = this.shadows[f];
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
		}
	}
	
	for (f = 1; f >= 0; f--) {
		sx = s_x[f];
		sy = s_y[2];
		sw = s_x[f + 1] - s_x[f];
		sh = s_y[3] - s_y[2];
		
		if (create) {
			el = this.shadow_context().createElement("DIV");
			el.style.position = "absolute";
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
			
			switch (f) {
				case 1 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_bottom.png',sizingMethod='scale')";
					else el.style.background = "url('/web/perfecto/gfx/sh_bottom.png')";
					break;
					
				case 0 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_bottom_left.png')";
					else el.style.background = "url('/web/perfecto/gfx/sh_bottom_left.png')";
					break;
			}
			
			cont.appendChild(el);
			this.shadows[this.shadows.length] = el;
		} else {
			el = this.shadows[3 + (1 - f)];
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
		}
	}
}

