﻿(function(a){if(!a.lhgren){a.browser.ie=a.browser.msie?true:false;a.browser.i7=a.browser.msie&&a.browser.version>=7?true:false}var i=window,j,t,u,A=false,B=function(){return a.browser.ie?a.browser.i7?"":"javascript:''":"javascript:void(0);"},C=a.browser.ie&&!a.browser.i7?'<iframe hideFocus="true" frameborder="0" src="'+B()+'" style="position:absolute;z-index:-1;width:100%;height:100%;top:0px;left:0px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)"></iframe>':"",w=function(e){e=e||document;return e.compatMode==="CSS1Compat"?e.documentElement:e.body},x=function(){if("pageXOffset"in i)return{x:i.pageXOffset||0,y:i.pageYOffset||0};else{var e=w(j);return{x:e.scrollLeft||0,y:e.scrollTop||0}}},y=function(){var e=w(j);return{w:e.clientWidth||0,h:e.clientHeight||0}},z=function(){u||(u=999);return++u},D=function(){var e=w(j);a(t).css({width:Math.max(e.scrollWidth,e.clientWidth||0)-1+"px",height:Math.max(e.scrollHeight,e.clientHeight||0)-1+"px"})},E=function(){for(var e=a("script"),r="",b=0,d=e.length;b<d;b++)if(e[b].src.indexOf("dialog")>=0){r=document.querySelector?e[b].src:e[b].getAttribute("src",4);break}return r.substr(0,r.lastIndexOf("/")+1)};for(;i.parent&&i.parent!=i;){try{if(i.parent.document.domain!=document.domain)break}catch(H){break}i=i.parent}if(i.document.getElementsByTagName("frameset").length>0)i=window;j=i.document;a.fn.fixie6png=function(){for(var e=a("*",this),r,b=0,d=e.length;b<d;b++){r=a(e[b]).css("backgroundImage");if(r.indexOf(".png")!==-1){r=r.replace(/url\(|"|\)/g,"");e[b].style.backgroundImage="none";e[b].runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+r+"',sizingMethod='scale')"}}};a.fn.dialog=function(e){var r=false;if(this[0])r=new a.dialog(e,this[0]);return r};a.dialog=function(e,r){var b=this,d=this.opt=a.extend({title:"dialog",width:400,height:300,id:"lhgdlgId",SetTopWindow:false,btns:true,link:false,page:"",event:"click",fixed:false,top:"center",left:"center",drag:true,resize:true,loadingText:""},e||{});if(d.SetTopWindow){i=d.SetTopWindow;j=i.document}if(!A){try{j.execCommand("BackgroundImageCache",false,true)}catch(I){}a("head",j).append('<link href="'+E()+'dialog.css" rel="stylesheet" type="text/css"/>');A=true}this.SetIFramePage=function(){var c;if(d.html)c=typeof d.html==="string"?'<div id="lhgdig_inbox" class="lhgdig_inbox" style="display:none">'+d.html+"</div>":'<div id="lhgdig_inbox" class="lhgdig_inbox" style="display:none"></div>';else if(d.page)c=['<iframe frameborder="0" src="',d.page,'" scrolling="auto" id="lhgfrm" style="display:none;width:100%;height:100%;"></iframe>'].join("");return['<div id="',d.id,'" class="lhgdig" style="width:',d.width,"px;height:",d.height,'px;"><table border="0" cellspacing="0" cellpadding="0"><tr><td class="lhgdig_leftTop"></td><td id="lhgdig_drag" class="lhgdig_top"><div class="lhgdig_title"><span id="lhgdig_icon" class="lhgdig_icon"></span>',d.title,'</div><div id="lhgdig_xbtn" class="lhgdig_xbtn"></div></td><td class="lhgdig_rightTop"></td></tr><tr><td class="lhgdig_left" id="lhgdigLeft"></td><td><table border="0" cellspacing="0" cellpadding="0"><tr><td id="lhgdig_content" class="lhgdig_content">',c,'<div id="throbber" class="lhgdig_throbber"><span id="lhgdig_load">',d.loadingText,"</span></div></td></tr>",d.btns?'<tr><td id="lhgdig_btns" class="lhgdig_btns"><div id="lhgdig_bDiv" class="lhgdig_bDiv"></div></td></tr>':"",'</table></td><td class="lhgdig_right"></td></tr><tr><td class="lhgdig_leftBottom"></td><td class="lhgdig_bottom"></td><td id="lhgdig_drop" class="lhgdig_rightBottom"></td></tr></table>',C,"</div>"].join("")};this.ShowDialog=function(){if(!a("#"+d.id,j)[0]){d.cover&&this.ShowCover();var c=d.fixed&&(!a.browser.ie||a.browser.i7)?"fixed":"absolute",g=this.SetIFramePage();this.dg=a(g,j).css({position:c,zIndex:z()}).appendTo(j.body)[0];this.iPos(this.dg,d.top,d.left,d.fixed);this.SetDialog(this.dg);d.drag&&this.initDrag(a("#lhgdig_drag",this.dg)[0]);d.resize&&this.initSize(a("#lhgdig_drop",this.dg)[0]);if(a.browser.ie&&!a.browser.i7)(a("html",j).css("ie6PngRepair")==="true"?true:false)&&a(this.dg).fixie6png();this.lhgDigxW=a("#lhgdigLeft",this.dg)[0].offsetWidth*2;this.reContentSize(this.dg);d.html&&d.cusfn&&d.cusfn();if(d.html){a("#throbber",this.dg).css("display","none");a("#lhgdig_inbox",this.dg)[0].style.display="inline-block"}}};this.ShowCover=function(){if(!t){var c=['<div style="position:absolute;top:0px;left:0px;background-color:#fff;">',C,"</div>"].join("");t=a(c,j).css("opacity",0.5).appendTo(j.body)[0]}a(i).bind("resize",D);D();a(t).css({display:"",zIndex:z()})};this.iPos=function(c,g,k,l){var p=y(i),q=x(i),h=c.offsetWidth,n=c.offsetHeight;if(l){if(a.browser.ie&&!a.browser.i7){a("html",j).addClass("lhgdig_ie6_fixed");a('<div class="lhgdig_warp"></div>',j).appendTo(j.body).append(c).css("zIndex",z())}lx=0;rx=p.w-h;cx=(rx-20)/2;ty=0;by=p.h-n;cy=(by-20)/2}else{lx=q.x;cx=q.x+(p.w-h-20)/2;rx=q.x+p.w-h;ty=q.y;cy=q.y+(p.h-n-20)/2;by=q.y+p.h-n}switch(k){case"center":k=cx;break;case"left":k=lx;break;case"right":k=rx;break;default:if(l)k-=q.x;k=k}switch(g){case"center":g=cy;break;case"top":g=ty;break;case"bottom":g=by;break;default:if(l)g-=q.y;g=g}a(c).css({top:g+"px",left:k+"px"})};this.SetDialog=function(c){this.topWin=i;this.topDoc=j;this.curWin=window;this.curDoc=document;a(c).bind("contextmenu",function(g){g.preventDefault()}).bind("mousedown",b.SetIndex);d.html&&d.html.nodeType&&a("#lhgdig_inbox",c).append(d.html);this.regWindow=[window];i!=window&&this.regWindow.push(i);if(d.page.length>0){this.dgFrm=a("#lhgfrm",c)[0];if(!d.link){this.dgWin=this.dgFrm.contentWindow;this.dgFrm.lhgDG=this}a(this.dgFrm).bind("load",function(){if(!b.opt.link){a(a.browser.ie?this.contentWindow.document:this.contentWindow).bind("mousedown",b.SetIndex);b.regWindow.push(this.contentWindow);b.dgDoc=this.contentWindow.document}this.style.display="block";a("#throbber",b.dg)[0].style.display="none"})}a("#lhgdig_xbtn",c).hover(function(){a(this).addClass("lhgdig_xbtnover")},function(){a(this).removeClass("lhgdig_xbtnover")}).click(b.cancel)};this.reContentSize=function(c){var g=a("#lhgdig_drag",c)[0].offsetHeight,k=a("#lhgdig_drop",c)[0].offsetHeight,l=this.lhgDigxW,p=d.btns?a("#lhgdig_btns",c)[0].offsetHeight:0;l=parseInt(c.style.width,10)-l;g=parseInt(c.style.height,10)-g-k-p;a("#lhgdig_content",c).css({width:l+"px",height:g+"px"});d.html&&a("#lhgdig_inbox",c).css({width:l+"px",height:g+"px"});this.SetLoadLeft()};this.SetLoadLeft=function(){var c=(a("#lhgdig_content",this.dg)[0].offsetWidth-a("#lhgdig_load",this.dg)[0].offsetWidth)/2;a("#lhgdig_load",this.dg)[0].style.left=c+"px"};this.reDialogSize=function(c,g){a(this.dg).css({width:c+"px",height:g+"px"});this.reContentSize(this.dg)};this.SetIndex=function(c){if(b.opt.fixed&&a.browser.ie&&!a.browser.i7){a(b.dg).parent()[0].style.zIndex=parseInt(u,10)+1;u=parseInt(a(b.dg).parent()[0].style.zIndex,10)}else{b.dg.style.zIndex=parseInt(u,10)+1;u=parseInt(b.dg.style.zIndex,10)}c.stopPropagation()};this.initDrag=function(c){function g(f){f={x:f.screenX,y:f.screenY};h={x:h.x+(f.x-l.x),y:h.y+(f.y-l.y)};l=f;if(d.rang){if(h.x<o.x)h.x=o.x;if(h.y<o.y)h.y=o.y;if(h.x>p)h.x=p;if(h.y>q)h.y=q}b.dg.style.top=b.opt.fixed?h.y-o.y+"px":h.y+"px";b.dg.style.left=b.opt.fixed?h.x-o.x+"px":h.x+"px"}function k(){for(var f=0,m=n.length;f<m;f++){a(n[f].document).unbind("mousemove",g);a(n[f].document).unbind("mouseup",k)}c=l=null;a.browser.ie&&b.dg.releaseCapture()}var l,p,q,h,n=this.regWindow,s,o;a(c).bind("mousedown",function(f){if(f.target.id!=="lhgdig_xbtn"){s=y(i);o=x(i);var m=b.dg.offsetLeft,v=b.dg.offsetTop,F=b.dg.clientWidth,G=b.dg.clientHeight;h=b.opt.fixed?{x:m+o.x,y:v+o.y}:{x:m,y:v};l={x:f.screenX,y:f.screenY};p=s.w+o.x-F;q=s.h+o.y-G;b.dg.style.zIndex=parseInt(u,10)+1;m=0;for(v=n.length;m<v;m++){a(n[m].document).bind("mousemove",g);a(n[m].document).bind("mouseup",k)}f.preventDefault();a.browser.ie&&b.dg.setCapture()}})};this.initSize=function(c){function g(f){f={x:f.screenX,y:f.screenY};s={w:f.x-l.x,h:f.y-l.y};if(s.w<200)s.w=200;if(s.h<100)s.h=100;b.dg.style.top=b.opt.fixed?h.y-o.y+"px":h.y+"px";b.dg.style.left=b.opt.fixed?h.x-o.x+"px":h.x+"px";b.reDialogSize(s.w,s.h)}function k(){for(var f=0,m=n.length;f<m;f++){a(n[f].document).unbind("mousemove",g);a(n[f].document).unbind("mouseup",k)}c=l=null;a.browser.ie&&b.releaseCapture()}var l,p,q,h,n=this.regWindow,s,o;a(c).bind("mousedown",function(f){q=b.dg.clientWidth;p=b.dg.clientHeight;s={w:q,h:p};y(i);o=x(i);var m=b.dg.offsetLeft,v=b.dg.offsetTop;h=b.opt.fixed?{x:m+o.x,y:v+o.y}:{x:m,y:v};l={x:f.screenX-q,y:f.screenY-p};b.dg.style.zIndex=parseInt(u,10)+1;m=0;for(v=n.length;m<v;m++){a(n[m].document).bind("mousemove",g);a(n[m].document).bind("mouseup",k)}f.preventDefault();a.browser.ie&&b.dg.setCapture()})};this.addBtn=function(c,g,k){if(a("#"+c,this.dg)[0])a("#"+c,this.dg).html("<em>"+g+"</em>").click(k);else{c=a('<a id="'+c+'" class="lhgdig_button" href="javascript:void(0)" hidefocus="true"><em>'+g+"</em></a>",j).click(k)[0];a("#lhgdig_bDiv",this.dg).append(c)}};this.removeBtn=function(c){a("#"+c,this.dg)[0]&&a("#"+c,this.dg).remove()};this.cancel=function(){b.removeDG();if(t)if(b.opt.parent&&b.opt.parent.opt.cover)t.style.zIndex=parseInt(b.opt.parent.dg.style.zIndex,10)-1;else t.style.display="none"};this.removeDG=function(){var c=a("#lhgfrm",b.dg)[0];if(c){b.opt.link||a(c.contentWindow).unbind("load");c.src=B()}b.regWindow=[];if(b.opt.fixed&&a.browser.ie&&!a.browser.i7){a("html",j).removeClass("lhgdig_ie6_fixed");a(b.dg).parent().remove()}else a(b.dg).remove();b.dg=null};this.cleanDialog=function(){b.dg&&b.removeDG();if(t){a(t).remove();t=null}};a(window).bind("unload",this.cleanDialog);r&&a(r).bind(d.event,function(){b.ShowDialog()})};a(function(){var e=setTimeout(function(){(new a.dialog({id:"reLoadId",html:"dialog",width:100,title:"reLoad",height:100,left:-9E3})).ShowDialog();clearTimeout(e)},150)})})(core);
