﻿/*!
 * lhgcore Dialog Plugin v3.4.0
 * Date : 2011-05-06 10:35:11
 * Copyright (c) 2009 - 2011 By Li Hui Gang
 */
(function(a){var b=window,c,e,f,g=a.browser.msie&&a.browser.version<7?!0:!1,h=g?'<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>':"",i=function(a){d=a||document;return d.compatMode=="CSS1Compat"?d.documentElement:d.body},j=function(){f||(f=1976);return++f},k=function(){if("pageXOffset"in b)return{x:b.pageXOffset||0,y:b.pageYOffset||0};var a=i(c);return{x:a.scrollLeft||0,y:a.scrollTop||0}},l=function(){var a=i(c);return{w:a.clientWidth||0,h:a.clientHeight||0}},m=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("?")}(),n=m[0].substr(0,m[0].lastIndexOf("/")+1),o=function(a){if(m[1]){var b=m[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},p=o("s")||"default",q=function(){var b=i(c);a(e).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(r){break}b=b.parent}if(o("t")==="self"||b.document.getElementsByTagName("frameset").length>0)b=window;c=b.document;try{c.execCommand("BackgroundImageCache",!1,!0)}catch(r){}a("head",c).append('<link href="'+n+"skins/"+p+'.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=n+"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(d){var m=this,n,o,p,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,fixed:!1,top:"center",left:"center",drag:!0,resize:!0,autoSize:!1,rang:!1,timer:null,iconTitle:!0,loadingText:"\u7A97\u53E3\u5185\u5BB9\u52A0\u8F7D\u4E2D\uFF0C\u8BF7\u7A0D\u7B49..."},d||{}),y,z={},A=!1,B=function(a){var b=a.style,d=i(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)},C=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="',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);"></a>':"")+(x.maxBtn?'<a class="lhgdg_maxbtn" id="lhgdg_maxbtn_'+x.id+'" href="javascript:void(0);"></a>':"")+(x.xButton?'<a class="lhgdg_xbtn" id="lhgdg_xbtn_'+x.id+'" href="javascript:void(0);"></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>",h,"</div>"].join("");return b},D=function(){e=a("#lhgdgCover",c)[0];if(!e){var d='<div id="lhgdgCover" style="position:absolute;top:0px;left:0px;background-color:#fff;">'+h+"</div>";e=a(d,c).css("opacity",.5).appendTo(c.body)[0]}a(b).bind("resize",q),q(),a(e).css({display:"",zIndex:j()})},E=function(b,c,d,e){var f=l(),h=k(),i=b.offsetWidth,j=b.offsetHeight,m,n,o,p,q,r,s,t;e?(o=g?h.x:0,p=g?f.w+h.x-i:f.w-i,q=g?(p+h.x-20)/2:(p-20)/2,r=g?h.y:0,s=g?f.h+h.y-j:f.h-j,t=g?(s+h.y-20)/2:(s-20)/2):(o=h.x,q=h.x+(f.w-i-20)/2,p=h.x+f.w-i,r=h.y,t=h.y+(f.h-j-20)/2,s=h.y+f.h-j);switch(d){case"center":m=q;break;case"left":m=o;break;case"right":m=p;break;default:e&&g&&(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&&g&&(c=c+h.y),n=c}a(b).css({top:n+"px",left:m+"px"}),e&&g&&B(b)},F=function(d){m.topWin=b,m.topDoc=c,m.curWin=window,m.curDoc=document,a(d).bind("contextmenu",function(a){a.preventDefault()}).bind("mousedown",m.SetIndex),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.SetIndex),v.push(m.dgWin),m.dgDoc=m.dgWin.document,x.autoSize&&H(),a.isFunction(x.dgOnLoad)&&x.dgOnLoad.call(m)}n.style.display="none"})),x.xButton&&x.titleBar&&a(p).bind("click",x.onXclick||m.cancel),x.maxBtn&&x.titleBar&&a(y).bind("click",I)},G=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"},H=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=i(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),E(m.dg,"center","center",x.fixed)},I=function(){var b,c;b=l(),c=k(),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)},K=function(b){function p(d){for(var e=0,f=i.length;e<f;e++)a(i[e].document).unbind("mousemove",o),a(i[e].document).unbind("mouseup",p);c=null,b=null,x.fixed&&g&&B(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>e&&(h.y=e)),m.dg.style.top=x.fixed&&!g?h.y-n.y+"px":h.y+"px",m.dg.style.left=x.fixed&&!g?h.x-n.x+"px":h.x+"px"}var c,d,e,h,i=v,j,n;a(b).bind("mousedown",function(b){if(b.target.id!=="lhgdg_xbtn_"+m.opt.id){j=l(),n=k();var q=m.dg.offsetLeft,r=m.dg.offsetTop,s=m.dg.clientWidth,t=m.dg.clientHeight;h=x.fixed&&!g?{x:q+n.x,y:r+n.y}:{x:q,y:r},c={x:b.screenX,y:b.screenY},d=j.w+n.x-s,e=j.h+n.y-t,m.dg.style.zIndex=parseInt(f,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,e,g,h=v,i,j,n;a(b).bind("mousedown",function(b){e=m.dg.clientWidth,d=m.dg.clientHeight,i={w:e,h:d},j=l(),n=k();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-e,y:b.screenY-d},m.dg.style.zIndex=parseInt(f,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(){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"),v=[],a(m.dg).remove(),m.dg=null,A=!1,z={},n=o=p=r=s=u=t=y=null};m.ShowDialog=function(){if(a("#"+x.id,c)[0])return m;x.cover&&D(),x.fixed&&(x.maxBtn=!1);var b=x.fixed&&!g?"fixed":"absolute",d=C();m.dg=a(d,c).css({position:b,zIndex:j()}).appendTo(c.body)[0],n=a("#lhgdg_load_"+x.id,c)[0],o=a("#lhgdg_inbox_"+x.id,c)[0],p=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],G(m.dg),E(m.dg,x.top,x.left,x.fixed),F(m.dg),x.drag?K(r):r.style.cursor="default",x.resize?L(s):s.style.cursor="default",g&&a(s).css("ie6png")&&a(m.dg).fixie6png(),x.html&&a.isFunction(x.dgOnLoad)&&x.dgOnLoad.call(m),x.html&&(n.style.display="none",o.style.display="",x.autoSize&&H()),x.timer&&m.closeTime(x.timer),x.btnBar&&x.cancelBtn&&m.addBtn("dgcancelBtn","\u53D6\u6D88",x.onCancel||m.cancel)},m.reDialogSize=function(b,c){a(m.dg).css({width:b+"px",height:c+"px"}),G(m.dg)},m.addBtn=function(b,d,e){if(x.btnBar)if(a("#lhgdg_"+x.id+"_"+b,c)[0])a("#lhgdg_"+x.id+"_"+b,c).html("<em>"+d+"</em>").click(e);else{var f='<a id="lhgdg_'+x.id+"_"+b+'" class="lhgdg_button" href="javascript:void(0);"><em>'+d+"</em></a>",g=a(f,c).bind("click",e)[0];a(".lhgdg_btn_div",u).prepend(g)}},m.removeBtn=function(b){a("#lhgdg_"+x.id+"_"+b,c)[0]&&a("#lhgdg_"+x.id+"_"+b,c).remove()},m.SetIndex=function(a){m.dg.style.zIndex=parseInt(f,10)+1,f=parseInt(m.dg.style.zIndex,10),a.stopPropagation()},m.SetXbtn=function(b,c){x.xButton&&x.titleBar&&(a.isFunction(b)&&a(p).unbind("click").bind("click",b),c?p.style.display="none":p.style.display="")},m.SetTitle=function(b){x.titleBar&&typeof b=="string"&&a(".lhgdg_title",c).html(b)},m.cancel=function(){M();if(e)if(x.parent&&x.parent.opt.cover){var a=x.parent.dg.style.zIndex;e.style.zIndex=parseInt(a,10)-1}else e.style.display="none"},m.cleanDialog=function(){m.dg&&M(),e&&(a(e).remove(),e=null)},m.closeTime=function(a){w&&clearTimeout(w),a&&(w=setTimeout(function(){m.cancel(),clearTimeout(w)},1e3*a))},m.SetPosition=function(a,b,c){E(m.dg,a,b,c)},x.onCancel=x.onCancel||m.cancel,x.onXclick=x.onXclick||m.cancel,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)})})(lhgcore);
