// ----------------------------------------
// CMSWebFTP.
// ----------------------------------------

var cmsWebFTP = null;

function CMSWebFTP(width,height)
{
	this.cmsWidth  = width;					// View-Breite
	this.cmsHeight = height;				// View-Hoehe
	this.cmsViewer = null;					// Viewer
	this.cmsGround = null;					// Hintergrund
		
// ----------------------------------------
// View zeigen.
// ----------------------------------------

	this.show = function()
	{
		var close,viewer,ground;
		var width,height;

		width							= this.cmsWidth;
		height							= this.cmsHeight;
		document.body.style.overflow	= "hidden";
		
		ground							= document.createElement("DIV");
		ground.style.width				= document.body.clientWidth;
		ground.style.height				= document.body.clientHeight;
		ground.style.backgroundColor	= "#000000";
		ground.style.opacity			= "0.7";
		ground.style.filter				= "alpha(opacity=70)";
		ground.style.position			= "absolute";
		ground.style.left				= document.body.scrollLeft;
		ground.style.top				= document.body.scrollTop;
		this.cmsGround					= ground;
	
		viewer							= document.createElement("DIV");
		viewer.style.width				= width;
		viewer.style.height				= height;
		viewer.style.backgroundColor	= "#353535";
		viewer.style.position			= "absolute";
		viewer.style.left				= document.body.scrollLeft + (document.body.clientWidth  - width) / 2;
		viewer.style.top				= document.body.scrollTop + 50;
		this.cmsViewer					= viewer;
							
		close							= document.createElement("IMG");
		close.style.right				= 6;
		close.style.top					= 6;
		close.onclick					= CMSCloseWebFTP;
		close.src						= "cmspages/images/close.png";
		close.style.position			= "absolute";	
		close.style.cursor				= "pointer";
		viewer.appendChild(close);
		
		this.createApplet(viewer);
		document.body.appendChild(ground);
		document.body.appendChild(viewer);
	} 
	
// ----------------------------------------
// Previews erstellen.
// ----------------------------------------

	this.createApplet = function(viewer)
	{
		var applet, param;
		
		applet				  = document.createElement("APPLET");
		applet.name			  = "FTP Webclient";
		applet.code			  = "webftp.core.WFApplet";
		applet.archive		  = "cmslibs/DSPApplets/WebFTP.jar";
		applet.style.width	  = this.cmsWidth  + "px";
		applet.style.height   = (this.cmsHeight - 20) + "px";
		applet.style.top	  = "30px";
		applet.style.left	  = "0px";
		applet.style.position = "absolute";
		applet.alt		= "Java is not available, please install Java: http://www.java.com";

		param 		= document.createElement("PARAM");
		param.name 	= "codebase_lookup";
		param.value 	= "false";
		applet.appendChild(param);
		
		viewer.appendChild(applet);
	}
	
// ----------------------------------------
// View schliessen.
// ----------------------------------------

	this.close = function()
	{
		this.cmsGround.parentNode.removeChild(this.cmsGround);
		this.cmsGround = null;
		this.cmsViewer.parentNode.removeChild(this.cmsViewer);
		this.cmsViewer = null;
	}
}

// ----------------------------------------
// Viewer anzeigen.
// ----------------------------------------

function CMSCloseWebFTP()
{
	cmsWebFTP.close();
	document.body.style.overflow = "auto";
}

// ----------------------------------------
// ShowWebFTP.
// ----------------------------------------

function CMSShowWebFTP(width,height)
{
	cmsWebFTP = new CMSWebFTP(width,height);	
	cmsWebFTP.show();
}
