/******************************************************************************
*	MyWindow 2011.1.1 (20110314)
*
*	Copyright 2004 - 2011 Carsten Ruppert - carsten.ruppert-at-web.de
*
******************************************************************************/
function MyWindowManager(d){var b=this;this.stack=[];this.overlayStack=[];this.xc=this.active=null;this.useOverlay=d.overlay?d.overlay:!1;this.overlayColor=d.overlayColor?d.overlayColor:"#000000";this.overlayOpacity=d.overlayOpacity?d.overlayOpacity:0.7;this.animationSpeed=d.animSpeed?d.animSpeed:600;this.useXMLConnector=d.ajax?d.ajax:!1;this.zindex=d.zindex?d.zindex:100;this.overlay=!1;this.lastScrollPosX=this.lastScrollPosY=0;this.currentWindow=void 0;this.initConnector=function(){if(window.XMLHttpRequest)return b.xc= new XMLHttpRequest,!0;else if(window.ActiveXObject)try{return b.xc=new ActiveXObject("Msxml2.XMLHTTP"),!0}catch(a){try{return b.xc=new ActiveXObject("Microsoft.XMLHTTP"),!0}catch(c){return!1}}else return!1};this.destructConnector=function(){delete b.xc;return!0};this.appendOverlay=function(){var a=window.innerHeight?window.innerHeight:document.documentElement.offsetHeight,c=document.createElement("div");c.id="overlay";c.style.display="none";c.style.position="absolute";c.style.background=b.overlayColor; c.style.top="0";c.style.left="0";c.style.width="100%";c.style.height=a+"px";c.style.opacity=b.overlayOpacity;c.style.filter="alpha(opacity="+100*b.overlayOpacity+")";c.style.zIndex=b.zindex;b.lastScrollPosY=document.documentElement.scrollTop?document.documentElement.scrollTop:window.pageYOffset;window.scrollTo(0,0);document.body.style.overflow="hidden";document.body.appendChild(c);jQuery(c).fadeIn(b.animationSpeed,function(){b.openWindow();return!0});return c};this.detachOverlay=function(){jQuery(b.overlay).fadeOut(b.animationSpeed, function(){var a=document.getElementById("overlay");document.body.removeChild(a);document.body.style.overflow="";window.scrollTo(0,b.lastScrollPosY)});b.overlay=!1};this.addWindow=function(a,b,d,g,h){this.lastUri=a;this.lastName=b;this.lastWidth=d;this.lastHeight=g;this.lastTheme=h;if(!this.overlay&&this.useOverlay)this.overlay=this.appendOverlay();else return this.openWindow(),!0};this.openWindow=function(){var a=b.lastWidth,c=b.lastHeight;a==0&&(a=window.innerWidth?window.innerWidth-100:document.documentElement.offsetWidth- 100);c==0&&(c=window.innerHeight?window.innerHeight-100:document.documentElement.offsetHeight-100);var d=window.innerWidth?window.innerWidth/2-a/2:document.documentElement.offsetWidth/2-a/2,g=window.innerHeight?window.innerHeight/2-c/2:document.documentElement.offsetHeight/2-c/2,h=b.zindex+(b.stack.length+1)*100,f=b.stack.length;if(b.useXMLConnector){var e=document.createElement("div");e.style.display="none";e.id="mywincontent"+f;document.body.appendChild(e);if(b.initConnector())b.xc.onreadystatechange= function(){if(b.xc.readyState==4&&b.xc.status==200)e.innerHTML=b.xc.responseText,b.destructConnector()},b.xc.open("GET",b.lastUri,!0),b.xc.send(null)}else e=document.createElement("iframe"),e.id="mywincontent"+f,e.style.display="none",e.style.borderWidth="0",e.frameBorder=0,e.frameborder=0,document.body.appendChild(e),e.src=b.lastUri;myWindowConfig.customTheme=b.lastTheme;a=new MyWindow(e.id,a,c,d,g,h,b.lastName,myWindowConfig);a.win.style.display="none";b.stack[b.stack.length]=a;b.overlayStack[b.overlayStack.length]= document.createElement("div");b.currentWindow=a;a.win.id=f;a.ismanaged=!0;jQuery(a.win).fadeIn(b.animationSpeed);if(a.moveable)a._mclipzone.id="mclip"+f,a.eventBind(a._mclipzone,"mousedown",b.activate);if(a.resizeable)a._rclipzone.id="rclip"+f,a.eventBind(a._rclipzone,"mousedown",b.activate);if(a.basics)a._btnmin.style.display="none",a._btnmax.style.display="none",a._btnreset.id="btres"+f,a._btnmax.id="btmax"+f,a._btnmin.id="btmin"+f,a.eventBind(a._btnreset,"mosedown",b.activate),a.eventBind(a._btnmax, "mousedown",b.activate),a.eventBind(a._btnmin,"mousedown",b.activate),jQuery(a._btnmin).fadeIn(b.animationSpeed),jQuery(a._btnmax).fadeIn(b.animationSpeed);if(a.closeable)a._btnclose.style.display="none",a._btnclose.id="btcls"+f,a.eventBind(a._btnclose,"mousedown",b.windowClosed),jQuery(a._btnclose).fadeIn(b.animationSpeed)};this.getWindowId=function(a){return a.target?a.target.id!=""?a.target.id.substring(5,a.target.id.length):(alert("Unable to get Window id."),0):a.srcElement?a.srcElement.id!=""? a.srcElement.id.substring(5,a.srcElement.id.length):(alert("Unable to get Window id in your Internet Explorer."),0):(alert("Your Browser is not supported"),0)};this.resetIds=function(){var a;if(b.stack.length>1)for(i=0;i<b.stack.length;i++){a=b.stack[i];a.win.id=i;a.content.id="mywincontent"+i;if(a.basics)a._btnreset.id="btres"+i,a._btnmax.id="btmax"+i,a._btnmin.id="btmin"+i;if(a.closeable)a._btnclose.id="btcls"+i;if(a.resizeable)a._rclipzone.id="rclip"+i;if(a.moveable)a._mclipzone.id="mclip"+i;a.setZ((i+ 1)*100)}};this.windowClosed=function(a){var a=b.getWindowId(a),c=document.getElementById("mywincontent"+a),d=c.parentNode;try{d.removeChild(c)}catch(g){alert(g.description)}b.stack.splice(a,1);b.stack.length>0?b.resetIds():b.useOverlay&&b.overlay&&b.detachOverlay()};this.activate=function(a){a=b.getWindowId(a);if(b.stack.length>1){var c=[];for(i=0;i<b.stack.length;i++)i==a&&i+1<b.stack.length?(++i,c[c.length]=b.stack[i]):i!=a&&(c[c.length]=b.stack[i]);c[c.length]=b.stack[a];b.stack=c;delete c;b.resetIds(); b.currentWindow=b.stack[b.stack.length-1]}}};
