(function(a){a.fn.closeDOMWindow=function(b){if(!b){b={}}var c=function(d){if(b.anchoredClassName){a("."+b.anchoredClassName).fadeOut("fast",function(){if(a.fn.draggable){a("."+b.anchoredClassName).draggable("destory").trigger("unload").remove()}else{a("."+b.anchoredClassName).trigger("unload").remove()}});if(b.functionCallOnClose){b.functionCallAfterClose()}}else{a("#DOMWindowOverlay").fadeOut("fast",function(){a("#DOMWindowOverlay").trigger("unload").unbind().remove()});a("#DOMWindow").fadeOut("fast",function(){if(a.fn.draggable){a("#DOMWindow").draggable("destroy").trigger("unload").remove()}else{a("#DOMWindow").trigger("unload").remove()}});a(window).unbind("scroll.DOMWindow");a(window).unbind("resize.DOMWindow");if(a.fn.openDOMWindow.isIE6){a("#DOMWindowIE6FixIframe").remove()}if(b.functionCallOnClose){b.functionCallAfterClose()}}};if(b.eventType){return this.each(function(d){a(this).bind(b.eventType,function(){c(this);return false})})}else{c()}};a.closeDOMWindow=function(b){a.fn.closeDOMWindow(b)};a.fn.openDOMWindow=function(c){var f=a.fn.openDOMWindow;f.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:""};var e=a.extend({},a.fn.openDOMWindow.defaultsSettings,c||{});f.viewPortHeight=function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight};f.viewPortWidth=function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth};f.scrollOffsetHeight=function(){return self.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop};f.scrollOffsetWidth=function(){return self.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft};f.isIE6=typeof document.body.style.maxHeight==="undefined";var j=function(){if(f.isIE6){var n=document.documentElement.offsetHeight+document.documentElement.scrollTop-4;var m=document.documentElement.offsetWidth-21;a("#DOMWindowOverlay").css({height:n+"px",width:m+"px"})}else{a("#DOMWindowOverlay").css({height:"100%",width:"100%",position:"fixed"})}};var h=function(){var n=document.documentElement.offsetHeight+document.documentElement.scrollTop-4;var m=document.documentElement.offsetWidth-21;a("#DOMWindowIE6FixIframe").css({height:n+"px",width:m+"px"})};var k=function(){if(e.height+50>f.viewPortHeight()){a("#DOMWindow").css("left",Math.round(f.viewPortWidth()/2)+f.scrollOffsetWidth()-Math.round((a("#DOMWindow").outerWidth())/2))}else{a("#DOMWindow").css("left",Math.round(f.viewPortWidth()/2)+f.scrollOffsetWidth()-Math.round((a("#DOMWindow").outerWidth())/2));a("#DOMWindow").css("top",Math.round(f.viewPortHeight()/2)+f.scrollOffsetHeight()-Math.round((a("#DOMWindow").outerHeight())/2))}};var b=function(){if(f.isIE6){a("#DOMWindowLoader").css({left:Math.round(f.viewPortWidth()/2)+f.scrollOffsetWidth()-Math.round((a("#DOMWindowLoader").innerWidth())/2),position:"absolute"});a("#DOMWindowLoader").css({top:Math.round(f.viewPortHeight()/2)+f.scrollOffsetHeight()-Math.round((a("#DOMWindowLoader").innerHeight())/2),position:"absolute"})}else{a("#DOMWindowLoader").css({left:"50%",top:"50%",position:"fixed"})}};var l=function(){a("#DOMWindow").css("left",e.positionLeft+f.scrollOffsetWidth());a("#DOMWindow").css("top",+e.positionTop+f.scrollOffsetHeight())};var i=function(m){if(arguments[0]){a("."+m+" #DOMWindowLoader").remove();a("."+m+" #DOMWindowContent").fadeIn("fast",function(){if(e.functionCallOnOpen){e.functionCallOnOpen()}});a("."+m+".closeDOMWindow").click(function(){a.closeDOMWindow();return false})}else{a("#DOMWindowLoader").remove();a("#DOMWindow").fadeIn("fast",function(){if(e.functionCallOnOpen){e.functionCallOnOpen()}});a("#DOMWindow .closeDOMWindow").click(function(){a.closeDOMWindow();return false})}};var g=function(m){var n={};m.replace(/b([^&=]*)=([^&=]*)b/g,function(o,p,q){if(typeof n[p]!="undefined"){n[p]+=","+q}else{n[p]=q}});return n};var d=function(n){e.windowSourceID=a(n).attr("href")||e.windowSourceID;e.windowSourceURL=a(n).attr("href")||e.windowSourceURL;e.windowBGImage=e.windowBGImage?"background-image:url("+e.windowBGImage+")":"";var r,p;if(e.positionType=="anchored"){var q=a(e.anchoredSelector).position();var o=q.left+e.positionLeft;var m=q.top+e.positionTop;a("body").append('<div class="'+e.anchoredClassName+'" style="'+e.windowBGImage+";background-repeat:no-repeat;padding:"+e.windowPadding+"px;overflow:auto;position:absolute;top:"+m+"px;left:"+o+"px;height:"+e.height+"px;width:"+e.width+"px;background-color:"+e.windowBGColor+";border:"+e.borderSize+"px solid "+e.borderColor+';z-index:10001"><div id="DOMWindowContent" style="display:none"></div></div>');if(e.loader&&e.loaderImagePath!==""){a("."+e.anchoredClassName).append('<div id="DOMWindowLoader" style="width:'+e.loaderWidth+"px;height:"+e.loaderHeight+'px;"><img src="'+e.loaderImagePath+'" /></div>')}if(a.fn.draggable){if(e.draggable){a("."+e.anchoredClassName).draggable({cursor:"move"})}}switch(e.windowSource){case"inline":a("."+e.anchoredClassName+" #DOMWindowContent").append(a(e.windowSourceID).children());a("."+e.anchoredClassName).unload(function(){a("."+e.windowSourceID).append(a("."+e.anchoredClassName+" #DOMWindowContent").children())});i(e.anchoredClassName);break;case"iframe":a("."+e.anchoredClassName+" #DOMWindowContent").append('<iframe frameborder="0" hspace="0" wspace="0" src="'+e.windowSourceURL+'" name="DOMWindowIframe'+Math.round(Math.random()*1000)+'" style="width:100%;height:100%;border:none;background-color:#fff;" class="'+e.anchoredClassName+'Iframe" ></iframe>');a("."+e.anchoredClassName+"Iframe").load(i(e.anchoredClassName));break;case"ajax":if(e.windowHTTPType=="post"){if(e.windowSourceURL.indexOf("?")!==-1){r=e.windowSourceURL.substr(0,e.windowSourceURL.indexOf("?"));p=g(e.windowSourceURL)}else{r=e.windowSourceURL;p={}}a("."+e.anchoredClassName+" #DOMWindowContent").load(r,p,function(){i(e.anchoredClassName)})}else{if(e.windowSourceURL.indexOf("?")==-1){e.windowSourceURL+="?"}a("."+e.anchoredClassName+" #DOMWindowContent").load(e.windowSourceURL+"&random="+(new Date().getTime()),function(){i(e.anchoredClassName)})}break}}else{if(e.overlay){a("body").append('<div id="DOMWindowOverlay" style="z-index:10000;display:none;position:absolute;top:0;left:0;background-color:'+e.overlayColor+";filter:alpha(opacity="+e.overlayOpacity+");-moz-opacity: 0."+e.overlayOpacity+";opacity: 0."+e.overlayOpacity+';"></div>');if(f.isIE6){a("body").append('<iframe id="DOMWindowIE6FixIframe"  src="blank.html"  style="width:100%;height:100%;z-index:9999;position:absolute;top:0;left:0;filter:alpha(opacity=0);"></iframe>');h()}j();a("#DOMWindowOverlay").fadeIn("fast");if(!e.modal){a("#DOMWindowOverlay").click(function(){a.closeDOMWindow()})}}if(e.loader&&e.loaderImagePath!==""){a("body").append('<div id="DOMWindowLoader" style="z-index:10002;width:'+e.loaderWidth+"px;height:"+e.loaderHeight+'px;"><img src="'+e.loaderImagePath+'" /></div>');b()}a("body").append('<div id="DOMWindow" style="background-repeat:no-repeat;'+e.windowBGImage+";overflow:auto;padding:"+e.windowPadding+"px;display:none;height:"+e.height+"px;width:"+e.width+"px;background-color:"+e.windowBGColor+";border:"+e.borderSize+"px solid "+e.borderColor+'; position:absolute;z-index:10001"></div>');switch(e.positionType){case"centered":k();if(e.height+50>f.viewPortHeight()){a("#DOMWindow").css("top",(e.fixedWindowY+f.scrollOffsetHeight())+"px")}break;case"absolute":a("#DOMWindow").css({top:(e.positionTop+f.scrollOffsetHeight())+"px",left:(e.positionLeft+f.scrollOffsetWidth())+"px"});if(a.fn.draggable){if(e.draggable){a("#DOMWindow").draggable({cursor:"move"})}}break;case"fixed":l();break}a(window).bind("scroll.DOMWindow",function(){if(e.overlay){j()}if(f.isIE6){h()}if(e.positionType=="centered"){k()}if(e.positionType=="fixed"){l()}});a(window).bind("resize.DOMWindow",function(){if(f.isIE6){h()}if(e.overlay){j()}if(e.positionType=="centered"){k()}});switch(e.windowSource){case"inline":a("#DOMWindow").append(a(e.windowSourceID).children());a("#DOMWindow").unload(function(){a(e.windowSourceID).append(a("#DOMWindow").children())});i();break;case"iframe":a("#DOMWindow").append('<iframe frameborder="0" hspace="0" wspace="0" src="'+e.windowSourceURL+'" name="DOMWindowIframe'+Math.round(Math.random()*1000)+'" style="width:100%;height:100%;border:none;background-color:#fff;" id="DOMWindowIframe" ></iframe>');a("#DOMWindowIframe").load(i());break;case"ajax":if(e.windowHTTPType=="post"){if(e.windowSourceURL.indexOf("?")!==-1){r=e.windowSourceURL.substr(0,e.windowSourceURL.indexOf("?"));p=g(e.windowSourceURL)}else{r=e.windowSourceURL;p={}}a("#DOMWindow").load(r,p,function(){i()})}else{if(e.windowSourceURL.indexOf("?")==-1){e.windowSourceURL+="?"}a("#DOMWindow").load(e.windowSourceURL+"&random="+(new Date().getTime()),function(){i()})}break}}};if(e.eventType){return this.each(function(m){a(this).bind(e.eventType,function(){d(this);return false})})}else{d()}};a.openDOMWindow=function(b){a.fn.openDOMWindow(b)}})(jQuery);