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