

var flashBox = {

	isOpen:false,
	name : "flashbox",
	dv : $("flashbox"),
	mov : null,
	is_after_mov : false ,
	
	headerText : '&nbsp;',
	footerText : '<a href="#" onclick="flashBox.close(); return false;" class="link">zamknij okno</a>',

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	show : function(type, url, title)
	{
		switch(type)
		{
			case 'div':
				
				SetPos(this.dv, 200, YmousePosition-100);
				$(this.name+"_content").innerHTML = $(url).innerHTML;

			break;
			
			case 'img':
			
				SetPos(this.dv, 50, 50);
				$(this.name+"_content").innerHTML = '<img src="'+url+'">';
			
			break;

			case 'http':
				
				var req = mint.Request();
				var that = this;
    
				req.OnSuccess = function()
				{
					$(that.name+"_content").innerHTML = this.responseText;
				}

				req.Send(url);
				SetPos(this.dv, 250, 250);
				
			break;
			
			default:
				return;
		}

		var head = $(this.name+"_header");
		head.innerHTML = title || this.headerText;

		this.dv.style.display = "block";

		mint.fx.Style(this.dv, "opacity", 0, 100, 10, 200);	
		this.is_after_mov = false;

		if(this.mov == null)
		{
			this.mov = document.createElement('div');

			var p = GetPos(head);
			var s = GetSize(this.dv);

			SetSize(this.mov, s.width, s.height);
			SetPos(this.mov, p.x, p.y);

			this.mov.innerHTML = "";
			this.mov.style.position = "absolute";
			this.mov.style.display = "none";
			this.mov.style.border = "1px dashed #999999";
			this.mov.style.backgroundColor = "#cccccc";
			this.mov.style.cursor = "move";
			this.mov.setAttribute('id', this.name+"_mover");

			document.body.appendChild(this.mov);
			var that = this;
			mint.gui.RegisterDragObject(this.mov);
			
			AddEvent(this.mov, 'mouseup', function(){	that.showMove(0, head);});
			AddEvent(head, 'mouseover', function(){	that.showMove(1, head);});
			AddEvent(this.dv, 'mouseout', function(){	that.showMove(-1, head);});
		}
		
	},
	
	//if(!ereg("<|>", $v))
	//$ret = str_replace("\"", "&quot;", $ret);
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	close : function(funct)
	{
		var that = this;
		mint.fx.Style(this.dv, "opacity", 100, 0, 10, 200, null, function()
		{
			that.dv.style.display = "none";
			if(funct){
				//window.execScript(funct);
				eval(funct);
				}
		}
		);
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	scroll : function()
	{
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		return yScroll;
	},	
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	showMove : function(t, hd)
	{
	//return;
		if(t == 1)
		{
			if(this.is_after_mov)
				return;
		
			var p = GetPos(hd);
			var s = GetSize(this.dv);

			SetSize(this.mov, s.width, s.height);
			SetPos(this.mov, p.x, p.y);
			SetOpacity(this.mov, 50);
			this.mov.style.display = 'block';
			//hd.style.visibility = 'hidden';
			
			this.is_after_mov = true;
		}
		else if(t == 0)
		{
			var p = GetPos(this.mov);
			this.mov.style.display = 'none';
			SetPos(this.dv, p.x, p.y);
		}
		else if(t == -1)
		{
			var that = this;
			//this.mov.style.display = 'none';
			setTimeout(function(){
				//that.is_after_mov = false;
				//hd.style.visibility = 'visible';
				
			}, 1000);
		}
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	setNewPos : function(hd)
	{
		if(this.mov != null)
		{
			//document.body.removeChild(this.mov);
			//this.mov = null;
		}
	}
	
};


