/**
 * Resource-Class
 */
Resource = function(url,type,clientid,name,description,width,height,dbid) 
{
	if(!url || !type) throw 'Resource: URL or type is null';
	var url = url;
	var type = type;
	var clientid;
	var name = name;
	var description = description;
	var height = height;
	var width = width;
	var dbid = dbid;
	
	this.getURL = function() { return url; }
	this.getType = function() { return type; }
	this.getName = function() { return name; }
	this.getDescription = function() { return description; }
	this.getHeight = function() { return hieght; }
	this.getWidth = function() { return width; }
	this.getDbId = function() { return dbid; }
	
	this.getElement = function(targetdocument) {
		if(targetdocument == null) throw 'Resource.getElement(targetdocument): targetdocument is null!';
		switch(type.toUpperCase()) {
			case 'GIF': case 'JPG': case 'JPEG': case 'PNG': {
				var image = targetdocument.createElement('IMG');
				image.src = url;
				if(width) image.width = width;
				if(height) image.height = height;
				if(clientid) image.id = clientid;
				return image;
			}
			case 'SWF': {
				var flash = targetdocument.createElement('EMBED');
				flash.src = url;
				if(clientid) flash.id = clientid;
				flash.type = 'application/x-shockwave-flash';
				flash.setAttribute('pluginspage','http://www.macromedia.com/go/getflashplayer');
				flash.quality = 'high';
				flash.wmode = 'transparent';
				return flash;
			}
			default : { // create a download link
				var lnk = targetdocument.createElement('A');
				lnk.href = url;
				if(clientid) lnk.id = clientid;
				lnk.target= "_blanc";
				lnk.appendChild(targetdocument.createTextNode(name));
				return lnk;
			}
		}		
	}
}