var MsgBox = function() {
	this.msg = '';						//mesaj statis
	this.contentId = '';				//id-ul div-ului in care se pune mesajul - cu clasa mCi pentru a fi ascuns
	this.url = '';						//url pentru iframe
	this.title = 'Bestmusic';			//Titlul afisat in bara mesajului
	this.width = '500';					//width-ul boxului
	this.height = '300';				//height-ul boxului
	this.close = 'inchide ';			//textul pt butonul de close
	this.fullBg = false;				//true ascunde toata pagina cu bg transparent, false nu ascunde decat zona boxului
	this.persist = false;				//true daca se doreste sa nu se stearga contentul la close
	
	
	this.cont;
	this.window;
	this.totalW = document.viewport.getWidth();
	this.totalH = document.viewport.getHeight();
	this.Win = window;
	this.curPos;
};

MsgBox.prototype = {
	init:function() {
		var bg, msgbox, title, close, close_span;
		
		msgbox = this.createElement('div', 'msg', '', {height:this.height-55+'px'});
		this.cont = this.createElement('div', 'msgcont', '', {display:'none'}, '');
		this.window = this.createElement('div', 'window', '', {width:this.width+'px', height:this.height+'px', top:(this.totalH-this.height)/2+'px', left:(this.totalW-this.width)/2+'px'});
		title = this.createElement('div', 'title', 'column first full', '', this.title);
		close = this.createElement('a', 'close', 'align-right', '', this.close);
		close_span = this.createElement('span', '', '', '', 'x');

		if (this.fullBg) {
			bg = this.createElement('div', 'msgbg', '', {height:this.totalH+'px'});
			this.cont.appendChild(bg);
		}
		close.appendChild(close_span);
		title.appendChild(close);
		this.window.appendChild(title);
		this.window.appendChild(msgbox);
		this.cont.appendChild(this.window);
		document.body.appendChild(this.cont);
		
		if (this.url != '') {
			msgbox.innerHTML = '<iframe id="frame_box" src="' + this.url + '" frameborder="0"></iframe>';
		} else if (this.contentId != '') {
			msgbox.innerHTML = $(this.contentId).innerHTML;
			$(this.contentId).remove();
		} else if (this.msg != '') {
			msgbox.innerHTML = this.msg;
		}
		
		var inOBJ = this;
		
		Event.observe(close, 'click', function(e){inOBJ.hide(); return false});

		Event.observe(this.Win, 'resize', function(e){inOBJ.resize();});
		
		if (Prototype.Browser.IE6) {
			Event.observe(this.Win, 'scroll', function(e){inOBJ.arange();});
		}
	},

	createElement:function(tag, id, className, stiluri, text) {
		if (tag && tag != '') {
			var elem;
			elem = document.createElement(tag);
			
			if (text && text != '') {
				var elemText;
				elemText = document.createTextNode(text);
				elem.appendChild(elemText);
			}
			
			if (id && id != '') {
				elem.id = id;
			}
			
			if (className && className != '') {
				elem.className = className;
			}
			
			if (stiluri && stiluri != '') {
				for (i in stiluri) {
					prop = i.toString();
					val = stiluri[i].toString();
					eval('elem.style.'+prop+' = "'+val+'"');
				}
			}
			
			return elem;
		} else {
			return false;
		}
	},
	
	resize:function() {
		var w = document.viewport.getWidth();
		var h = document.viewport.getHeight();
		this.cont.style.width = w+'px';
		this.cont.style.height = h+'px';
		this.window.style.left = (w-this.width)/2+'px';
		this.window.style.top = (h-this.height)/2+'px';
	},
	
	arange:function() {
		var XY = document.viewport.getScrollOffsets();
		
		if (XY.left != this.cont.style.left || XY.top != this.cont.style.top) {
			this.cont.style.left = XY.left+'px';
			this.cont.style.top = XY.top+'px';
		}
	},
	
	show:function() {
		Effect.Appear(this.cont);
		
		document.observe('dom:loaded', 
			function(event){
				if (Prototype.Browser.IE) {
					var sels = $$('select');
					sels.each(function(sel, iter){sel.style.display='none'});
				}
				
				var objs = $$('object');
				objs.each(function(obj, iter){obj.style.display='none'});
				
				var embs = $$('embed');
				embs.each(function(emb, iter){emb.style.display='none'});
			}
		);
	},
	
	hide:function() {
		Effect.Fade(this.cont);
		
		if (Prototype.Browser.IE) {
			var sels = $$('select');
			sels.each(function(sel, iter){sel.style.display='block'});
		}
		
		var objs = $$('object');
		objs.each(function(obj, iter){obj.style.display='block'});
		
		var embs = $$('embed');
		embs.each(function(emb, iter){emb.style.display='block'});
		
		if (!this.persist) {
			this.cont.remove();
		}
	}
}
