//
// openPopUps v1.01 Copyright (c) 2006 openWebWare.com
// This copyright notice MUST stay intact for use.
//
// The perfect pop up window replacement for your advertisements and web 
// applications. Pop up blockers will fail to prevent an openPopUp window 
// from opening. 
//
// This library is free software; you can redistribute it and/or modify 
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation; either version 2.1 of the License, or 
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
// License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along 
// with this library; if not, write to the Free Software Foundation, Inc., 59 
// Temple Place, Suite 330, Boston, MA 02111-1307 USA 

// CSS Diretory
cssDir = "css/";

// Images Directory
imageDir = "images/";

// Include Style Sheet
//document.write('<link rel="stylesheet" type="text/css" href="' +cssDir+ 'styles.css">\n');

/* ---------------------------------------------------------------------- *\
  Function    : JSWindow()
  Description : creates a new window
  Usage       : JSWindow("title", oContent, [x], [y], [id], [width])
  Arguments   : title    - The title of the window as displayed in the titlebar
	              oContent - The content of the Div called using getElementbyID
								x        - The number of pixels from the left the window appears when first open
								y        - The number of pixels from the top the window appears when first open
	              id       - The <div> this window will use for its content
                width    - The default width of the window                
\* ---------------------------------------------------------------------- */

function JSWindow(title, oContent, x, y, id, width, popupColor, minimizeIcon, modul)
{
	this.modul = modul;
	this.max=false;
	if(modul==1){
		// define variables
		this.title = title;
		this.oContent = oContent;
	  this.width = width;
		this.x = x;
		this.y = y;
	  this.id = id;
		//this.bgcolor = popupColor;

		this.backgroundImage="url(../images/bg.jpg)";


		// create the table window and define CSS properties
		this.oTable = document.createElement("table");
	  this.oTable.id = "Window " + this.id;
	  this.oTable.border="0";
		this.oTable.style.width = this.width + "px";
		//this.oTable.style.border = "1px solid #0D1D72";
	  this.oTable.cellSpacing = 0;
		this.oTable.cellPadding = 0;
		this.oTable.border = 0;
		this.oTable.style.backgroundColor = "#FFFFFF";

		// determine the windows position when first open
		this.oTable.style.position = "absolute";
		this.oTable.style.left = this.x + "px";
		this.oTable.style.top = this.y + "px";

		// link from the table to the JSWindow object
		this.oTable.jsWindow = this;

		// if the table is clicked anywhere, show the table in front of other open windows
		this.oTable.onmousedown = JSWindow.prototype.onBringToFront;

		// append to document body
		document.body.appendChild(this.oTable);

		// add a row for the titlebar
		var oTR = this.oTable.insertRow(0);
		oTR.className = "JSWindowTitleStyle";


		// Title: add the title to the titlebar	
		var tl = oTR.insertCell(0);
		tl.innerHTML="<img src='images/top-left.png' style='width: 5px; height: 24px;'>";
		tl.width = "5px";
		tl.colSpan=1;
		tl.height = "24px";
		tl.style.backgroundImage = "url(" + imageDir + "top.png)";
		
		
		oTD = oTR.insertCell(1);
		oTD.innerHTML = title;
		oTD.colSpan = 4;
		oTD.jsWindow = this;
		oTD.onmousedown = JSWindow.prototype.tdOnMouseDown;
		//oTD.ommouseover = JSWindow.prototype.tdOnMouseOver;
		//oTD.ommouseout = JSWindow.prototype.tdOnMouseOut;
		//oTD.style.borderBottom = "1px solid #003062";
		oTD.style.backgroundImage = "url(" + imageDir + "top.png)";
		oTD.style.cursor = "move";
		oTD.height = "24px";
		oTD.width = "100%";
		
		// Minimize: add the minimize button to the titlebar
		this.oMinTD = oTR.insertCell(2);
		  this.oMinTD.innerHTML = "<img src='images/maximize.png' style='width: 19px; height: 24px;' border=0>";
		  this.oMinTD.onmousedown = JSWindow.prototype.onMaximize;
		  this.oMinTD.jsWindow = this;
	    	//this.oMinTD.style.borderBottom = "1px solid black";
		 // this.oMinTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
		  this.oMinTD.width = "19px";
		  //this.oMinTD.style.paddingRight = "1px";	
	  

		// Close: add the close button to the titlebar
		oTD = oTR.insertCell(3); 
		oTD.innerHTML = "<img src='images/close.png' style='width: 19px; height: 24px;' border=0>";
		oTD.jsWindow = this;
		//oTD.onmousedown = JSWindow.prototype.hide;
		oTD.onmousedown = JSWindow.prototype.onClose;
		//oTD.style.borderBottom = "1px solid black";
		//oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
	  	oTD.width = "19px";
		//oTD.style.paddingLeft = "1px";
		
		// Close: add the close button to the titlebar
		oTD = oTR.insertCell(4); 
		oTD.innerHTML = "<img src='images/top-right.png' style='width: 15px; height: 24px;'>";
		oTD.jsWindow = this;
		//oTD.onmousedown = JSWindow.prototype.hide;
		//oTD.onmousedown = JSWindow.prototype.onClose;
		//oTD.style.borderBottom = "1px solid black";
		//oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
	 	oTD.width = "15px";
		//oTD.style.paddingLeft = "1px";

		// add a row for the window's content
		oTR = this.oTable.insertRow(1);
		
		
		this.oMenuTD = oTR.insertCell(0);
		//this.oMenuTD.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		this.oContentTD = oTR.insertCell(1);
		var div = document.createElement("div");
		div.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		div.style.backgroundRepeat="repeat-y";
		div.style.paddingLeft = "5px";
		div.height="100%";
		//div.style.overflow="hidden";
		div.id="popmenu";
		div.className="popmenu";
		this.oMenuTD.appendChild(div);
		if (minimizeIcon == 1) {
		  this.oContentTD.colSpan = 6;
		}
		else {
		  this.oContentTD.colSpan = 6;
		}  

		oTD = oTR.insertCell(2); 
		oTD.innerHTML = "";
		oTD.jsWindow = this;
		oTD.colSpan=1;
		oTD.style.backgroundImage = "url(" + imageDir + "right-border.png)";
		oTD.width = "15px";
		oTD.style.backgroundRepeat="repeat-y";
		//oTD.style.paddingLeft = "1px";
		
		this.sLine=oTR;
		oTR = this.oTable.insertRow(2);
		
		oTD = oTR.insertCell(0); 
		oTD.innerHTML = "<img src='images/left-bottom.png' style='width: 5px; height: 38px;'>";
		oTD.jsWindow = this;
		oTD.colSpan=2;
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.height = "38px";
		//oTD.style.paddingLeft = "1px";
		
		oTD = oTR.insertCell(1); 
		oTD.jsWindow = this;
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.colSpan=4;
		oTD.rowSpan=1;
		
		oTD = oTR.insertCell(2); 
		oTD.jsWindow = this;
		oTD.innerHTML = "";
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.style.align="right";
		
		oTD.colSpan=1;
		oTD.rowSpan=1;
		
		//oTD = oTR.insertCell(2); 
		//oTD.jsWindow = this;
		//oTD.innerHTML = "<img src='images/resize.png' style='width: 19px; height: 39px;' border='0'>";
		//oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		//oTD.style.align="right";
		//oTD.onmousedown = JSWindow.prototype.onResize;
		//oTD.colSpan=1;
		//oTD.rowSpan=1;

		oTD = oTR.insertCell(3); 
		oTD.jsWindow = this;
		oTD.innerHTML = "<img src='images/low-right.png' style='width: 15px; height: 39px;'>";
		//oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.colSpan=1;
		oTD.rowSpan=1;
		
		this.oMenuTD.style.backgroundColor = this.bgcolor;
		this.oMenuTD.className = "JSWindowMenuStyle";
		this.oContentTD.style.backgroundColor = this.bgcolor;
		this.oContentTD.className = "JSWindowContentStyle";


		// use the content from the referenced div as the content for the window
		//var code = innerXHTML(this.oContentTD,innerXHTML(document.getElementById("Div" + this.id)));

		this.oContentTD.innerHTML = document.getElementById("Div" + this.id).innerHTML;
	}
	if(modul==2){
		// define variables
		this.title = title;
		this.oContent = oContent;
	  this.width = width;
		this.x = x;
		this.y = y;
	  this.id = id;
		//this.bgcolor = popupColor;

		this.backgroundImage="url(../images/bg.jpg)";


		// create the table window and define CSS properties
		this.oTable = document.createElement("table");
	  this.oTable.id = "Window " + this.id;
	  this.oTable.border="0";
		this.oTable.style.width = this.width + "px";
		//this.oTable.style.border = "1px solid #0D1D72";
	  this.oTable.cellSpacing = 0;
		this.oTable.cellPadding = 0;
		this.oTable.border = 0;
		this.oTable.style.backgroundColor = "#FFFFFF";

		// determine the windows position when first open
		this.oTable.style.position = "absolute";
		this.oTable.style.left = this.x + "px";
		this.oTable.style.top = this.y + "px";

		// link from the table to the JSWindow object
		this.oTable.jsWindow = this;

		// if the table is clicked anywhere, show the table in front of other open windows
		this.oTable.onmousedown = JSWindow.prototype.onBringToFront;

		// append to document body
		document.body.appendChild(this.oTable);

		// add a row for the titlebar
		var oTR = this.oTable.insertRow(0);
		oTR.className = "JSWindowTitleStyle";


		// Title: add the title to the titlebar	
		var tl = oTR.insertCell(0);
		tl.innerHTML="<img src='images/top-left.png' style='width: 5px; height: 24px;'>";
		tl.width = "5px";
		tl.colSpan=1;
		tl.height = "24px";
		tl.style.backgroundImage = "url(" + imageDir + "top.png)";
		
		
		oTD = oTR.insertCell(1);
		oTD.innerHTML = title;
		oTD.colSpan = 4;
		oTD.jsWindow = this;
		oTD.onmousedown = JSWindow.prototype.tdOnMouseDown;
		//oTD.ommouseover = JSWindow.prototype.tdOnMouseOver;
		//oTD.ommouseout = JSWindow.prototype.tdOnMouseOut;
		//oTD.style.borderBottom = "1px solid #003062";
		oTD.style.backgroundImage = "url(" + imageDir + "top.png)";
		oTD.style.cursor = "move";
		oTD.height = "24px";
		oTD.width = "100%";
		
		// Minimize: add the minimize button to the titlebar
		this.oMinTD = oTR.insertCell(2);
		  this.oMinTD.innerHTML = "";
		  //this.oMinTD.onmousedown = JSWindow.prototype.onMaximize;
		  this.oMinTD.jsWindow = this;
	    	//this.oMinTD.style.borderBottom = "1px solid black";
		 // this.oMinTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
		  this.oMinTD.width = "19px";
		  //this.oMinTD.style.paddingRight = "1px";	
	  

		// Close: add the close button to the titlebar
		oTD = oTR.insertCell(3); 
		oTD.innerHTML = "<img src='images/close.png' style='width: 19px; height: 24px;' border=0>";
		oTD.jsWindow = this;
		//oTD.onmousedown = JSWindow.prototype.hide;
		oTD.onmousedown = JSWindow.prototype.onClose;
		//oTD.style.borderBottom = "1px solid black";
		//oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
	  	oTD.width = "19px";
		//oTD.style.paddingLeft = "1px";
		
		// Close: add the close button to the titlebar
		oTD = oTR.insertCell(4); 
		oTD.innerHTML = "<img src='images/top-right.png' style='width: 15px; height: 24px;'>";
		oTD.jsWindow = this;
		//oTD.onmousedown = JSWindow.prototype.hide;
		//oTD.onmousedown = JSWindow.prototype.onClose;
		//oTD.style.borderBottom = "1px solid black";
		//oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
	 	oTD.width = "15px";
		//oTD.style.paddingLeft = "1px";

		// add a row for the window's content
		oTR = this.oTable.insertRow(1);
		
		
		this.oMenuTD = oTR.insertCell(0);
		//this.oMenuTD.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		this.oContentTD = oTR.insertCell(1);
		var div = document.createElement("div");
		div.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		div.style.backgroundRepeat="repeat-y";
		div.style.paddingLeft = "5px";
		div.style.height="100%";
		div.style.width="10px"
		//div.innerHTML="<br><br><br><br><br><br><br><br><br>";
		//div.style.overflow="hidden";
		div.id="popmenu";
		//div.className="popmenu";
		this.oMenuTD.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		this.oMenuTD.style.backgroundRepeat="repeat-y";
		//this.oMenuTD.appendChild(div);
		if (minimizeIcon == 1) {
		  this.oContentTD.colSpan = 6;
		}
		else {
		  this.oContentTD.colSpan = 6;
		}  

		oTD = oTR.insertCell(2); 
		oTD.innerHTML = "";
		oTD.jsWindow = this;
		oTD.colSpan=1;
		oTD.style.backgroundImage = "url(" + imageDir + "right-border.png)";
		oTD.width = "15px";
		oTD.style.backgroundRepeat="repeat-y";
		//oTD.style.paddingLeft = "1px";
		
		this.sLine=oTR;
		oTR = this.oTable.insertRow(2);
		
		oTD = oTR.insertCell(0); 
		oTD.innerHTML = "<img src='images/left-bottom.png' style='width: 5px; height: 38px;'>";
		oTD.jsWindow = this;
		oTD.colSpan=2;
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.height = "38px";
		//oTD.style.paddingLeft = "1px";
		
		oTD = oTR.insertCell(1); 
		oTD.jsWindow = this;
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.colSpan=4;
		oTD.rowSpan=1;
		
		oTD = oTR.insertCell(2); 
		oTD.jsWindow = this;
		oTD.innerHTML = "";
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.style.align="right";
		
		oTD.colSpan=1;
		oTD.rowSpan=1;
		
		//oTD = oTR.insertCell(2); 
		//oTD.jsWindow = this;
		//oTD.innerHTML = "<img src='images/resize.png' style='width: 19px; height: 39px;' border='0'>";
		//oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		//oTD.style.align="right";
		//oTD.onmousedown = JSWindow.prototype.onResize;
		//oTD.colSpan=1;
		//oTD.rowSpan=1;

		oTD = oTR.insertCell(3); 
		oTD.jsWindow = this;
		oTD.innerHTML = "<img src='images/low-right.png' style='width: 15px; height: 39px;'>";
		//oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.colSpan=1;
		oTD.rowSpan=1;
		
		this.oMenuTD.style.backgroundColor = this.bgcolor;
		this.oMenuTD.className = "JSWindowMenuStyle";
		this.oContentTD.style.backgroundColor = this.bgcolor;
		this.oContentTD.className = "JSWindowContentStyle";


		// use the content from the referenced div as the content for the window
		//var code = innerXHTML(this.oContentTD,innerXHTML(document.getElementById("Div" + this.id)));

		this.oContentTD.innerHTML = document.getElementById("Div" + this.id).innerHTML;
	}
	if(modul==3){
		// define variables
		this.title = title;
		this.oContent = oContent;
	  this.width = width;
		this.x = x;
		this.y = y;
	  this.id = id;
		//this.bgcolor = popupColor;

		this.backgroundImage="url(../images/bg.jpg)";


		// create the table window and define CSS properties
		this.oTable = document.createElement("table");
	  this.oTable.id = "Window " + this.id;
	  this.oTable.border="0";
		this.oTable.style.width = this.width + "px";
		//this.oTable.style.border = "1px solid #0D1D72";
	  this.oTable.cellSpacing = 0;
		this.oTable.cellPadding = 0;
		this.oTable.border = 0;
		this.oTable.style.backgroundColor = "#FFFFFF";

		// determine the windows position when first open
		this.oTable.style.position = "absolute";
		this.oTable.style.left = this.x + "px";
		this.oTable.style.top = this.y + "px";

		// link from the table to the JSWindow object
		this.oTable.jsWindow = this;

		// if the table is clicked anywhere, show the table in front of other open windows
		this.oTable.onmousedown = JSWindow.prototype.onBringToFront;

		// append to document body
		document.body.appendChild(this.oTable);

		// add a row for the titlebar
		var oTR = this.oTable.insertRow(0);
		oTR.className = "JSWindowTitleStyle";


		// Title: add the title to the titlebar	
		var tl = oTR.insertCell(0);
		tl.innerHTML="<img src='images/top-left.png' style='width: 5px; height: 24px;'>";
		tl.width = "5px";
		tl.colSpan=1;
		tl.height = "24px";
		tl.style.backgroundImage = "url(" + imageDir + "top.png)";


		oTD = oTR.insertCell(1);
		oTD.innerHTML = title;
		oTD.colSpan = 4;
		oTD.jsWindow = this;
		oTD.onmousedown = JSWindow.prototype.tdOnMouseDown;
		//oTD.ommouseover = JSWindow.prototype.tdOnMouseOver;
		//oTD.ommouseout = JSWindow.prototype.tdOnMouseOut;
		//oTD.style.borderBottom = "1px solid #003062";
		oTD.style.backgroundImage = "url(" + imageDir + "top.png)";
		oTD.style.cursor = "move";
		oTD.height = "24px";
		oTD.width = "100%";

		// Minimize: add the minimize button to the titlebar
		this.oMinTD = oTR.insertCell(2);
		  this.oMinTD.innerHTML = "<img src='images/maximize.png' style='width: 19px; height: 24px;' border=0>";
		  this.oMinTD.onmousedown = JSWindow.prototype.onMaximize;
		  this.oMinTD.jsWindow = this;
		//this.oMinTD.style.borderBottom = "1px solid black";
		 // this.oMinTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
		  this.oMinTD.width = "19px";
		  //this.oMinTD.style.paddingRight = "1px";	


		// Close: add the close button to the titlebar
		oTD = oTR.insertCell(3); 
		oTD.innerHTML = "<img src='images/close.png' style='width: 19px; height: 24px;' border=0>";
		oTD.jsWindow = this;
		//oTD.onmousedown = JSWindow.prototype.hide;
		oTD.onmousedown = JSWindow.prototype.onClose;
		//oTD.style.borderBottom = "1px solid black";
		//oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
		oTD.width = "19px";
		//oTD.style.paddingLeft = "1px";

		// Close: add the close button to the titlebar
		oTD = oTR.insertCell(4); 
		oTD.innerHTML = "<img src='images/top-right.png' style='width: 15px; height: 24px;'>";
		oTD.jsWindow = this;
		//oTD.onmousedown = JSWindow.prototype.hide;
		//oTD.onmousedown = JSWindow.prototype.onClose;
		//oTD.style.borderBottom = "1px solid black";
		//oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
		oTD.width = "15px";
		//oTD.style.paddingLeft = "1px";

		// add a row for the window's content
		oTR = this.oTable.insertRow(1);


		this.oMenuTD = oTR.insertCell(0);
		//this.oMenuTD.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		this.oContentTD = oTR.insertCell(1);
		var div = document.createElement("div");
		div.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		div.style.backgroundRepeat="repeat-y";
		div.style.paddingLeft = "5px";
		div.style.height="100%";
		div.style.width="10px";
		div.innerHTML="<br><br><br><br><br><br><br><br><br>";
		div.style.overflow="hidden";
		div.id="popmenu";
		div.className="popmenu";
		this.oMenuTD.style.backgroundImage = "url(" + imageDir + "left-border.gif)";
		this.oMenuTD.style.backgroundRepeat="repeat-y";
		//this.oMenuTD.appendChild(div);
		if (minimizeIcon == 1) {
		  this.oContentTD.colSpan = 6;
		}
		else {
		  this.oContentTD.colSpan = 6;
		}  

		oTD = oTR.insertCell(2); 
		oTD.innerHTML = "";
		oTD.jsWindow = this;
		oTD.colSpan=1;
		oTD.style.backgroundImage = "url(" + imageDir + "right-border.png)";
		oTD.width = "15px";
		oTD.style.backgroundRepeat="repeat-y";
		//oTD.style.paddingLeft = "1px";

		this.sLine=oTR;
		oTR = this.oTable.insertRow(2);

		oTD = oTR.insertCell(0); 
		oTD.innerHTML = "<img src='images/left-bottom.png' style='width: 5px; height: 38px;'>";
		oTD.jsWindow = this;
		oTD.colSpan=2;
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.height = "38px";
		//oTD.style.paddingLeft = "1px";

		oTD = oTR.insertCell(1); 
		oTD.jsWindow = this;
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.colSpan=4;
		oTD.rowSpan=1;

		oTD = oTR.insertCell(2); 
		oTD.jsWindow = this;
		oTD.innerHTML = "";
		oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.style.align="right";

		oTD.colSpan=1;
		oTD.rowSpan=1;

		//oTD = oTR.insertCell(2); 
		//oTD.jsWindow = this;
		//oTD.innerHTML = "<img src='images/resize.png' style='width: 19px; height: 39px;' border='0'>";
		//oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		//oTD.style.align="right";
		//oTD.onmousedown = JSWindow.prototype.onResize;
		//oTD.colSpan=1;
		//oTD.rowSpan=1;

		oTD = oTR.insertCell(3); 
		oTD.jsWindow = this;
		oTD.innerHTML = "<img src='images/low-right.png' style='width: 15px; height: 39px;'>";
		//oTD.style.backgroundImage = "url(" + imageDir + "bottom.png)";
		oTD.colSpan=1;
		oTD.rowSpan=1;

		this.oMenuTD.style.backgroundColor = this.bgcolor;
		//this.oMenuTD.className = "JSWindowMenuStyle";
		this.oContentTD.style.backgroundColor = this.bgcolor;
		this.oContentTD.className = "JSWindowContentStyle";


		// use the content from the referenced div as the content for the window
		//var code = innerXHTML(this.oContentTD,innerXHTML(document.getElementById("Div" + this.id)));

		this.oContentTD.innerHTML = document.getElementById("Div" + this.id).innerHTML;
	}
}
JSWindow.prototype.update = function()
{
	this.oContentTD.innerHTML = document.getElementById("Div" + this.id).innerHTML;

}

JSWindow.prototype.hide = function()
{
	isfade=true;
	if(isfade){
		this.oTable.style.filter='alpha(opacity=100)';
		window.setTimeout("fade("+this.id+",50);",000); 
		window.setTimeout("fade("+this.id+",10);",100); 
		window.setTimeout("fade("+this.id+",0);",200); 
	}
	document.body.removeChild(this.oTable);
}

JSWindow.prototype.show = function(isfade)
{
	if(isfade){
		this.oTable.style.filter='alpha(opacity=00)';
	}
	document.body.appendChild(this.oTable);
	if(isfade){
		window.setTimeout("fade("+this.id+",10);",000); 
		window.setTimeout("fade("+this.id+",50);",100); 
		window.setTimeout("fade("+this.id+",100);",200); 
	}
}

function fade(what,amm)
{	if(document.getElementById("Window "+what)){
		document.getElementById("Window "+what).style.filter='alpha(opacity='+amm+')';
	}
}
JSWindow.prototype.onBringToFront = function()
{
	this.jsWindow.bringToFront();
}

JSWindow.prototype.onMaximize = function()
{
	if(!this.jsWindow.max){
		this.jsWindow.max=true;
		//this.jsWindow.oTable.style.position = "absolute";
		//this.jsWindow.oTable.style.left = "0px";
		//this.jsWindow.oTable.style.top = "0px";
		//this.jsWindow.oTable.style.height = hh*2+"px";
		//this.jsWindow.oTable.style.width = hw*2+"px";
		this.jsWindow.oTable.style.position = "absolute";
		this.jsWindow.oTable.style.left = "14px";
		this.jsWindow.oTable.style.top = "7px";
		this.jsWindow.sLine.style.height = (hh*2)-250+"px";
		this.jsWindow.oTable.style.width = (hw*2)-50+"px";
	}else{
		this.jsWindow.max=false;
		this.jsWindow.oTable.style.position = "absolute";
		this.jsWindow.oTable.style.left = hw-(this.jsWindow.width/2)+"px";
		this.jsWindow.oTable.style.top = "80px";
		this.jsWindow.sLine.style.height = "250px";
		this.jsWindow.oTable.style.width = "300px";
		//this.jsWindow.oTable.style.width = this.jsWindow.width;
	}
	
}

JSWindow.prototype.onResize = function()
{
	alert("resize");
}

JSWindow.prototype.bringToFront = function()
{
	// if not already the last child of the document.body, make it so
	if ( document.body.childNodes[document.body.childNodes.length-1] !== this.oTable )
	{
		// move to bottom of document
		document.body.appendChild(this.oTable);
	}
}

JSWindow.prototype.tdOnMouseDown = function()
{
	document.onselectstart=new Function ("return false");
	
	this.jsWindow.oTable.firstChild.firstChild.style.backgroundColor='#C8DAE8';
	this.jsWindow.oTable.style.filter='alpha(opacity=83)';
	this.jsWindow.onMouseDown();
}


JSWindow.prototype.onMouseDown = function()
{
	// record that an onmousedown has just occurred
	this.bDown = true;
	
	// link from body to this JSWindow object
	document.body.jsWindow = this;

	// save body mouse handlers
	this.saveMouseMove = document.body.onmousemove;
	this.saveMouseUp = document.body.onmouseup;

	// set new handlers.
	document.body.onmousemove = JSWindow.prototype.bodyOnMouseMove;
	document.body.onmouseup = JSWindow.prototype.bodyOnMouseUp;
}

JSWindow.prototype.bodyOnMouseMove = function(evt)
{
	var e = window.event ? window.event : evt;
	this.jsWindow.onMouseMove(e);
}

JSWindow.prototype.onMouseMove = function(evt)
{
	// if mouse not down, stop the move (for IE only)
	//if ( (document.all) && !(evt.button & 1) )
	//{
	//	this.onMouseUp();
	//	return;
	//}
	if ( this.bDown )
	{
		this.dx = parseInt(this.oTable.style.left, 10) - evt.clientX;
		this.dy = parseInt(this.oTable.style.top, 10) - evt.clientY;
		this.bDown = false;
	}
	else
	{
		this.oTable.style.left = Math.max((this.dx + evt.clientX),0) + "px";
		this.oTable.style.top = Math.max((this.dy + evt.clientY),0) + "px";
	}
}

JSWindow.prototype.bodyOnMouseUp = function()
{
	document.onselectstart=new Function ("return true");
	this.jsWindow.oTable.firstChild.firstChild.style.backgroundColor='#f5f5f5';
	this.jsWindow.oTable.style.filter='alpha(opacity=100)';
	this.jsWindow.onMouseUp();
}

JSWindow.prototype.onMouseUp = function()
{
	document.body.onmouseup = this.saveMouseUp;
	document.body.onmousemove = this.saveMouseMove;
	document.body.jsWindow = null;
}


JSWindow.prototype.onMinimize = function()
{
  this.jsWindow.minimize();
}



JSWindow.prototype.minimize = function()
{
	// hide the content
	this.oContent.style.visibility = "hidden";
	this.oContent.style.position = "absolute";
	//document.body.appendChild(this.oContent);
	document.getElementById('cms').appendChild(this.oContent);
	
	this.oTable.deleteRow(1);
	
	// save current position
	this.saveX = this.oTable.style.left;
	this.saveY = this.oTable.style.top;
	
  // get the "window bar"
	if ( !window.jsWindowBar )
	{
		window.jsWindowBar = document.createElement("span");
	  document.body.appendChild(window.jsWindowBar);
	}
	
	window.jsWindowBar.appendChild(this.oTable);
	this.oTable.style.position = "static";
	this.oTable.style.left = "0px";
	this.oTable.style.top = "0px";
	
	this.oMinTD.innerHTML = "<img src='" + imageDir + "maximize.jpg'>";
	this.oMinTD.onmousedown = JSWindow.prototype.onMaximize;
	this.oTable.style.width = "220px";
  this.oTable.style.borderBottom = "0px";
	
}


JSWindow.prototype.onMaximize1 = function()
{
	this.jsWindow.maximize();
}

JSWindow.prototype.maximize1 = function()
{
	document.body.appendChild(this.oTable);
	this.oTable.style.position = "absolute";
	
	this.oTable.style.left = this.saveX;
	this.oTable.style.top = this.saveY;
	this.oTable.style.width = this.width + "px"
	this.oTable.style.borderBottom = "1px solid #000000";
	
	// add the content again.
	oTR = this.oTable.insertRow(1);
	
  this.oContentTD = oTR.insertCell(0);
	this.oContentTD.colSpan = 3;
	this.oContentTD.innerHTML = document.getElementById("Div" + this.id).innerHTML;
	
	//oTD.appendChild(this.oContent);
	this.oContent.style.position = "static";
	this.oContent.style.visibility = "visible";
	this.oContentTD.style.backgroundColor = this.bgcolor;
	this.oContentTD.className = "JSWindowContentStyle";
	
  this.oMinTD.style.paddingRight = "1px";	
	this.oMinTD.innerHTML = "<img src='" + imageDir + "minimize.jpg'>";
	this.oMinTD.onmousedown = JSWindow.prototype.onMinimize;

}

JSWindow.prototype.onMaximize1 = function()
{
	this.jsWindow.maximize();
}

JSWindow.prototype.close = function()
{	
	// remove from browser document
	this.oTable.parentNode.removeChild(this.oTable);
	//prepareeditor();
}

JSWindow.prototype.onClose = function()
{
	this.jsWindow.close();
}



/* ---------------------------------------------------------------------- *\
  Function    : hideDiv()
  Description : Hides all Divs on the page.
  Usage       : hideDiv([divNumber])
  Arguments   : divNumber - The number of Divs in the page that must be hidden
\* ---------------------------------------------------------------------- */

function hideDiv(divNumber) {
	for (var count = 1; count <= divNumber;) {
    document.getElementById('Div' + count).style.display = 'none';
		count++;
	}
}

function getWindow() {
	return Window;
}


/* ---------------------------------------------------------------------- *\
  Function    : createWindows()
  Description : determines if Window already exists, else calls JSWindow
  Usage       : createWindows([windowID], [width], "title")
  Arguments   : windowID - The <div> this window will use for its content
                width    - The default width of the window
                title    - The title of the window as displayed in the titlebar
\* ---------------------------------------------------------------------- */
var Window;
function createWindow(title, width, popupColor, windowID, minimizeIcon, x, y, modul)
{
if (document.getElementById('Window ' + windowID)) {
  }
else {
  Window = new JSWindow("&nbsp;" + title, document.getElementById("Div" + windowID), x, y, windowID, width, popupColor, minimizeIcon, modul); 
  return Window;
  }
}

