(function($){$.extend($.fn,{_idoModalIndex:0,_idoModalZIndex:200000,hideIdoModal:function(indexId){$("select").show();$("#idomodal-overlay-"+indexId).remove();$("#idomodal-frame-"+indexId).remove();$("#idomodal-backmask-"+indexId).remove();$("#idomodal-movemask-"+indexId).remove();var idomodal=$("#idomodal-"+indexId);var timer=idomodal.data("disposeTimer");var interval=idomodal.data("autoHeightInterval");if(timer>0){window.clearTimeout(timer)}if(interval>0){window.clearInterval(interval)}idomodal.remove()},_getModalExpOpt:function(o,extOpt){if(!extOpt){return o}for(var i in extOpt){o[i]=extOpt[i]}return o},idoProcess:function(indexId,msg,extOpt){var $o=$("#idomodal-"+indexId);msg="<img src='http://img1.ido360.com/img/loading1.gif' valign='absmiddle'/>&nbsp;"+msg;if($o.size()>0){o.find(".idomodal-content").html(msg);return indexId}else{return $.fn.idoModal($.fn._getModalExpOpt({buttonText:{},content:msg,indexId:indexId,initWidth:300,showBottom:false,showClose:false,showTop:false,contentCss:{padding:"20px 10px","line-height":"18px"},_type:"process"},extOpt))}},idoAlert:function(msg,fn,extOpt){var fn1=function(data,args){if(fn){setTimeout(function(){fn(data,args)},0)}args.complete()};var title=!extOpt?"":extOpt.title;if(!title){title="爱度小贴士"}return $.fn.idoModal($.fn._getModalExpOpt({buttonText:{ok:"确定"},content:msg,okEvent:fn1,cancelEvent:fn1,title:title,initWidth:300,contentCss:{padding:"20px 10px","line-height":"18px"},_type:"alert"},extOpt))},idoConfirm:function(msg,fnOk,fnCancel,extOpt){var fn1=function(data,args){if(fnOk){setTimeout(function(){fnOk(data,args)})}args.complete()};var fn2=function(data){if(fnCancel){setTimeout(function(){fnCancel(data)})}};var title=!extOpt?"":extOpt.title;if(!title){title="爱度小贴士"}return $.fn.idoModal($.fn._getModalExpOpt({content:msg,okEvent:fn1,cancelEvent:fn2,title:title,initWidth:300,contentCss:{padding:"20px 10px","line-height":"18px"},_type:"confirm"},extOpt))},idoModalFrame:function(setting,scrolling,frameborder){setting._type="iframe";setting.content.autoHeight=true;var c=setting.content;if(c.data){if(c.url.indexOf("?")==-1){c.url+="?"}else{c.url+="&"}c.url+=$.param(c.data)}setting.content=function(e){var id="t_loading_"+Math.random();id=id.replace(".","");e.html("<p style='padding:30px;' id='"+id+"'><img src='http://img1.ido360.com/img/loading1.gif' style='vertical-align:middle'/>&nbsp;正在加载内容，请稍侯...</p>");setTimeout(function(){var $frm=$("<iframe src='about:blank' width=\""+c.width+'" height="'+c.height+'" scrolling="'+(scrolling==undefined?"no":scrolling)+'" frameborder="'+(frameborder==undefined?"no":frameborder)+'" />');$frm.hide().bind("load",function(){e.find("#"+id).remove();$(this).show();e.holder.show();e.overlay.show();if(c.autoHeight){var height1=$frm.contents().height();var heightw1=$(window).height();if(heightw1>0&&height1>heightw1-67){height1=heightw1-67}$frm.height(height1)}setTimeout(function(){try{$($frm[0].contentWindow).resize(function(){var height1=$frm.contents().height();var heightw1=$(window).height();if(heightw1>0&&height1>heightw1-67){height1=heightw1-67}$frm.height(height1)})}catch(e2){}try{$frm.contents().find("input[type=text], input[type=password], textarea :eq(0)").focus()}catch(e1){}if(!Ido.IE){e.holder.resize()}var autoHeightInterval=window.setInterval(function(){var fh=$frm.height();var fch=$frm.contents().height();window.parent.trace(fh+","+fch);if(fh==fch){return}var w1=$(window).height();if(w1>0&&fch>w1-67){fch=w1-67}$frm.height(fch);if(!Ido.IE){e.holder.resize()}},1000);e.holder.data("autoHeightInterval",autoHeightInterval)},1)}).appendTo(e).attr("src",c.url)},0)};return $.fn.idoModal(setting)},idoModalLoad:function(setting){setting.content.autoHeight=true;var c=setting.content;if(!c.type){if(!c.data){c.type="GET"}else{c.type="POST"}}setting.content=function(e){var id="t_loading_"+Math.random();id=id.replace(".","");e.html("<p style='padding:30px;' id='"+id+"'><img src='http://img1.ido360.com/img/loading1.gif' style='vertical-align:middle'/>&nbsp;正在加载内容，请稍侯...</p>");setTimeout(function(){$.ajax({url:c.url,type:c.type,data:c.data,success:function(msg){e.html(msg)},error:function(){e.html("加载内容失败")},complete:function(){if(!Ido.IE){e.holder.resize()}}})},1)};return $.fn.idoModal(setting)},idoModal:function(setting){var ps=$.fn.extend({data:{},marginTop:"auto",buttonText:{ok:"确定",cancel:"取消"},okEvent:function(e){},cancelEvent:function(e){},initWidth:400,fixed:true,title:"爱度小贴士",content:"",showBottom:true,showClose:true,showMask:true,showTop:true,move:true,skinId:"idomodal1",dispose:0,showOnLoad:false,_type:null},setting);var allSel=$("select").hide();ps.marginTop="auto";ps.docWidth=$(window).width();ps.docHeight=$(window).height();var index=ps.indexId?ps.indexId:$.fn._idoModalIndex++;ps.indexId=index;ps.fixed=false;var idomodal=$("#idomodal-"+index);var overlay=$("#idomodal-overlay"+index);var frame=$("#idomodal-frame-"+index);var backmask=$("#idomodal-backmask-"+index);var movemask=$("#idomodal-movemask-"+index);if(idomodal.length>0){idomodal.remove();overlay.remove();frame.remove();backmask.remove();movemask.remove()}var bottomIndex=ps.showBottom?1:2;var s="";s+='<div id="idomodal-overlay-'+index+'" class="idomodal-overlay" style="background-color:#000;">';s+='<iframe id="idomodal-frame-'+index+'" frameBorder="0" style="width:100%;height:100%;overflow:hidden;display:block;" onmousemove="return false"></iframe>';s+="</div>";s+='<div id="idomodal-backmask-'+index+'" class="idomodal-backmask">&nbsp;</div>';s+='<div id="idomodal-movemask-'+index+'" class="idomodal-movemask">&nbsp;</div>';s+='<div id="idomodal-'+index+'" class="idomodal-main">';s+='<table class="idomodal-tb" cellpadding="0" cellspacing="0">';if(ps.showTop){s+="<tr>";s+='<td class="idomodal-top-left idomodal-m">&nbsp;</td>';s+='<td class="idomodal-top-mid idomodal-m">';s+='	<div class="idomodal-title-cont">';if(ps.showClose){s+='	<a class="idomodal-close idomodal-m" href="javascript:void(0)"></a>'}s+='	<a class="idomodal-move" href="javascript:void(0)"></a>';s+='		<span class="idomodal-title"></span>';s+="	</div>";s+="</td>";s+='<td class="idomodal-top-right idomodal-m">&nbsp;</td>';s+="</tr>"}else{s+="<tr>";s+='<td class="idomodal-top-left2 idomodal-m">&nbsp;</td>';s+='<td class="idomodal-top-mid2 idomodal-m">&nbsp;</td>';s+='<td class="idomodal-top-right2 idomodal-m">&nbsp;</td>';s+="</tr>"}s+="<tr>";s+='<td class="idomodal-mid-left idomodal-m">&nbsp;</td>';s+='<td class="idomodal-mid-mid">';s+='	<div class="idomodal-content"></div>';if(ps.showBottom){s+='<div class="idomodal-opts">';var _count=0;var _s="";for(var i in ps.buttonText){if(_count++>0){s+="&nbsp;&nbsp;"}_s=ps.buttonText[i];if(i=="ok"){s+='<a m="'+i+'" href="javascript:void(0)" class="idomodal-m">'+_s+"</a>"}else{if(_s.length==1){_s="　"+_s+"　"}else{if(_s.length==2){_s="&nbsp;"+_s+"&nbsp;"}}s+='<a m="'+i+'" href="javascript:void(0)"><table cellpadding="0" cellspacing="0" border="0"><tr><td class="idomodal-opt-other-tdl idomodal-m"></td><td class="idomodal-opt-other-tdm idomodal-m">'+_s+'</td><td class="idomodal-opt-other-tdr idomodal-m"></td></tr></table></a>'}}s+="</div>"}s+="</td>";s+='<td class="idomodal-mid-right idomodal-m">&nbsp;</td>';s+="</tr>";s+="<tr>";s+='<td class="idomodal-bot-left idomodal-m">&nbsp;</td>';s+='<td class="idomodal-bot-mid idomodal-m">&nbsp;</td>';s+='<td class="idomodal-bot-right idomodal-m">&nbsp;</td>';s+="</tr>";s+="</table>";s+="</div>";$(document.body).append(s);idomodal=$("#idomodal-"+index);overlay=$("#idomodal-overlay-"+index);frame=$("#idomodal-frame-"+index);backmask=$("#idomodal-backmask-"+index);movemask=$("#idomodal-movemask-"+index);overlay.css("z-index",$.fn._idoModalZIndex++);backmask.css("z-index",$.fn._idoModalZIndex++);idomodal.css("z-index",$.fn._idoModalZIndex++);movemask.css("z-index",$.fn._idoModalZIndex++);idomodal.attr("class",ps.skinId);if(ps.showOnLoad){idomodal.hide();overlay.hide()}var overlayOpacity=ps.showMask?0.2:0;overlay.css({opacity:0,position:(ps.fixed?"fixed":"absolute")}).animate({opacity:overlayOpacity},200);frame.css("opacity",0);movemask.css({position:(ps.fixed?"fixed":"absolute"),opacity:0.5});var tLeft=(ps.docWidth-ps.initWidth-18)/2;if(window.IdoMain){tLeft=(ps.docWidth-220-ps.initWidth-18)/2}idomodal.css({position:(ps.fixed?"fixed":"absolute"),width:ps.initWidth+18,left:tLeft});idomodal.resize(function(){if(!ps.showMask){var top=idomodal.offset().top;if(ps.fixed){top-=$(document).scrollTop()}overlay.css({height:idomodal.height(),width:idomodal.width(),left:idomodal.offset().left,top:top})}if(ps.marginTop=="auto"){var scrollTop=ps.fixed?0:$(document).scrollTop();var marginTop=($(window).height()-idomodal.height())/2+scrollTop;if(marginTop<0){marginTop=0}if(idomodal.offset().top<1){idomodal.css("top",marginTop,function(){if(!ps.showMask){overlay.css("top",marginTop)}})}else{idomodal.animate({top:marginTop},"fast",function(){if(!ps.showMask){overlay.css("top",marginTop)}})}}});idomodal.find(".idomodal-top-mid, .idomodal-mid-mid, .idomodal-bot-mid").width(ps.initWidth);idomodal.find(".idomodal-move").width(ps.initWidth-20);var $con=idomodal.find(".idomodal-content");if(ps.contentCss){$con.css(ps.contentCss)}if(typeof ps.content=="string"){$con.html(ps.content)}if(typeof ps.content=="function"){var e=$con;e.holder=idomodal;e.overlay=overlay;ps.content(e)}if(ps.marginTop=="auto"){var scrollTop=ps.fixed?0:$(document).scrollTop();var marginTop=($(window).height()-idomodal.height())/2+scrollTop;if(marginTop<0){marginTop=0}idomodal.css("top",marginTop)}if(ps.showMask){overlay.css({height:$(document).height(),width:"100%"})}else{var top=idomodal.offset().top;if(ps.fixed){top-=$(document).scrollTop()}overlay.css({height:idomodal.height(),width:idomodal.width(),left:idomodal.offset().left,top:top})}idomodal.find(".idomodal-title").html(ps.title);if(ps.showBottom){if(ps.buttonText.ok){var $ok=idomodal.find("a[m=ok]").bind("click",function(e){var args={complete:function(){$.fn.hideIdoModal(index)}};allSel.show();ps.okEvent(ps.data,args,idomodal)});$.fn._idoModalOptBtn($ok,ps,"ok")}if(ps.buttonText.cancel){var $cancel=idomodal.find("a[m=cancel]").one("click",function(e){ps.cancelEvent(ps.data);$.fn.hideIdoModal(ps.indexId)});$.fn._idoModalOptBtn($cancel,ps,"cancel")}for(var i in ps.buttonText){if(i=="ok"||i=="cancel"){continue}var $btn=idomodal.find("a[m="+i+"]").click(function(e){var f=eval("ps."+$(this).attr("m")+"Event");var args={complete:function(){$.fn.hideIdoModal(index)}};if(typeof(f)=="function"){allSel.show();f(ps.data,args,idomodal)}});$.fn._idoModalOptBtn($btn,ps,i)}}if(ps.showClose){idomodal.find(".idomodal-close").bind("click",function(e){if(ps._type=="alert"){var args={complete:function(){$.fn.hideIdoModal(index)}};allSel.show();ps.okEvent(ps.data,args)}else{ps.cancelEvent(ps.data);$.fn.hideIdoModal(ps.indexId)}return false})}var offX=0,offY=0,isDrag=false;idomodal.find(".idomodal-move").mousedown(function(e){backmask.show();var x=idomodal.offset().left;var y=idomodal.offset().top;offX=e.pageX-x;offY=e.pageY-y;if(ps.fixed){y-=$(document).scrollTop()}movemask.show().css({top:y,left:x,width:idomodal.width(),height:idomodal.height()});isDrag=true;return false});$(document).mouseup(function(e){if(!isDrag){return true}isDrag=false;var x=e.pageX,y=e.pageY;if(x<0){x=0}if(y<0){y=0}var top=y-offY;if(ps.fixed){top-=$(document).scrollTop()}idomodal.css({top:top,left:x-offX});if(!ps.showMask){overlay.css({left:idomodal.offset().left,top:top})}backmask.hide();movemask.hide();return false}).mousemove(function(e){if(!isDrag){return true}var top=e.pageY-offY;if(ps.fixed){top-=$(document).scrollTop()}movemask.css({top:top,left:e.pageX-offX});return false});if(ps.dispose>0){var disposeTimer=window.setTimeout(function(){var $o=$("#idomodal-"+index);if($o.size()>0){$o.hide("fast",function(){$.fn.hideIdoModal(index)})}idomodal.removeData("disposeTimer")},ps.dispose*1000);idomodal.data("disposeTimer",disposeTimer)}return index},_idoModalOptBtn:function($btn,ps,type){if(ps.skinId=="idomodal1"){$btn.addClass("idomodal-opt-"+(type=="ok"?"ok":"other"))}else{}}});$.idoModal=$.fn.idoModal;$.idoAlert=$.fn.idoAlert;$.idoConfirm=$.fn.idoConfirm;$.hideIdoModal=$.fn.hideIdoModal;$.idoProcess=$.fn.idoProcess;$.idoModalFrame=$.fn.idoModalFrame;$.idoModalLoad=$.fn.idoModalLoad})(jQuery);