/******************************************************************************
*	MyWindow 2011.1 (20110314)
*
*	Copyright 2004 - 2011 Carsten Ruppert - carsten.ruppert-at-web.de
*
******************************************************************************/
function MyWindow(f,g,h,d,j,k,l,c){var a=this;this.content=document.getElementById(f);this.ismanaged=!1;this.w=g;this.h=h;this.x=d;this.y=j;this.z=k;this.minheight=c.minwidth?c.minwidth:200;this.minwidth=c.minheight?c.minheight:200;this.scrollbars=c.scrollbars!=void 0?c.scrollbars:!0;this.resizeable=c.resizeable!=void 0?c.resizeable:!0;this.moveable=c.moveable!=void 0?c.moveable:!0;this.basics=c.basicButtons!=void 0?c.basicButtons:!0;this.closeable=c.closeable!=void 0?c.closeable:!0;this.classprefix= c.customTheme?c.customTheme:c.theme?c.theme:"mywin";this.useAnimations=c.animations!=void 0?c.animations:!1;this.animationSpeed=c.animationSpeed?c.animationSpeed:800;this.skin=[];this.windowname=l;this.status="standard";this.resizing=this.moveing=!1;this._btnposxd=[0,0,0];this._btnposx=[0,0,0];this._btnposy=[];this.restore=[];this.eventBind=function(a,e,c){window.addEventListener?a.addEventListener(e,c,!1):window.attachEvent&&a.attachEvent("on"+e,c)};this.eventUnbind=function(a,e,c){window.removeEventListener? a.removeEventListener(e,c,!1):window.detachEvent&&a.detachEvent("on"+e,c)};this.expandClipArea=function(b){b.style.left="0px";b.style.top="0px";b.style.width="100%";b.style.zIndex=a.z+1E3;b.style.height=window.innerHeight?window.innerHeight+"px":document.documentElement?document.documentElement.offsetHeight+"px":"100%"};this.removePx=function(a){a.indexOf("px")&&(a=Number(a.substr(0,a.indexOf("px"))));return a};this.move=function(b){a.moveing=!0;var e=document.documentElement?document.documentElement.scrollTop: 0;a._citbx=b.clientX-a.x;a._citby=b.clientY+e-a.y;a.eventUnbind(a._mclipzone,"mousedown",a.move);a.eventBind(a._mclipzone,"mouseup",a.stopp);a.eventBind(a._mclipzone,"mousemove",a.follow);a.expandClipArea(a._mclipzone)};this.stopp=function(){a.moveing=!1;a.eventUnbind(a._mclipzone,"mousemove",a.follow);a.eventUnbind(a._mclipzone,"mouseup",a.stopp);a.eventBind(a._mclipzone,"mousedown",a.move);a.setClipZones()};this.follow=function(b){var e,c,d=document.documentElement?document.documentElement.scrollTop: 0;if(b.clientX)e=b.clientX,c=b.clientY+d;e-=a._citbx;c-=a._citby;a.moveTo(e,c)};this.resize=function(){a.resizing=!0;a.expandClipArea(a._rclipzone);a.eventUnbind(a._rclipzone,"mousedown",a.resize);a.eventBind(a._rclipzone,"mouseup",a.stopResize);a.eventBind(a._rclipzone,"mousemove",a.growShrink)};this.stopResize=function(){a.resizing=!1;a.eventUnbind(a._rclipzone,"mouseup",a.stopResize);a.eventUnbind(a._rclipzone,"mousemove",a.growShrink);a.eventBind(a._rclipzone,"mousedown",a.resize);a.setClipZones()}; this.growShrink=function(b){var c,d=document.documentElement?document.documentElement.scrollTop:0;b.clientX?(c=b.clientX,b=b.clientY+d):(c=b.pageX,b=b.pageY+d);c=c-(Number(a.w)+Number(a.x))+Number(a.w);b=b-(a.h+a.y)+a.h;a.w=c<=a.minwidth?a.w:c;a.h=b<=a.minheight?a.minheight:b;a.win.style.width=a.w+"px";a.win.style.height=a.h+"px";a._wintitle.style.width=a.getTitleWidth()+"px";a.content.style.width=a.getContentWidth()+"px";a.content.style.height=a.getContentHeight()+"px";a.setButtons()};this.minMaxAnimations= function(){var b=a.getTitleWidth(),c=a.getContentWidth(),d=a.getContentHeight();jQuery(a.win).animate({width:a.w+"px",height:a.h+"px",left:a.x+"px",top:a.y+"px"},a.animationSpeed);jQuery(a._wintitle).animate({width:b+"px"},a.animationSpeed);jQuery(a.content).animate({width:c+"px",height:d+"px"},a.animationSpeed)};this.maximize=function(){a.restore=[a.w,a.h,a.x,a.y];document.body.removeChild(a._btnmax);document.body.removeChild(a._btnmin);document.body.appendChild(a._btnreset);document.body.removeChild(a._rclipzone); a.w=(window.innerWidth?window.innerWidth:document.body.offsetWidth)-30;a.h=(window.innerHeight?window.innerHeight:document.documentElement.offsetHeight)-30;a.x=5;a.y=5;a.useAnimations?a.minMaxAnimations():(a.win.style.width=a.w+"px",a.win.style.height=a.h+"px",a.win.style.left=a.x+"px",a.win.style.top=a.y+"px",a._wintitle.style.width=a.getTitleWidth()+"px",a.content.style.width=a.getContentWidth()+"px",a.content.style.height=a.getContentHeight()+"px");a.eventUnbind(a._mclipzone,"mousedown",a.move); a.status="maximized";a.setButtons();a.setClipZones()};this.minimize=function(){a.restore=[a.w,a.h,a.x,a.y];document.body.removeChild(a._btnmax);document.body.removeChild(a._btnmin);document.body.appendChild(a._btnreset);document.body.removeChild(a._rclipzone);a.w=a._btnposxd[2]+100;a.h=a.headheight;a.y=0;a.useAnimations?a.minMaxAnimations():(a.win.style.width=a.w+"px",a.win.style.height=a.h+"px",a.win.style.top=a.y+"px",a.content.style.width="0px",a.content.style.height="0px",a._wintitle.style.width= a.getTitleWidth()+"px");a.status="minimized";a.setButtons();a.setClipZones()};this.reSet=function(){a.w=a.restore[0];a.h=a.restore[1];a.x=a.restore[2];a.y=a.restore[3];var b=a.getTitleWidth(),c=a.getContentWidth(),d=a.getContentHeight();a.useAnimations?a.minMaxAnimations():(a.win.style.width=a.w+"px",a.win.style.height=a.h+"px",a.win.style.left=a.x+"px",a.win.style.top=a.y+"px",a._wintitle.style.width=b+"px",a.content.style.width=c+"px",a.content.style.height=d+"px");a.status=="maximized"&&a.eventBind(a._mclipzone, "mousedown",a.move);document.body.appendChild(a._btnmax);document.body.appendChild(a._btnmin);document.body.removeChild(a._btnreset);document.body.appendChild(a._rclipzone);a.restore=!1;a.status="standard";a.setButtons();a.setClipZones()};this.closeWin=function(){a.content.setAttribute("mywindow","0");for(var b,c;a.win.hasChildNodes;)if((b=a.win.firstChild)&&b.id==a.content.id&&c!=!0)document.body.appendChild(b),b.style.display="none",c=!0;else if(b)a.win.removeChild(b);else break;a.moveable&&document.body.removeChild(a._mclipzone); a.resizeable&&a.status=="standard"&&document.body.removeChild(a._rclipzone);a.basics&&(a.status!="standard"?document.body.removeChild(a._btnreset):(document.body.removeChild(a._btnmax),document.body.removeChild(a._btnmin)));a.closeable&&document.body.removeChild(a._btnclose);document.body.removeChild(a.win);delete a};this.getSkin=function(){var a;for(i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].cssRules)for(d=0;d<document.styleSheets[i].cssRules.length;d++)a=document.styleSheets[i].cssRules[d], a.selectorText&&a.selectorText.indexOf(this.classprefix)>-1&&(this.skin[a.selectorText]=a);else for(d=0;d<document.styleSheets[i].rules.length;d++)a=document.styleSheets[i].rules[d],a.selectorText.indexOf(this.classprefix)>-1&&(this.skin[a.selectorText]=a)};this.setButtons=function(){if(a.closeable)a._btnposx[0]=Number(a.x)+Number(a.w)-Number(a._btnposxd[0]),a._btnposy[0]=a.y+a.removePx(a.skin["."+a.classprefix+"ButtonClose"].style.top),a.useAnimations&&!a.moveing&&!a.resizing?jQuery(a._btnclose).animate({left:a._btnposx[0]+ "px",top:a._btnposy[0]+"px"},a.animationSpeed):(a._btnclose.style.left=a._btnposx[0]+"px",a._btnclose.style.top=a._btnposy[0]+"px");if(a.basics)a._btnposx[1]=Number(a.x)+Number(a.w)-Number(a._btnposxd[1]),a._btnposy[1]=Number(a.y)+a.removePx(a.skin["."+a.classprefix+"Maximizer"].style.top),a._btnposx[2]=Number(a.x)+Number(a.w)-Number(a._btnposxd[2]),a._btnposy[2]=a.y+a.removePx(a.skin["."+a.classprefix+"Minimizer"].style.top),a.useAnimations&&!a.moveing&&!a.resizing?(jQuery(a._btnreset).animate({left:a._btnposx[1]+ "px",top:a._btnposy[1]+"px"},a.animationSpeed),jQuery(a._btnmax).animate({left:a._btnposx[1]+"px",top:a._btnposy[1]+"px"},a.animationSpeed),jQuery(a._btnmin).animate({left:a._btnposx[2]+"px",top:a._btnposy[2]+"px"},a.animationSpeed)):(a._btnreset.style.left=a._btnposx[1]+"px",a._btnreset.style.top=a._btnposy[1]+"px",a._btnmax.style.left=a._btnposx[1]+"px",a._btnmax.style.top=a._btnposy[1]+"px",a._btnmin.style.left=a._btnposx[2]+"px",a._btnmin.style.top=a._btnposy[2]+"px")};this.setClipZones=function(){if(a.moveable)document.body.removeChild(a._mclipzone), document.body.appendChild(a._mclipzone),a._mclipzone.style.left=a.x+"px",a._mclipzone.style.top=a.y+"px",a._mclipzone.style.width=a.w+"px",a._mclipzone.style.height=a.headheight+"px",a._mclipzone.style.zIndex=a.z+1;if(a.resizeable)a.status=="standard"&&(document.body.removeChild(a._rclipzone),document.body.appendChild(a._rclipzone)),a._rclipzone.style.width="15px",a._rclipzone.style.height="15px",a._rclipzone.style.left=Number(a.x)+Number(a.w)+"px",a._rclipzone.style.top=Number(a.y)+Number(a.h)+"px", a._rclipzone.style.zIndex=a.z+1};this.getTitleWidth=function(){var b=a.removePx(a.skin["."+a.classprefix+"Titlebar"].style.borderLeftWidth);b+=a.removePx(a.skin["."+a.classprefix+"Titlebar"].style.borderRightWidth);b+=a.removePx(a.skin["."+a.classprefix+"Titlebar"].style.paddingLeft);b+=a.removePx(a.skin["."+a.classprefix+"Titlebar"].style.paddingRight);b+=a.removePx(a.skin["."+a.classprefix+"Titlebar"].style.marginLeft);b+=a.removePx(a.skin["."+a.classprefix+"Titlebar"].style.marginRight);return a.w- b};this.getContentWidth=function(){var b=a.removePx(a.skin["."+a.classprefix+"Content"].style.borderLeftWidth);b+=a.removePx(a.skin["."+a.classprefix+"Content"].style.borderRightWidth);b+=a.removePx(a.skin["."+a.classprefix+"Content"].style.paddingLeft);b+=a.removePx(a.skin["."+a.classprefix+"Content"].style.paddingRight);return a.w-b};this.getContentHeight=function(){var b=a.removePx(a.skin["."+a.classprefix+"Content"].style.borderTopWidth);b+=a.removePx(a.skin["."+a.classprefix+"Content"].style.borderBottomWidth); b+=a.removePx(a.skin["."+a.classprefix+"Content"].style.paddingTop);b+=a.removePx(a.skin["."+a.classprefix+"Content"].style.paddingBottom);b+=a.headheight;return a.h-b};this.setZ=function(b){a.z=b;a.win.style.zIndex=b;if(a.closeable)a._btnclose.style.zIndex=a.z+2;if(a.basics)a._btnmax.style.zIndex=a.z+2,a._btnmin.style.zIndex=a.z+2,a._btnreset.style.zIndex=a.z+2;if(a.moveable)a._mclipzone.style.zIndex=a.z+1;if(a.resizeable)a._rclipzone.style.zIndex=a.z+1};this.moveTo=function(b,c){a.x=b;a.y=c;a.useAnimations&& !a.moveing?jQuery(a.win).animate({left:a.x+"px",top:a.y+"px"},a.animationSpeed):(a.win.style.left=a.x+"px",a.win.style.top=a.y+"px");a.setButtons();a.moveing||a.setClipZones()};this.resizeTo=function(b,c){a.w=b;a.h=c;var d=a.getTitleWidth(),f=a.getContentWidth(),g=a.getContentHeight();a.useAnimations&&!a.resizing?(jQuery(a.win).animate({width:a.w+"px",height:a.h+"px"},a.animationSpeed),jQuery(a.content).animate({width:f+"px",height:g+"px"},a.animationSpeed),jQuery(a._wintitle).animate({width:d+"px"}, a.animationSpeed)):(a.win.style.width=a.w+"px",a.win.style.height=a.h+"px",a._wintitle.style.width=a.getTitleWidth()+"px",a.content.style.width=a.getContentWidth()+"px",a.content.style.height=a.getContentHeight()+"px");a.setClipZones();a.setButtons()};this.setWindowTitle=function(b){a.winname.innerHTML=b};if(this.content)if(f=(f=this.content.getAttributeNode("mywindow"))?f.nodeValue:0,f==0){f=document.createAttribute("mywindow");f.nodeValue="1";this.content.setAttributeNode(f);this.getSkin();this.headheight= this.removePx(this.skin["."+this.classprefix+"Titlebar"].style.height);this.headheight+=this.removePx(this.skin["."+this.classprefix+"Titlebar"].style.paddingTop);this.headheight+=this.removePx(this.skin["."+this.classprefix+"Titlebar"].style.paddingBottom);this.headheight+=this.removePx(this.skin["."+this.classprefix+"Titlebar"].style.marginTop);this.headheight+=this.removePx(this.skin["."+this.classprefix+"Titlebar"].style.marginBottom);this.headheight+=this.removePx(this.skin["."+this.classprefix+ "Titlebar"].style.borderTopWidth);this.headheight+=this.removePx(this.skin["."+this.classprefix+"Titlebar"].style.borderBottomWidth);this.minheight=this.headheight;this.win=document.createElement("div");this.win.className=this.classprefix+"Window";this.win.style.position="absolute";this.win.style.left=this.x+"px";this.win.style.top=this.y+"px";this.win.style.width=this.w+"px";this.win.style.height=this.h+"px";this.win.style.overflow="hidden";this.win.style.zIndex=this.z;document.body.appendChild(this.win); this.content.className=this.classprefix+"Content";this.content.style.position="absolute";this.content.style.display="block";this.content.style.top=this.headheight+"px";this.content.style.width=this.getContentWidth()+"px";this.content.style.height=this.getContentHeight()+"px";this.content.style.overflow=this.scrollbars?"auto":"hidden";this.win.appendChild(this.content);this._wintitle=document.createElement("div");this._wintitle.className=this.classprefix+"Titlebar";this._wintitle.style.position="absolute"; this._wintitle.style.left="0px";this._wintitle.style.top="0px";this._wintitle.style.width=this.getTitleWidth()+"px";this._wintitle.style.overflow="hidden";this.win.appendChild(this._wintitle);this.winname=document.createElement("div");this.winname.className=this.classprefix+"Name";this._wintitle.appendChild(this.winname);if(this.windowname!="")this.winname.innerHTML=this.windowname;if(this.moveable)this._mclipzone=document.createElement("div"),this._mclipzone.className="mywindowClippingArea",this._mclipzone.style.position= "absolute",this._mclipzone.style.left=this.x+"px",this._mclipzone.style.top=this.y+"px",this._mclipzone.style.width=this.w+"px",this._mclipzone.style.width=this.getTitleWidth()+"px",this._mclipzone.style.height=this.headheight+"px",this._mclipzone.style.zIndex=this.z+1,this.eventBind(this._mclipzone,"mousedown",a.move),document.body.appendChild(this._mclipzone);if(this.resizeable)this._rclipzone=document.createElement("div"),this._rclipzone.className=this.classprefix+"Resizer mywindowClippingArea", this._rclipzone.style.position="absolute",this._rclipzone.style.left=Number(a.x)+Number(a.w)+"px",this._rclipzone.style.top=Number(a.y)+Number(a.h)+"px",this._rclipzone.style.cursor="se-resize",this._rclipzone.style.width="15px",this._rclipzone.style.height="15px",this._rclipzone.style.zIndex=this.z+1,this.eventBind(this._rclipzone,"mousedown",this.resize),document.body.appendChild(this._rclipzone);if(this.closeable)this._btnclose=document.createElement("a"),this._btnposxd[0]=this.removePx(this.skin["."+ this.classprefix+"ButtonClose"].style.width),this._btnposx[0]=Number(this.x)+Number(this.w)-Number(this._btnposxd[0]),this._btnposy[0]=this.y+this.removePx(this.skin["."+this.classprefix+"ButtonClose"].style.top),this._btnclose.className=this.classprefix+"ButtonClose",this._btnclose.style.position="absolute",this._btnclose.style.left=this._btnposx[0]+"px",this._btnclose.style.top=this._btnposy[0]+"px",this._btnclose.style.zIndex=this.z+2,this.ismanaged||this.eventBind(this._btnclose,"click",this.closeWin), document.body.appendChild(this._btnclose);if(this.basics)this._btnmax=document.createElement("a"),this._btnmin=document.createElement("a"),this._btnposxd[1]=this.removePx(this.skin["."+this.classprefix+"Maximizer"].style.width),this._btnposxd[1]+=this.closeable?this._btnposxd[0]:0,this._btnposxd[2]=this._btnposxd[1]+this.removePx(this.skin["."+this.classprefix+"Minimizer"].style.width),this._btnposx[1]=Number(this.x)+Number(this.w)-Number(this._btnposxd[1]),this._btnposx[2]=Number(this.x)+Number(this.w)- Number(this._btnposxd[2]),this._btnposy[1]=this.y+this.removePx(this.skin["."+this.classprefix+"Maximizer"].style.top),this._btnposy[2]=this.y+this.removePx(this.skin["."+this.classprefix+"Minimizer"].style.top),this._btnmax.className=this.classprefix+"Maximizer",this._btnmax.style.position="absolute",this._btnmax.style.left=this._btnposx[1]+"px",this._btnmax.style.top=this._btnposy[1]+"px",this._btnmax.style.zIndex=this.z+2,this._btnmin.className=this.classprefix+"Minimizer",this._btnmin.style.position= "absolute",this._btnmin.style.left=this._btnposx[2]+"px",this._btnmin.style.top=this._btnposy[2]+"px",this._btnmin.style.zIndex=this.z+2,this._btnreset=document.createElement("a"),this._btnreset.className=this.classprefix+"ButtonReset",this._btnreset.style.position="absolute",this._btnreset.style.left=this._btnposx[1]+"px",this._btnreset.style.top=this._btnposy[1]+"px",this._btnreset.style.zIndex=this.z+2,this.eventBind(this._btnmax,"click",this.maximize),this.eventBind(this._btnmin,"click",this.minimize), this.eventBind(this._btnreset,"click",this.reSet),document.body.appendChild(this._btnmax),document.body.appendChild(this._btnmin);return this.content.id}else delete a;else return!1};
