// JavaScript Document
//显示或隐藏屏幕变灰的层
jQuery.fn.xiaoliGray=function(show)
{
	if(show==true)
	{
		var de=document.documentElement;
		var maxWidth=(de.scrollWidth>de.clientWidth)?de.scrollWidth:de.clientWidth;
		var maxHeight=(de.scrollHeight>de.clientHeight)?de.scrollHeight:de.clientHeight;
		this.find("iframe").css({width:maxWidth+"px",height:maxHeight+"px"});
		this.find("div").css({width:maxWidth+"px",height:maxHeight+"px"});
		this.css({display:"block",width:maxWidth+"px",height:maxHeight+"px"});
	}else{
		this.css("display","none");
	}
}

jQuery.fn.xiaoliCenter=function()
{
	var xThis=this[0];
	xThis.style.display="block";
	var de=document.documentElement;
	var xTop=de.clientHeight/2-xThis.offsetHeight/2-30+de.scrollTop;
	xTop=(xTop<0)?10:xTop;
	var xLeft=de.clientWidth/2-xThis.offsetWidth/2;
	xThis.style.left=xLeft+"px";
	xThis.style.top=xTop+"px";
}

function openDialog(dialogId,draggable){
	var baseDiv = '<div id="baseDiv" style="position:absolute;z-index:1217;top:0;left:0;display:none;opacity:.5;filter:alpha(opacity=50);background:#000;">';
	baseDiv += '<div></div>';
	baseDiv += '</div>';
	$("body").append(baseDiv);
	$("#baseDiv").xiaoliGray(true);
	var z_index = $("#baseDiv").css("z-index") + 1;
	$("#"+dialogId).css("position","absolute");
	$("#"+dialogId).css("z-index",z_index);
	$("#"+dialogId).xiaoliCenter();
	if(draggable){
		$("#"+dialogId).draggable({
			handle:$("#"+dialogId).find("div.dialogTitle"),
			cursor:"move"
		});
	}
	jQuery(window).resize(function(){if(jQuery("#baseDiv").css("display")!="none"){$("#baseDiv").xiaoliGray(true);$("#"+dialogId).xiaoliCenter();}});//让灰色随窗口大小改变
}

function closeDialog(dialogId){
	$("#baseDiv").xiaoliGray(false);
	$("#"+dialogId).hide();
}