!function(e){e.fn.closeDOMWindow=function(o){o||(o={});var n=function(n){if(o.anchoredClassName){var i=e("."+o.anchoredClassName);i.fadeOut("fast",function(){e.fn.draggable?i.draggable("destory").trigger("unload").remove():i.trigger("unload").remove()}),o.functionCallOnClose&&o.functionCallAfterClose()}else{var t=e("#DOMWindowOverlay"),d=e("#DOMWindow");t.fadeOut("fast",function(){t.trigger("unload").unbind().remove()}),d.fadeOut("fast",function(){e.fn.draggable?d.draggable("destroy").trigger("unload").remove():d.trigger("unload").remove()}),e(window).unbind("scroll.DOMWindow"),e(window).unbind("resize.DOMWindow"),e.fn.openDOMWindow.isIE6&&e("#DOMWindowIE6FixIframe").remove(),o.functionCallOnClose&&o.functionCallAfterClose()}};return o.eventType?this.each(function(i){e(this).bind(o.eventType,function(){return n(this),!1})}):void n()},e.closeDOMWindow=function(o){e.fn.closeDOMWindow(o)},e.fn.openDOMWindow=function(o){var n=e.fn.openDOMWindow;n.defaultsSettings={anchoredClassName:"",anchoredSelector:"",borderColor:"#ccc",borderSize:"4",draggable:0,eventType:null,fixedWindowY:100,functionCallOnOpen:null,functionCallOnClose:null,height:500,loader:0,loaderHeight:0,loaderImagePath:"",loaderWidth:0,modal:0,overlay:1,overlayColor:"#000",overlayOpacity:"85",positionLeft:0,positionTop:0,positionType:"centered",width:500,windowBGColor:"#fff",windowBGImage:null,windowHTTPType:"get",windowPadding:10,windowSource:"inline",windowSourceID:"",windowSourceURL:"",windowSourceAttrURL:"href"};var i=e.extend({},e.fn.openDOMWindow.defaultsSettings,o||{});n.viewPortHeight=function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},n.viewPortWidth=function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},n.scrollOffsetHeight=function(){return self.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop},n.scrollOffsetWidth=function(){return self.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft},n.isIE6="undefined"==typeof document.body.style.maxHeight;var t=function(){var o=e("#DOMWindowOverlay");if(n.isIE6){var i=document.documentElement.offsetHeight+document.documentElement.scrollTop-4,t=document.documentElement.offsetWidth-21;o.css({height:i+"px",width:t+"px"})}else o.css({height:"100%",width:"100%",position:"fixed"})},d=function(){var o=document.documentElement.offsetHeight+document.documentElement.scrollTop-4,n=document.documentElement.offsetWidth-21;e("#DOMWindowIE6FixIframe").css({height:o+"px",width:n+"px"})},r=function(){var o=e("#DOMWindow");i.height+50>n.viewPortHeight()?o.css("left",Math.round(n.viewPortWidth()/2)+n.scrollOffsetWidth()-Math.round(o.outerWidth()/2)):(o.css("left",Math.round(n.viewPortWidth()/2)+n.scrollOffsetWidth()-Math.round(o.outerWidth()/2)),o.css("top",Math.round(n.viewPortHeight()/2)+n.scrollOffsetHeight()-Math.round(o.outerHeight()/2)))},a=function(){var o=e("#DOMWindowLoader");n.isIE6?(o.css({left:Math.round(n.viewPortWidth()/2)+n.scrollOffsetWidth()-Math.round(o.innerWidth()/2),position:"absolute"}),o.css({top:Math.round(n.viewPortHeight()/2)+n.scrollOffsetHeight()-Math.round(o.innerHeight()/2),position:"absolute"})):o.css({left:"50%",top:"50%",position:"fixed"})},l=function(){var o=e("#DOMWindow");o.css("left",i.positionLeft+n.scrollOffsetWidth()),o.css("top",+i.positionTop+n.scrollOffsetHeight())},c=function(o){arguments[0]?(e("."+o+" #DOMWindowLoader").remove(),e("."+o+" #DOMWindowContent").fadeIn("fast",function(){i.functionCallOnOpen&&i.functionCallOnOpen()}),e("."+o+".closeDOMWindow").click(function(){return e.closeDOMWindow(),!1})):(e("#DOMWindowLoader").remove(),e("#DOMWindow").fadeIn("fast",function(){i.functionCallOnOpen&&i.functionCallOnOpen()}),e("#DOMWindow .closeDOMWindow").click(function(){return e.closeDOMWindow(),!1}))},s=function(e){var o={};return e.replace(/b([^&=]*)=([^&=]*)b/g,function(e,n,i){"undefined"!=typeof o[n]?o[n]+=","+i:o[n]=i}),o},f=function(o){i.windowSourceID=e(o).attr("href")||i.windowSourceID,i.windowSourceURL=e(o).attr(i.windowSourceAttrURL)||i.windowSourceURL,i.windowBGImage=i.windowBGImage?"background-image:url("+i.windowBGImage+")":"";var f,w;if("anchored"==i.positionType){var u=e(i.anchoredSelector).position(),h=u.left+i.positionLeft,p=u.top+i.positionTop;switch(e("body").append('
'),i.loader&&""!==i.loaderImagePath&&e("."+i.anchoredClassName).append('
'),e.fn.draggable&&i.draggable&&e("."+i.anchoredClassName).draggable({cursor:"move"}),i.windowSource){case"inline":e("."+i.anchoredClassName+" #DOMWindowContent").append(e(i.windowSourceID).children()),e("."+i.anchoredClassName).unload(function(){e("."+i.windowSourceID).append(e("."+i.anchoredClassName+" #DOMWindowContent").children())}),c(i.anchoredClassName);break;case"iframe":e("."+i.anchoredClassName+" #DOMWindowContent").append(''),e("."+i.anchoredClassName+"Iframe").load(c(i.anchoredClassName));break;case"ajax":"post"==i.windowHTTPType?(i.windowSourceURL.indexOf("?")!==-1?(f=i.windowSourceURL.substr(0,i.windowSourceURL.indexOf("?")),w=s(i.windowSourceURL)):(f=i.windowSourceURL,w={}),e("."+i.anchoredClassName+" #DOMWindowContent").load(f,w,function(){c(i.anchoredClassName)})):(i.windowSourceURL.indexOf("?")==-1&&(i.windowSourceURL+="?"),e("."+i.anchoredClassName+" #DOMWindowContent").load(i.windowSourceURL+"&random="+(new Date).getTime(),function(){c(i.anchoredClassName)}))}}else{if(i.overlay){e("body").append(''),n.isIE6&&(e("body").append(''),d()),t();var m=e("#DOMWindowOverlay");m.fadeIn("fast"),i.modal||m.click(function(){e.closeDOMWindow()})}i.loader&&""!==i.loaderImagePath&&(e("body").append('
'),a()),e("body").append('
');var g=e("#DOMWindow");switch(i.positionType){case"centered":r(),i.height+50>n.viewPortHeight()&&g.css("top",i.fixedWindowY+n.scrollOffsetHeight()+"px");break;case"absolute":g.css({top:i.positionTop+n.scrollOffsetHeight()+"px",left:i.positionLeft+n.scrollOffsetWidth()+"px"}),e.fn.draggable&&i.draggable&&g.draggable({cursor:"move"});break;case"fixed":l();break;case"anchoredSingleWindow":var u=e(i.anchoredSelector).position(),h=u.left+i.positionLeft,p=u.top+i.positionTop;g.css({top:p+"px",left:h+"px"})}switch(e(window).bind("scroll.DOMWindow",function(){i.overlay&&t(),n.isIE6&&d(),"centered"==i.positionType&&r(),"fixed"==i.positionType&&l()}),e(window).bind("resize.DOMWindow",function(){n.isIE6&&d(),i.overlay&&t(),"centered"==i.positionType&&r()}),i.windowSource){case"inline":g.append(e(i.windowSourceID).children()),g.unload(function(){e(i.windowSourceID).append(g.children())}),c();break;case"iframe":g.append(''),e("#DOMWindowIframe").load(c());break;case"ajax":"post"==i.windowHTTPType?(i.windowSourceURL.indexOf("?")!==-1?(f=i.windowSourceURL.substr(0,i.windowSourceURL.indexOf("?")),w=s(i.windowSourceURL)):(f=i.windowSourceURL,w={}),g.load(f,w,function(){c()})):(i.windowSourceURL.indexOf("?")==-1&&(i.windowSourceURL+="?"),g.load(i.windowSourceURL+"&random="+(new Date).getTime(),function(){c()}))}}};return i.eventType?this.each(function(o){e(this).bind(i.eventType,function(){return f(this),!1})}):void f()},e.openDOMWindow=function(o){e.fn.openDOMWindow(o)}}(jQuery);