/**
 * 对话框类
 */


 /**
  * 
  * @param {Object} attribute{
  * 	width 宽度
  * 	height 高度
  * 	type 类型
  * 	text 文本 如果类型为page 应为URL 如果类型为text 应为文本
  * }
  */
 function Dialog(attribute){
 	
 	this.width = attribute.width;
	this.height= attribute.height;
	this.type = attribute.type;
	this.title_class = '';
	this.content_style='';
	this.transparency=20;
	//this.text = attribute.text;
 }
 
 Dialog.prototype = {
 	
	setTitleStyle:function(class_name){
		this.title_class = class_name;
	},
	
	setContentStyle:function(class_name){
		this.content_style = class_name;
	},
	
	setText:function(text){
		this.text = text;
	},
	
	
	showDialog:function(){
		if(this.type=='page'){
			this._showPageDialog();
		}
		else{
			this._showTextDialog();
		}
	},
	
	hideDialog:function(value){
		var dlg = $("#lplus_dialog");
		var panel = $("#lplus_dialog_panel");		
		dlg.empty();
		dlg.remove();
		panel.empty();
		panel.remove();
		return value;
	},
	
	_showPageDialog:function(){
		alert("Page Dialog");
	},
	
	_showTextDialog:function(){
		// 透明背景
		var dialog_panel = $('<div id="lplus_dialog_panel"></div>')
		dialog_panel.appendTo("body");
		dialog_panel.css("background-color","#000");
		dialog_panel.css("position","absolute");
		dialog_panel.css("z-index","9998");
		dialog_panel.css("filter","alpha(style=0,opacity="+this.transparency+")");
		dialog_panel.css("opacity",this.transparency /100);
		dialog_panel.css("width",document.body.clientWidth+"px");
		var browser_height = document.all ? document.documentElement.clientHeight +16 : document.documentElement.clientHeight ;
		var doc_height = document.body.scrollHeight;
		//alert(doc_height);
		var panel_height = browser_height > doc_height ? browser_height: doc_height;
		dialog_panel.css("height",panel_height +"px");
		document.documentElement.clientWidth
		dialog_panel.css("top","0px");
		dialog_panel.css("left","0px");
		
		// 对话框
		var dlg = $('<div id="lplus_dialog"></div>');
		dlg.appendTo("body");
		//dlg.css("background-color","#FFF");
		dlg.css("width",this.width + "px");
		dlg.css("height",this.height + "px");
		dlg.css("border","0px solid");
		dlg.css("position","absolute");
		dlg.css("z-index","9999");
		dlg.css("top",(browser_height - this.height-100)/2 + 'px');
		dlg.css("left",(document.body.clientWidth - this.width)/2 + 'px');
		dlg.html(this.text);
		// 滑动处理就 OK
		
		
	}
 }

