/**
 class="Dialog" rel="{type:'div',size:{w:600,h:400},url:'<?=BASEURI?>model_html/allcat',off:'hidden'}"
**/
$(document).ready(
	function(){
		$(".Dialog").click(function(){
			var option		=	$(this).attr('rel');
			eval("var arg	=	"+option);
			var height	=	$(window).height()/2-arg.size.h/2;
			var width	=	$(window).width()/2-arg.size.w/2;
			var dialog	=	"<div id='Dialog'><div class='dialog_off' onclick='offDialog(\""+arg.off+"\")'></div><div class='dialogiframe' id='dialogiframe'></div></div>";
			if(document.getElementById('Dialog')){
				$("#Dialog").css("display","block");
				$(this).attr("disabled",true);
				return true;
			}
			if(document.getElementsByTagName("form")){	$("form").append(dialog);	}
			else{	$("body").append(dialog);	}
			$("#Dialog").css("top",height+"px");
			$("#Dialog").css("left",width+"px");
			$("#dialogiframe").css("width",arg.size.w-10+"px");
			$("#dialogiframe").css("height",arg.size.h-30+"px");
			$("#Dialog").css("width",arg.size.w+"px");
			$("#Dialog").css("height",arg.size.h+"px");
			$("#dialogiframe").css("overflow","auto");
			if(!arg['type']){
				arg['type']='iframe';
			}
			switch(arg['type']){
				case 'iframe': 
					var append	=	"<iframe src='' name='main' width='"+(arg.size.w-15)+"' height='"+(arg.size.h-30)+"' frameborder='0' scrolling='auto' style='overflow: visible;' id='iframe_window'></iframe>";
					$("#dialogiframe").append(append);
					$("#iframe_window").attr("src",arg.url);
					//alert($("#dialogiframe").html());
				break;
				case 'image': 
				break;
				case 'div': $('#dialogiframe').load(arg['url']);
				break;
				default: alert('未定义摸拟模态窗口显示类型');	
			}
			$(this).attr("disabled",true);
		});
		
	}
);
function offDialog(offType){
	if(offType=='hidden'){
		$("#Dialog").css("display","none");
		$(".Dialog").attr("disabled",false);
	}
	else{
		$("#Dialog").remove();
		$(".Dialog").attr("disabled",false);
	}
}
