var msgBoxId = 1;
function MsgBox(arg){
		this.title = arg.title;
		this.msg = arg.msg;
		this.width = arg.width;
		this.type = arg.type;
		this.fn = arg.fn;
		this.msgBoxId = msgBoxId;
		msgBoxId ++;
	}
MsgBox.prototype = {
	show : function(){
		 	var msgBox = document.createElement('div');
			msgBox.className = 'msgBox';
			msgBox.id = 'msgBox'+ this.msgBoxId;
		    if(isIE()){//IE
							msgBox.style.filter = "alpha(opacity:" + 0 + ")"; 
							}else{
								msgBox.style.opacity  = 0; 
								}	
			document.body.appendChild(msgBox);
			document.body.scrollTop = 100;
			
			msgBox.style.top = parseInt(document.documentElement.scrollTop) + 200 + 'px'
			//alert(document.documentElement.scrollTop)
			msgBox.style.width = this.width+'px';
			msgBox.style.left = (document.body.scrollWidth/2 - this.width/2) +'px';
			var msgBox_head = document.createElement('div');
			msgBox_head.className = 'head';
			msgBox_head.id = 'msgBox_head'+this.msgBoxId
			msgBox.appendChild(msgBox_head);
			
			
			var msgBox_title = document.createElement('div');
			msgBox_title.className = 'title';
			msgBox_title.id = 'msgBox_title'+ this.msgBoxId;
			msgBox_title.innerHTML = this.title;
			msgBox_head.appendChild(msgBox_title);
			
			/*var msgBox_closeButton = document.createElement('div');
			msgBox_closeButton.className = 'closeButton';
			msgBox_closeButton.id = 'msgBox_closeButton'+ this.msgBoxId;
			msgBox_head.appendChild(msgBox_closeButton);
			msgBox_closeButton.onclick = this.close;
			*/
			var message =  document.createElement('div');
			message.className = 'msg';
			message.innerHTML = this.msg;
			message.id = 'msgBox_message'+ this.msgBoxId;
			msgBox.appendChild(message);
			
			MsgBoxOpacityShow(msgBox.id,true);
			if(this.fn)this.fn();
						
		}
	}
function MsgBoxOpacityShow(oid,isShow){
		
		var o = document.getElementById(oid);
	  	if(isIE()){
			o.style.filter = "alpha(opacity:" + (o.filters.alpha.opacity+10) + ")";
		}else{
			var p =  parseFloat(o.style.opacity)+0.1;
			o.style.opacity =  p;
		}
		if(isIE()){ 
		   if(o.filters.alpha.opacity<100)setTimeout("MsgBoxOpacityShow('"+o.id+"',"+isShow+")",100);
		   else setTimeout("MsgBoxOpacityClose('"+o.id+"',"+isShow+")",3000);
		   
		}else{ 
			if(o.style.opacity <1) setTimeout("MsgBoxOpacityShow('"+o.id+"',"+isShow+")",100);
		   else setTimeout("MsgBoxOpacityClose('"+o.id+"',"+isShow+")",3000);
		}
	}
function MsgBoxOpacityClose(oid,isShow){
		
		var o = document.getElementById(oid);
	  	if(isIE()){
			o.style.filter = "alpha(opacity:" + (o.filters.alpha.opacity-10) + ")";
		}else{
			var p =  parseFloat(o.style.opacity)-0.1;
			o.style.opacity =  p;
		}
		if(isIE()){ 
		   if(o.filters.alpha.opacity>0)setTimeout("MsgBoxOpacityClose('"+o.id+"',"+isShow+")",100);
		   else destroyMsgBox(o.id);
		   
		}else{ 
			if(o.style.opacity >0) setTimeout("MsgBoxOpacityClose('"+o.id+"',"+isShow+")",100);
			else destroyMsgBox(o.id);
		}
		
		
	}
function destroyMsgBox(id){
			var msgBoxId = id.replace('msgBox','');
			document.getElementById('msgBox'+msgBoxId).style.display='none';
			document.getElementById('msgBox_head'+msgBoxId).removeChild(document.getElementById('msgBox_title'+msgBoxId));
			document.getElementById('msgBox'+msgBoxId).removeChild(document.getElementById('msgBox_message'+msgBoxId));
			document.getElementById('msgBox'+msgBoxId).removeChild(document.getElementById('msgBox_head'+msgBoxId));
			}
			
function isIE() {
		if (!window.ActiveXObject)
			return false;
		try {
			new ActiveXObject("Microsoft.XMLDOM");
			return true;
		} catch (err) {
			return false;
		}
	}	
