﻿/*!
 * lhgcore Dialog Plugin v3.2.4
 * Date : 2011-03-02 08:21:11
 * Copyright (c) 2009 - 2011 By Li Hui Gang
 */
(function(b){var i=window,j,t,u,B=false,w=b.browser.msie&&b.browser.version<7?true:false,C=function(){return b.browser.msie?w?"":"javascript:''":"javascript:void(0);"},D=w?'<iframe hideFocus="true" frameborder="0" src="'+C()+'" style="position:absolute;z-index:-1;width:100%;height:100%;top:0px;left:0px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)"></iframe>':"",x=function(e){e=e||document;return e.compatMode==="CSS1Compat"?e.documentElement:e.body},y=function(){if("pageXOffset"in i)return{x:i.pageXOffset||0,y:i.pageYOffset||0};else{var e=x(j);return{x:e.scrollLeft||0,y:e.scrollTop||0}}},z=function(){var e=x(j);return{w:e.clientWidth||0,h:e.clientHeight||0}},A=function(){u||(u=999);return++u},E=function(){var e=x(j);b(t).css({width:Math.max(e.scrollWidth,e.clientWidth||0)-1+"px",height:Math.max(e.scrollHeight,e.clientHeight||0)-1+"px"})},F=function(){for(var e=b("script"),r="",a=0,d=e.length;a<d;a++)if(e[a].src.indexOf("lhgdialog")>=0){r=document.querySelector?e[a].src:e[a].getAttribute("src",4);break}return r.substr(0,r.lastIndexOf("/")+1)};for(;i.parent&&i.parent!=i;){try{if(i.parent.ignore!=ignore)break}catch(I){break}i=i.parent}if(i.document.getElementsByTagName("frameset").length>0)i=window;j=i.document;b.fn.fixie6png=function(){for(var e=b("*",this),r,a=0,d=e.length;a<d;a++){r=b(e[a]).css("backgroundImage");if(r.indexOf(".png")!==-1){r=r.replace(/url\(|"|\)/g,"");e[a].style.backgroundImage="none";e[a].runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+r+"',sizingMethod='scale')"}}};b.fn.dialog=function(e){var r=false;if(this[0])r=new b.dialog(e,this[0]);return r};b.dialog=function(e,r){var a=this,d=a.opt=b.extend({title:"lhgdialog \u5f39\u51fa\u7a97\u53e3",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:"\u7a97\u53e3\u5185\u5bb9\u52a0\u8f7d\u4e2d\uff0c\u8bf7\u7a0d\u7b49..."},e||{});if(d.SetTopWindow){i=d.SetTopWindow;j=i.document}if(!B){try{j.execCommand("BackgroundImageCache",false,true)}catch(J){}b("head",j).append('<link href="'+F()+'lhgdialog.css" rel="stylesheet" type="text/css"/>');B=true}a.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>',D,"</div>"].join("")};a.ShowDialog=function(){if(!b("#"+d.id,j)[0]){d.cover&&a.ShowCover();var c=d.fixed&&!w?"fixed":"absolute",g=a.SetIFramePage();a.dg=b(g,j).css({position:c,zIndex:A()}).appendTo(j.body)[0];a.iPos(a.dg,d.top,d.left,d.fixed);a.SetDialog(a.dg);d.drag&&a.initDrag(b("#lhgdig_drag",a.dg)[0]);d.resize&&a.initSize(b("#lhgdig_drop",a.dg)[0]);if(w)(b("html",j).css("ie6PngRepair")==="true"?true:false)&&b(a.dg).fixie6png();a.lhgDigxW=b("#lhgdigLeft",a.dg)[0].offsetWidth*2;a.reContentSize(a.dg);d.html&&d.cusfn&&d.cusfn.call(this);if(d.html){b("#throbber",a.dg).css("display","none");b("#lhgdig_inbox",a.dg)[0].style.display="inline-block"}}};a.ShowCover=function(){t=b("#lhgdgCover",j)[0];if(!t){var c=['<div id="lhgdgCover" style="position:absolute;top:0px;left:0px;background-color:#fff;">',D,"</div>"].join("");t=b(c,j).css("opacity",0.5).appendTo(j.body)[0]}b(i).bind("resize",E);E();b(t).css({display:"",zIndex:A()})};a.iPos=function(c,g,k,l){var p=z(i),q=y(i),h=c.offsetWidth,n=c.offsetHeight;if(l){if(w){b("html",j).addClass("lhgdig_ie6_fixed");b('<div class="lhgdig_warp"></div>',j).appendTo(j.body).append(c).css("zIndex",A())}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}b(c).css({top:g+"px",left:k+"px"})};a.SetDialog=function(c){a.topWin=i;a.topDoc=j;a.curWin=window;a.curDoc=document;b(c).bind("contextmenu",function(g){g.preventDefault()}).bind("mousedown",a.SetIndex);d.html&&d.html.nodeType&&b("#lhgdig_inbox",c).append(d.html);a.regWindow=[window];i!=window&&a.regWindow.push(i);if(d.page.length>0){a.dgFrm=b("#lhgfrm",c)[0];if(!d.link){a.dgWin=a.dgFrm.contentWindow;a.dgFrm.lhgDG=a}b(a.dgFrm).bind("load",function(){if(!a.opt.link){b(b.browser.msie?a.dgWin.document:a.dgWin).bind("mousedown",a.SetIndex);a.regWindow.push(a.dgWin);a.dgDoc=a.dgWin.document}this.style.display="block";b("#throbber",a.dg)[0].style.display="none"})}b("#lhgdig_xbtn",c).hover(function(){b(this).addClass("lhgdig_xbtnover")},function(){b(this).removeClass("lhgdig_xbtnover")}).bind("click",a.cancel)};a.reContentSize=function(c){var g=b("#lhgdig_drag",c)[0].offsetHeight,k=b("#lhgdig_drop",c)[0].offsetHeight,l=a.lhgDigxW,p=d.btns?b("#lhgdig_btns",c)[0].offsetHeight:0;l=parseInt(c.style.width,10)-l;g=parseInt(c.style.height,10)-g-k-p;b("#lhgdig_content",c).css({width:l+"px",height:g+"px"});d.html&&b("#lhgdig_inbox",c).css({width:l+"px",height:g+"px"});a.SetLoadLeft()};a.SetLoadLeft=function(){var c=(b("#lhgdig_content",a.dg)[0].offsetWidth-b("#lhgdig_load",a.dg)[0].offsetWidth)/2;b("#lhgdig_load",a.dg)[0].style.left=c+"px"};a.reDialogSize=function(c,g){b(a.dg).css({width:c+"px",height:g+"px"});a.reContentSize(a.dg)};a.SetIndex=function(c){if(a.opt.fixed&&w){b(a.dg).parent()[0].style.zIndex=parseInt(u,10)+1;u=parseInt(b(a.dg).parent()[0].style.zIndex,10)}else{a.dg.style.zIndex=parseInt(u,10)+1;u=parseInt(a.dg.style.zIndex,10)}c.stopPropagation()};a.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}a.dg.style.top=a.opt.fixed?h.y-o.y+"px":h.y+"px";a.dg.style.left=a.opt.fixed?h.x-o.x+"px":h.x+"px"}function k(){for(var f=0,m=n.length;f<m;f++){b(n[f].document).unbind("mousemove",g);b(n[f].document).unbind("mouseup",k)}c=l=null;b.browser.msie&&a.dg.releaseCapture()}var l,p,q,h,n=a.regWindow,s,o;b(c).bind("mousedown",function(f){if(f.target.id!=="lhgdig_xbtn"){s=z(i);o=y(i);var m=a.dg.offsetLeft,v=a.dg.offsetTop,G=a.dg.clientWidth,H=a.dg.clientHeight;h=a.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-G;q=s.h+o.y-H;a.dg.style.zIndex=parseInt(u,10)+1;m=0;for(v=n.length;m<v;m++){b(n[m].document).bind("mousemove",g);b(n[m].document).bind("mouseup",k)}f.preventDefault();b.browser.msie&&a.dg.setCapture()}})};a.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;a.dg.style.top=a.opt.fixed?h.y-o.y+"px":h.y+"px";a.dg.style.left=a.opt.fixed?h.x-o.x+"px":h.x+"px";a.reDialogSize(s.w,s.h)}function k(){for(var f=0,m=n.length;f<m;f++){b(n[f].document).unbind("mousemove",g);b(n[f].document).unbind("mouseup",k)}c=l=null;b.browser.msie&&a.dg.releaseCapture()}var l,p,q,h,n=a.regWindow,s,o;b(c).bind("mousedown",function(f){q=a.dg.clientWidth;p=a.dg.clientHeight;s={w:q,h:p};z(i);o=y(i);var m=a.dg.offsetLeft,v=a.dg.offsetTop;h=a.opt.fixed?{x:m+o.x,y:v+o.y}:{x:m,y:v};l={x:f.screenX-q,y:f.screenY-p};a.dg.style.zIndex=parseInt(u,10)+1;m=0;for(v=n.length;m<v;m++){b(n[m].document).bind("mousemove",g);b(n[m].document).bind("mouseup",k)}f.preventDefault();b.browser.msie&&a.dg.setCapture()})};a.addBtn=function(c,g,k){if(b("#"+c,a.dg)[0])b("#"+c,a.dg).html("<em>"+g+"</em>").click(k);else{c=b('<a id="'+c+'" class="lhgdig_button" href="'+(w?"###":"javascript:void(0)")+'" hidefocus="true"><em>'+g+"</em></a>",j).bind("click",k)[0];b("#lhgdig_bDiv",a.dg).append(c)}};a.removeBtn=function(c){b("#"+c,a.dg)[0]&&b("#"+c,a.dg).remove()};a.cancel=function(){a.removeDG();if(t)if(a.opt.parent&&a.opt.parent.opt.cover)t.style.zIndex=parseInt(a.opt.parent.dg.style.zIndex,10)-1;else t.style.display="none"};a.removeDG=function(){if(a.dgFrm){a.opt.link||b(a.dgDoc).unbind("load");a.dgFrm.src=b.browser.mozilla?"about:blank":C();a.dgFrm=null}a.regWindow=[];if(a.opt.fixed&&w){b("html",j).removeClass("lhgdig_ie6_fixed");b(a.dg).parent().remove()}else b(a.dg).remove();a.dg=null};a.cleanDialog=function(){a.dg&&a.removeDG();if(t){b(t).remove();t=null}};b(window).bind("unload",a.cleanDialog);r&&b(r).bind(d.event,a.ShowDialog)};b(function(){var e=setTimeout(function(){(new b.dialog({id:"reLoadId",html:"lhgdialog",width:100,title:"reLoad",height:100,left:-9E3})).ShowDialog();clearTimeout(e)},150)})})(lhgcore);
