﻿/*!
 * lhgcore Dialog Plugin v3.4.3
 * Date : 2011-05-30 09:35:11
 * Copyright (c) 2009 - 2011 By Li Hui Gang
 */
(function(a){var b=window,c,d,e,f=a.browser.msie&&a.browser.version<7?!0:!1,g=f?'<iframe hideFocus="true" frameborder="0" src="about:blank" style="position:absolute;z-index:-1;width:100%;height:100%;top:0px;left:0px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)"></iframe>':"",h=function(a){a=a||document;return a.compatMode=="CSS1Compat"?a.documentElement:a.body},i=function(){e||(e=1976);return++e},j=function(){if("pageXOffset"in b)return{x:b.pageXOffset||0,y:b.pageYOffset||0};var a=h(c);return{x:a.scrollLeft||0,y:a.scrollTop||0}},k=function(){var a=h(c);return{w:a.clientWidth||0,h:a.clientHeight||0}},l=function(){var a=document.getElementsByTagName("script"),b="",c=0,d=a.length,e=/lhgdialog(?:\.min)?\.js/i;for(;c<d;c++)if(e.test(a[c].src)){b=!document.querySelector?a[c].getAttribute("src",4):a[c].src;break}return b.split("?")}(),m=l[0].substr(0,l[0].lastIndexOf("/")+1),n=function(a){if(l[1]){var b=l[1].split("&"),c=0,d=b.length,e;for(;c<d;c++){e=b[c].split("=");if(a===e[0])return e[1]}}return null},o=n("s")||"default",p=function(){var b=h(c);a(d).css({width:Math.max(b.scrollWidth,b.clientWidth||0)-1+"px",height:Math.max(b.scrollHeight,b.clientHeight||0)-1+"px"})};while(b.parent&&b.parent!=b){try{if(b.parent.document.domain!=document.domain)break}catch(q){break}b=b.parent}if(n("t")==="self"||b.document.getElementsByTagName("frameset").length>0)b=window;c=b.document;try{c.execCommand("BackgroundImageCache",!1,!0)}catch(q){}a("head",c).append('<link href="'+m+"skins/"+o+'.css" rel="stylesheet" type="text/css"/>'),a.fn.fixie6png=function(){var b=a("*",this),c,d;for(var e=0,f=b.length;e<f;e++)c=a(b[e]).css("ie6png"),d=m+"skins/"+c,c&&(b[e].style.backgroundImage="none",b[e].runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+d+"',sizingMethod='scale')")},a.fn.dialog=function(b){var c=!1;this[0]&&(c=new a.dialog(b),this.bind("click",c.ShowDialog));return c},a.dialog=function(l){var m=this,n,o,q,r,s,t,u,v,w,x=m.opt=a.extend({title:"lhgdialog \u5f39\u51fa\u7a97\u53e3",cover:!1,titleBar:!0,btnBar:!0,xButton:!0,maxBtn:!0,minBtn:!1,cancelBtn:!0,width:400,height:300,id:"lhgdgId",link:!1,html:null,page:null,parent:null,dgOnLoad:null,onXclick:null,onCancel:null,onMinSize:null,fixed:!1,top:"center",left:"center",drag:!0,resize:!0,autoSize:!1,rang:!1,timer:null,iconTitle:!0,bgcolor:"#fff",opacity:.5,autoPos:!1,autoCloseFn:null,cancelBtnTxt:"\u53d6\u6d88",loadingText:"\u7a97\u53e3\u5185\u5bb9\u52a0\u8f7d\u4e2d\uff0c\u8bf7\u7a0d\u7b49..."},l||{}),y,z={},A=!1,B,C=function(a){var b=a.style,d=h(c),e=parseInt(b.left)-d.scrollLeft,f=parseInt(b.top)-d.scrollTop;b.removeExpression("left"),b.removeExpression("top"),b.setExpression("left","this.ownerDocument.documentElement.scrollLeft"+e),b.setExpression("top","this.ownerDocument.documentElement.scrollTop + "+f)},D=function(){var a,b;x.html?typeof x.html=="string"?a='<div id="lhgdg_inbox_'+x.id+'" class="lhgdg_inbox" style="display:none">'+x.html+"</div>":a='<div id="lhgdg_inbox_'+x.id+'" class="lhgdg_inbox" style="display:none"></div>':x.page&&(a='<iframe id="lhgfrm_'+x.id+'" frameborder="0" src="'+x.page+'" '+'scrolling="auto" style="display:none;width:100%;height:100%;"></iframe>'),b=['<div id="lhgdlg_',x.id,'" class="lhgdialog" style="width:',x.width,"px;height:",x.height,'px;">','<table border="0" cellspacing="0" cellpadding="0" width="100%">',"<tr>",'<td class="lhgdg_leftTop"></td>','<td id="lhgdg_drag_',x.id,'" class="lhgdg_top">',x.titleBar?'<div class="lhgdg_title_icon">'+(x.iconTitle?'<div class="lhgdg_icon"></div>':"")+'<div class="lhgdg_title">'+x.title+"</div>"+(x.minBtn?'<a class="lhgdg_minbtn" id="lhgdg_minbtn_'+x.id+'" href="javascript:void(0);" target="_self"></a>':"")+(x.maxBtn?'<a class="lhgdg_maxbtn" id="lhgdg_maxbtn_'+x.id+'" href="javascript:void(0);" target="_self"></a>':"")+(x.xButton?'<a class="lhgdg_xbtn" id="lhgdg_xbtn_'+x.id+'" href="javascript:void(0);" target="_self"></a>':"")+"</div>":"","</td>",'<td class="lhgdg_rightTop"></td>',"</tr>","<tr>",'<td class="lhgdg_left"></td>',"<td>",'<table border="0" cellspacing="0" cellpadding="0" width="100%">',"<tr>",'<td id="lhgdg_content_',x.id,'" style="background-color:#fff">',a,'<div id="lhgdg_load_',x.id,'" class="lhgdg_load"><span>',x.loadingText,"</span></div>","</td>","</tr>",x.btnBar?'<tr><td id="lhgdg_btnBar_'+x.id+'" class="lhgdg_btnBar"><div class="lhgdg_btn_div"></div></td></tr>':"","</table>","</td>",'<td class="lhgdg_right"></td>',"</tr>","<tr>",'<td class="lhgdg_leftBottom"></td>','<td class="lhgdg_bottom"></td>','<td id="lhgdg_drop_',x.id,'" class="lhgdg_rightBottom"></td>',"</tr>","</table>",g,"</div>"].join("");return b},E=function(){d=a("#lhgdgCover",c)[0];if(!d){var e='<div id="lhgdgCover" style="position:absolute;top:0px;left:0px;background-color:'+x.bgcolor+';">'+g+"</div>";d=a(e,c).css("opacity",x.opacity).appendTo(c.body)[0]}a(b).bind("resize",p),p(),a(d).css({display:"",zIndex:i()})},F=function(b,c,d,e){var g=k(),h=j(),i=b.offsetWidth,l=b.offsetHeight,m,n,o,p,q,r,s,t;e?(o=f?h.x:0,p=f?g.w+h.x-i:g.w-i,q=f?(p+h.x-20)/2:(p-20)/2,r=f?h.y:0,s=f?g.h+h.y-l:g.h-l,t=f?(s+h.y-20)/2:(s-20)/2):(o=h.x,q=h.x+(g.w-i-20)/2,p=h.x+g.w-i,r=h.y,t=h.y+(g.h-l-20)/2,s=h.y+g.h-l);switch(d){case"center":m=q;break;case"left":m=o;break;case"right":m=p;break;default:e&&f&&(d=d+h.x),m=d}switch(c){case"center":n=t;break;case"top":n=r;break;case"bottom":n=s;break;default:e&&f&&(c=c+h.y),n=c}a(b).css({top:n+"px",left:m+"px"}),e&&f&&C(b)},G=function(d){m.curWin=window,m.curDoc=document,a(d).bind("contextmenu",function(a){a.preventDefault()}).bind("mousedown",M),x.html&&x.html.nodeType&&(a(o).append(x.html),x.html.style.display=""),v=[window],b!=window&&v.push(b),x.page&&(m.dgFrm=a("#lhgfrm_"+x.id,c)[0],x.link||(m.dgWin=m.dgFrm.contentWindow,m.dgFrm.lhgDG=m),a(m.dgFrm).bind("load",function(){this.style.display="block";if(!x.link){var b=a.browser.msie?m.dgWin.document:m.dgWin;a(b).bind("mousedown",M),v.push(m.dgWin),m.dgDoc=m.dgWin.document,x.autoSize&&I(),a.isFunction(x.dgOnLoad)&&x.dgOnLoad.call(m)}n.style.display="none"})),x.xButton&&x.titleBar&&a(q).bind("click",x.onXclick||m.cancel),x.maxBtn&&x.titleBar&&(a(y).bind("click",m.maxSize),a(r).bind("dblclick",m.maxSize)),x.minBtn&&x.titleBar&&a.isFunction(x.onMinSize)&&a(B).bind("click",x.onMinSize)},H=function(a){var b=r.offsetHeight,c=s.offsetHeight,d=x.btnBar?u.offsetHeight:0,e=parseInt(a.style.height,10)-b-c-d;n.style.lineHeight=e+"px",t.style.height=e+"px"},I=function(){var a=r.offsetHeight,b=s.offsetHeight,c=x.btnBar?u.offsetHeight:0,d=s.offsetWidth*2,e,f,g;if(x.html)e=Math.max(o.scrollHeight,o.clientHeight||0),f=Math.max(o.scrollWidth,o.clientWidth||0);else if(x.page&&!x.link){if(!m.dgDoc)return;g=h(m.dgDoc),e=Math.max(g.scrollHeight,g.clientHeight||0),f=Math.max(g.scrollWidth,g.clientWidth||0)}e=e+a+b+c,f=f+d,m.reDialogSize(f,e),F(m.dg,"center","center",x.fixed)},K=function(b){function p(d){for(var e=0,g=i.length;e<g;e++)a(i[e].document).unbind("mousemove",o),a(i[e].document).unbind("mouseup",p);c=null,b=null,h.y<0&&(m.dg.style.top="0px"),x.fixed&&f&&C(m.dg),a.browser.msie&&m.dg.releaseCapture()}function o(a){var b={x:a.screenX,y:a.screenY};h={x:h.x+(b.x-c.x),y:h.y+(b.y-c.y)},c=b,x.rang&&(h.x<n.x&&(h.x=n.x),h.y<n.y&&(h.y=n.y),h.x>d&&(h.x=d),h.y>g&&(h.y=g)),m.dg.style.top=x.fixed&&!f?h.y-n.y+"px":h.y+"px",m.dg.style.left=x.fixed&&!f?h.x-n.x+"px":h.x+"px"}var c,d,g,h,i=v,l,n;a(b).bind("mousedown",function(b){if(b.target.id!=="lhgdg_xbtn_"+m.opt.id){l=k(),n=j();var q=m.dg.offsetLeft,r=m.dg.offsetTop,s=m.dg.clientWidth,t=m.dg.clientHeight;h=x.fixed&&!f?{x:q+n.x,y:r+n.y}:{x:q,y:r},c={x:b.screenX,y:b.screenY},d=l.w+n.x-s,g=l.h+n.y-t,m.dg.style.zIndex=parseInt(e,10)+1;for(var u=0,v=i.length;u<v;u++)a(i[u].document).bind("mousemove",o),a(i[u].document).bind("mouseup",p);b.preventDefault(),a.browser.msie&&m.dg.setCapture()}})},L=function(b){function p(d){for(var e=0,f=h.length;e<f;e++)a(h[e].document).unbind("mousemove",o),a(h[e].document).unbind("mouseup",p);c=null,b=null,a.browser.msie&&m.dg.releaseCapture()}function o(a){var b={x:a.screenX,y:a.screenY};i={w:b.x-c.x,h:b.y-c.y},i.w<200&&(i.w=200),i.h<100&&(i.h=100),m.dg.style.top=x.fixed?g.y-n.y+"px":g.y+"px",m.dg.style.left=x.fixed?g.x-n.x+"px":g.x+"px",m.reDialogSize(i.w,i.h)}var c,d,f,g,h=v,i,l,n;a(b).bind("mousedown",function(b){f=m.dg.clientWidth,d=m.dg.clientHeight,i={w:f,h:d},l=k(),n=j();var q=m.dg.offsetLeft,r=m.dg.offsetTop;g=x.fixed?{x:q+n.x,y:r+n.y}:{x:q,y:r},c={x:b.screenX-f,y:b.screenY-d},m.dg.style.zIndex=parseInt(e,10)+1;for(var s=0,t=h.length;s<t;s++)a(h[s].document).bind("mousemove",o),a(h[s].document).bind("mouseup",p);b.preventDefault(),a.browser.msie&&m.dg.setCapture()})},M=function(a){m.dg.style.zIndex=parseInt(e,10)+1,e=parseInt(m.dg.style.zIndex,10),a.stopPropagation()},N=function(){F(m.dg,x.autoPos.top,x.autoPos.left,x.fixed)},O=function(){m.dgFrm&&(x.link||a(m.dgFrm).unbind("load"),m.dgFrm.src="about:blank",m.dgFrm=null),x.html&&x.html.nodeType&&(a(m.curDoc).append(x.html),x.html.style.display="none"),x.autoPos&&a(b).unbind("resize",N),v=[],a(m.dg).remove(),m.dg=null,A=!1,z={},n=o=q=r=s=u=t=y=B=null};m.ShowDialog=function(){if(a("#lhgdlg_"+x.id,c)[0])return m;x.cover&&E(),x.fixed&&(x.maxBtn=!1,x.minBtn=!1);var d=x.fixed&&!f?"fixed":"absolute",e=D();m.dg=a(e,c).css({position:d,zIndex:i()}).appendTo(c.body)[0],n=a("#lhgdg_load_"+x.id,c)[0],o=a("#lhgdg_inbox_"+x.id,c)[0],q=a("#lhgdg_xbtn_"+x.id,c)[0],r=a("#lhgdg_drag_"+x.id,c)[0],s=a("#lhgdg_drop_"+x.id,c)[0],u=a("#lhgdg_btnBar_"+x.id,c)[0],t=a("#lhgdg_content_"+x.id,c)[0],y=a("#lhgdg_maxbtn_"+x.id,c)[0],B=a("#lhgdg_minbtn_"+x.id,c)[0],H(m.dg),F(m.dg,x.top,x.left,x.fixed),G(m.dg),x.drag?K(r):r.style.cursor="default",x.resize?L(s):s.style.cursor="default",f&&a(s).css("ie6png")&&a(m.dg).fixie6png(),x.btnBar&&x.cancelBtn&&m.addBtn("dgcancelBtn",x.cancelBtnTxt,x.onCancel||m.cancel),x.html&&(n.style.display="none",o.style.display="",x.autoSize&&I()),x.timer&&m.closeTime(x.timer,x.autoCloseFn),x.html&&a.isFunction(x.dgOnLoad)&&x.dgOnLoad.call(m),x.autoPos&&a(b).bind("resize",N)},m.reDialogSize=function(b,c){a(m.dg).css({width:b+"px",height:c+"px"}),H(m.dg)},m.maxSize=function(){var b,c;b=k(),c=j(),A?(m.reDialogSize(z.dgW,z.dgH),a(m.dg).css({top:z.dgT,left:z.dgL}),a(y).addClass("lhgdg_maxbtn").removeClass("lhgdg_rebtn"),x.drag&&(K(r),r.style.cursor="move"),x.resize&&(L(s),s.style.cursor="nw-resize"),A=!1):(z.dgW=m.dg.offsetWidth,z.dgH=m.dg.offsetHeight,z.dgT=m.dg.style.top,z.dgL=m.dg.style.left,a(m.dg).css({top:c.y+"px",left:c.x+"px"}),m.reDialogSize(b.w,b.h),a(y).addClass("lhgdg_rebtn").removeClass("lhgdg_maxbtn"),x.drag&&a(r).unbind("mousedown").css("cursor","default"),x.resize&&a(s).unbind("mousedown").css("cursor","default"),A=!0)},m.SetMinBtn=function(b){x.minBtn&&x.titleBar&&a.isFunction(b)&&a(B).unbind("click").bind("click",b)},m.addBtn=function(b,d,e,f){f=f||"left";if(x.btnBar)if(a("#lhgdg_"+x.id+"_"+b,c)[0])a("#lhgdg_"+x.id+"_"+b,c).html("<em>"+d+"</em>").unbind("click").bind("click",e);else{var g='<a id="lhgdg_'+x.id+"_"+b+'" class="lhgdg_button" href="javascript:void(0);" target="_self"><em>'+d+"</em></a>",h=a(g,c).bind("click",e)[0];f==="left"?a(".lhgdg_btn_div",u).prepend(h):a(".lhgdg_btn_div",u).append(h)}},m.removeBtn=function(b){a("#lhgdg_"+x.id+"_"+b,c)[0]&&a("#lhgdg_"+x.id+"_"+b,c).remove()},m.SetIndex=function(){m.dg.style.zIndex=parseInt(e,10)+1,e=parseInt(m.dg.style.zIndex,10)},m.SetXbtn=function(b,c){x.xButton&&x.titleBar&&(a.isFunction(b)&&a(q).unbind("click").bind("click",b),c?q.style.display="none":q.style.display="")},m.SetTitle=function(b){x.titleBar&&typeof b=="string"&&a(".lhgdg_title",m.dg).html(b)},m.cancel=function(){O();if(d)if(x.parent&&x.parent.opt.cover){var a=x.parent.dg.style.zIndex;d.style.zIndex=parseInt(a,10)-1}else d.style.display="none"},m.cleanDialog=function(){m.dg&&O(),d&&(a(d).remove(),d=null)},m.closeTime=function(b,c){w&&clearTimeout(w),a.isFunction(c)&&c.call(m),b&&(w=setTimeout(function(){m.cancel(),clearTimeout(w)},1e3*b))},m.SetPosition=function(a,b){F(m.dg,b,a,x.fixed)},m.iWin=function(b){if(a("#lhgfrm_"+b,c)[0])return a("#lhgfrm_"+b,c)[0].contentWindow;return null},m.iDoc=function(b){if(a("#lhgfrm_"+b,c)[0])return a("#lhgfrm_"+b,c)[0].contentWindow.document;return null},m.iDG=function(a){return c.getElementById("lhgdlg_"+a)||null},m.SetCancelBtn=function(b,d){d=d||m.cancel,a("#lhgdg_"+x.id+"_dgcancelBtn",c)[0]&&a("#lhgdg_"+x.id+"_dgcancelBtn",c).html("<em>"+b+"</em>").unbind("click").bind("click",d)},a(window).bind("unload",m.cleanDialog)},a(function(){var b=setTimeout(function(){(new a.dialog({id:"reLoadId",html:"lhgdialog",width:100,title:"reLoad",height:100,left:-9e3,btnBar:!1})).ShowDialog(),clearTimeout(b)},150)})})(window.lhgcore||window.jQuery);
