

var lightbox = Class.create();
var __G_LIGHTBOX_ON=false;
lightbox.prototype = {
	yPos : 0,
	xPos : 0,
	enabled:false,
	initialize: function(params) {
		if(this.enabled=(!__G_LIGHTBOX_ON))
			__G_LIGHTBOX_ON=true;
		this.params=params;
	},
	// Turn everything on - mainly the IE fixes
	activate: function(){
		if(!this.enabled) return;
		this.displayLightbox("block");
	},
	displayLightbox: function(display){
		//if(!$('lightboxOverlay')){
			//document.body.appendChild(new Element('DIV',{id:'lightboxOverlay'}));
			//modify by liugang 20081205  ie6 support
		//	document.body.appendChild(new Element('iframe',{id:'lightboxOverlay'}));
			//$('lightboxOverlay').src=Bonc.getContextPath()+"/resources/base/js/blank.html";
		//	$('lightboxOverlay').src=Bonc.Constants.BLANK_IMAGE_URL;
		//	$('lightboxOverlay').style.height=document.body.scrollHeight+"px";
		
		//}
		//$('lightboxOverlay').style.display = display;
		if(display != 'none') this.loadInfo();
	},
	loadInfo: function() {
		var msgObj=new Element('DIV',{'id':'lightbox'});
		var width=this.params.width ? this.params.width : 200;
		var height=this.params.width ? this.params.height : 100;
		var b_v = navigator.appVersion;
		var IE6 = b_v.search(/MSIE 6/i) != -1;
		var IE7 = b_v.search(/MSIE 7/i) != -1;
	
		if (IE6){
			 msgObj.style.top = document.body.scrollHeight/2-110+'px'; 
		}
		else if (IE7){
			 msgObj.style.top = document.body.scrollHeight/3-100+'px'; 
		}else{
			 msgObj.style.top = document.body.scrollHeight/3-100+'px'; 
		}
		msgObj.style.width=width+'px';
		msgObj.style.height=height+'px';
		msgObj.style.marginLeft=-width/2+'px';
		msgObj.style.marginTop=-height/2+'px';
		msgObj.style.border="0";

        document.body.appendChild(msgObj);
		var msg_title =new Element('DIV',{'id':'ImgClose'});
		msg_title.style.align = "center";
		msg_title.style.padding.right = "8px";
		msg_title.style.padding.left = "0px";
		msg_title.style.padding.top = "8px";

		msg_title.innerHTML = "<img src='"+Bonc.Constants.CLOSE_IMAGE_URL+"' style='cursor:pointer' >";
	    msgObj.appendChild(msg_title);  
	    
		var msg_content =new Element('DIV',{'id':'boxContent'});
		msg_content.style.align = "center";
		msg_content.style.padding.right = "8px";
		msg_title.style.padding.left = "0px";
		msg_content.style.padding.top = "0px";
		msgObj.appendChild(msg_content);
	   
		//var msg_bt=new Element('DIV',{'id':'lightboxBottom'});
	    //msgObj.appendChild(msg_bt); 
		
		msg_content.update(this.params.content);
		//var clickBt=new Element('INPUT',{type:'button',value:'确定'});	
		//msg_bt.appendChild(clickBt);
		//Event.observe(clickBt,'click',this.deactivate.bindAsEventListener(this));
		Event.observe(msg_title,'click',this.deactivate.bindAsEventListener(this));		
	},
	deactivate: function(){
		Element.remove($('lightbox'));
		this.displayLightbox("none");
		__G_LIGHTBOX_ON=false;
	}
}