// Neue Klasse: Popup

// var popup = new Popup(site,preview)
//	popup.pop(12,100,100)



// Konstruktor!
function Popup(site, preview, className)
{
	// Eigenschaften
	this.site 				= site;
	this.preview 			= preview;
	this.className 			= className;
	this.componentId 		;
	this.srcWidth 			;
	this.srcHeight 			;
	this.path 				;
	this.params 			;
	this.filename			= "popup.php";
	this.name 				= "myPopup";

}

// Methoden
Popup.prototype.init		= function(componentId, srcWidth, srcHeight)
{
	var scrollbarWidth 		= 20;
	var myWidth 			= screen.width;
	var myHeight 			= screen.height;
	var myPreview 			= '&preview='+this.preview
	var myClass				= '&className='+this.className
	var hasScrollbar 		= '';

	// Bildgroesse > Fenstergroesse
	if (srcWidth > myWidth){
		srcWidth = myWidth + scrollbarWidth;
		hasScrollbar 		= ',scrollbars=yes,'
	}
	if (srcHeight > myHeight){
		srcHeight = myHeight;
	}

	this.name 				+= "_"+componentId;
	this.params 			= 'width='+srcWidth+',height='+srcHeight+hasScrollbar+',resizable=yes';
	this.path				= '/'+this.filename+'?id_component='+componentId+myPreview+myClass;//'/'+this.site+
}

Popup.prototype.pop 		= function(componentId, srcWidth, srcHeight)
{
	this.init(componentId, srcWidth, srcHeight);
	var p 					= window.open(this.path, this.name, this.params);
	p.focus();
}

Popup.prototype.popAsHTML	= function(componentId, srcWidth, srcHeight)
{
	this.init(componentId, srcWidth, srcHeight);
	var p 					= window.open("", this.name, this.params);
	with(p)	{
		document.write(this.getContent());
		document.close();
		focus();
	}
}

Popup.prototype.getContent	= function(){
	return '<html><head><title>IMAGE</title></head><body style="margin:0"><img border="0" onclick="window.close();" src="'+ this.path +'" title="click to close"></body></html>';
}

Popup.prototype.setName 	= function(popup_name){
	this.name				= popup_name;
}

Popup.prototype.setFilename = function(file_name){
	this.filename			= file_name;
}

Popup.prototype.setSite 	= function(site){
	this.site				= site;
}

Popup.prototype.setPreview 	= function(preview){
	this.preview			= preview;
}


