
(function(win,undefined) {
	var Dialog=J16.Class.extend( {
	options: {
	html:'',iframe:'',title:'标题',width:200,height:80,onshow:function() {
	},onIframeLoaded:function() {
	},onclose:function() {
	},top:-1,left:-1,opacity:'.5',hideType:'display',temp:"<div id='alert1616_main'><table  cellspacing=\"0\"><tr class=\"alert_top\"><td class=\"lt\">&nbsp;
	</td><td class=\"ct\"><h2 id=\"alert1616_title\"></h2></td><td class=\"rt\">&nbsp;
	</td></tr><tr class=\"alert_content\"><td class=\"lc\">&nbsp;
	</td><td class=\"cc\"><div id=\"alert1616_content\"></div></td><td class=\"rc\">&nbsp;
	</td></tr><tr class=\"alert_bottom\"><td class=\"lb\">&nbsp;
	</td><td class=\"cb\"></td><td class=\"rb\">&nbsp;
	</td></tr></table><div id=\"alert1616_closer\" title=\"关闭\"></div></div>"
}
,init:function(opt) {
	this.setOpt(opt);
}
,setOpt:function(opt) {
	$.extend(this.options,opt)
}
,runOnce:function(inner) {
	var op=this.options.opacity;
	$('<div id="alert1616_cover" style="opacity:'+op+';
	filter:alpha(opacity='+(op*100)+');
	"></div>').appendTo($('body'));
	$(inner).appendTo($('body'));
	this.destroy(1);
}
,render:function() {
	var opt=this.options;
	if(opt.iframe!='') {
	$('#alert1616_content').html("<img style='position:absolute;
	top:50%;
	margin-top:-40px;
	left:50%;
	margin-left:-40px;
	' src='http://r.9533.com/iplatform/img/loading2.gif'/><iframe frameborder='0' scrolling='no' style='height:100%;
	width:100%;
	' src=\""+opt.iframe+"\"></iframe>");
}
else {
	$('#alert1616_content').html(opt.html);
}
$('#alert1616_title').html(opt.title);
	$('#alert1616_content').height(opt.height).width(opt.width);},_setCoverWH:function() {
	$("#alert1616_cover").css( {
	height:"100%",width:"100%"
}
)},_setPos:function(opt) {
	var _h=win.innerHeight||document.documentElement.clientHeight;
	var _w=document.documentElement.offsetWidth;
	this.posRecord=document.all&&navigator.userAgent.indexOf('MSIE 6')!=-1? {
	left:opt.left==-1?(_w-opt.width-28)/2+document.documentElement.scrollLeft:opt.left,top:opt.top==-1?(_h-opt.height-36)/2+document.documentElement.scrollTop:opt.top,zIndex:10000
}
: {
	left:opt.left==-1?(_w-opt.width-(document.all?28:12))/2:opt.left,top:opt.top==-1?(_h-opt.height-(document.all?36:54))/2:opt.top,zIndex:10000
}
;$('#alert1616_main').css(this.posRecord);},bindEvents:function() {
	var opt=this.options,_this=this;
	$("#alert1616_closer").unbind("click").click(function() {
	_this.destroy()
}
);
	if(opt.iframe!='') {
	$('#alert1616_content iframe').unbind("load").bind('load',function() {
	$('#alert1616_content img').hide();
	var _win=$(this)[0].contentWindow;
	opt.onIframeLoaded&&opt.onIframeLoaded.call(_win);
	var link=_win.document.links,len=link.length;
	setTimeout(function() {
	for(var i=0;
	i<len;
	i++) {
	if(link[i].className.toLowerCase().indexOf('alert1616')!=-1) {
	document.all?link[i].attachEvent("onclick",setEvent):link[i].addEventListener("click",setEvent,false);
}
}},10);})}function setEvent(e) {
	$('#alert1616_content img').show();
	var e=e||win.event;
	var tar=e.target||e.srcElement,t=tar.getAttribute("title"),h=tar.getAttribute("_height"),w=tar.getAttribute("_width");
	t&&$('#alert1616_title').html(t);
	h&&$('#alert1616_content').height(h);
	w&&$('#alert1616_content').width(w);
}
if(navigator.userAgent.indexOf('MSIE 6')!=-1) {
	$(win).unbind("scroll").scroll(function() {
	_this._setPos(opt)
}
);}$(win).unbind("resize").resize(function() {
	_this._setPos(opt);
	_this._setCoverWH();
}
);},show:function(opt) {
	if(!$('#alertstyle')[0]) {
	var link=document.createElement('link');
	link.setAttribute('rel','stylesheet');
	link.setAttribute('type','text/css');
	link.id='alertstyle';
	link.href='http://r.9533.com/iplatform/img/tc.css';
	$('head')[0].appendChild(link);
}
if(opt)this.setOpt(opt);
	if(!$('#alert1616_cover')[0]) {
	this.runOnce(this.options.temp);
}
this.render();
	this.display();
	this.bindEvents();},display:function() {
	this._setPos(this.options);
	$('#alert1616_main').show();
	$('#alert1616_cover').show();
	this.options.onshow.call(this);
}
,destroy:function(notRunClose) {
	if(this.options.hideType!='display') {
	$('#alert1616_main').css( {
	top:'-999px'
}
);}else {
	$('#alert1616_main').hide();
}
$('#alert1616_cover').hide();
	notRunClose||this.options.onclose.call(this);}});
	J16.util.dialog=win.J16.util.dialog|| {
	show:function(opt) {
	var d=arguments.callee.Al||(arguments.callee.Al=new Dialog());
	opt?d.show(opt):d.display();
	if(!J16.util.dialog.hide) {
	J16.util.dialog.hide=function(b) {
	d.destroy(b)
}
}}}})(window);