Uwd.System.Program = function(){
    
	var id = null;
	var name = null;
	var programFolder = null;
	var revision = null;
	var installTime = null;
	var mainFile = null;
	var viewPath = null;
	var backendPath = null;
	var iconClass = null;
	var windowWidth = null;
	var windowHeight = null;
	var windowIsResizable = null;
	var windowIsMaximizable = null;
	var windowIsMinimizable = null;
	var windowIsAutoscroll = null;
	var isSystemProgram = null;
	var isTool = null;
	var author = null;
	var description = null;
	var jsFiles = [];
	var cssFiles = [];
	var loaded = false;
	var isMultiple = false;
	
	
	// public methods
	this.setConfig = function(config, jsFiles) {
		this.instances = 0;
		Ext.apply(this, config);
		/*if (this.name === 'UWD Zip' || this.name === 'Datanode') {
			this.isMultiple = true;	
		}*/
		this.loaded = false;
	};

    this.getId = function(){
        return this.id;
    };
	
    this.getName = function(){
        return this.name;
    };
	
	this.getProgramFolder = function() {
		return this.programFolder;	
	};
	
	this.getRevision = function(){
        return this.revision;
    };

    this.getInstallTime = function(){
        return this.installTime;
    };
	
    this.getMainFile = function(){
        return this.mainFile;
    };
	
    this.getViewPath = function(){
        return this.viewPath;
    };
	
    this.getBackendPath = function(){
        return this.backendPath;
    };
	
    this.getIconClass = function(){
        return this.iconClass;
    };
	
	this.getWindowWidth = function() {
		return Number(this.windowWidth);
	};
	
	this.getWindowHeight = function() {
		return Number(this.windowHeight);
	};
	
	this.getWindowIsResizable = function() {
		return this.windowIsResizable === '0' ? false : true;
	};
	
	this.getWindowIsMaximizable = function() {
		return this.windowIsMaximizable === '0' ? false : true;
	};
	
	this.getWindowIsMinimizable = function() {
		return this.windowIsMinimizable === '0' ? false : true;
	};
	
	this.getWindowIsAutoScoll = function() {
		return this.windowIsAutoScroll === '0' ? false : true;
	};
	
	this.getIsSystemProgram = function() {
		return this.isSystemProgram === '1';
	};

	this.getIsTool = function() {
		return this.isTool === '1';
	};

	this.getAuthor = function() {
		return this.author;
	};

	this.getDescription = function() {
		return this.description;
	};
	
	this.getIsMultiple = function() {
		return this.isMultiple;	
	}
	
	this.getInstances = function() {
		return this.instances;	
	}
	
	this.openWindow = function(c) {
		if (!c) {
			var c = {};	
		}
		if (this.isMultiple == 1) {
			this.instances++;
			var id = this.getId() + '-' + this.getName() + '-' + this.instances;
		} else {
			var id = this.getId() + '-' + this.getName();
		}

		this.desktop = window.system.getDesktop();
		var win = this.desktop.getWindow(id);
		if(!win){
			var winClass = '';
			if (this.getName() === 'U-Sound') {
				winClass = Ext.ux.Desktop.FlashWindow;
			} else {
				winClass = Ext.Window;
			}

			win = this.desktop.createWindow({
				callConfig: c,
				id: id,
				title: this.getName(),
				loadMask: true,
				border: false,
				hideMode : 'visibility',
				width: typeof c.width != 'undefined' ? c.width : Number(this.getWindowWidth()),
				height: typeof c.height != 'undefined' ? c.height : Number(this.getWindowHeight()),
				cls: 'programWindow',
				iconCls: this.getIconClass(),
				shim:false,
				minimizable: this.getWindowIsMinimizable(),
				maximizable: typeof c.maximizable != 'undefined' ? c.maximizable : this.getWindowIsMaximizable(),
				resizable: this.getWindowIsResizable(),
				//animCollapse:true,
				constrainHeader:true,
				autoScroll: this.getWindowIsAutoScoll(),
				layout: 'fit',
				autoLoad: {
					url: this.getViewPath() + this.getMainFile(),
					scope: this,
					nocache: true,
					scripts: true
				}				
			}, winClass);
			/* determine context menu in program windows per default */
			win.getEl().on('contextmenu', function(e) {
				e.preventDefault();
				e.stopEvent();
			});
		}
		win.show();
		win.doLayout();
		return win;
	};
	
	this.loadIconCss = function() {
		 var sheetSource = this.getViewPath() + 'resources/' + window.system.getTheme() + '/css/icon.css';
		 var cssLink = window.document.createElement('link');
		 cssLink.setAttribute('rel', 'stylesheet');
		 cssLink.setAttribute('type', 'text/css');
		 cssLink.setAttribute('href', sheetSource);
		 window.document.getElementsByTagName('head')[0].appendChild(cssLink);
	};
	
	this.loadProgram = function() {
		this.loadAdditionalCss();
		this.loadAdditionalScripts();
		this.loaded = true;
	};
	
	this.loadAdditionalCss = function() {
		Ext.each(this.cssFiles, function(cssFile) {
			 var cssLink = window.document.createElement('link');
			 cssLink.setAttribute('rel', 'stylesheet');
			 cssLink.setAttribute('type', 'text/css');
			 cssLink.setAttribute('href', this.getViewPath() + 'resources/' + window.system.getTheme() + '/css/' + cssFile.name);
			 //alert(this.getViewPath() + 'resources/' + window.system.getTheme() + '/css/' + cssFile.name);
			 window.document.getElementsByTagName('head')[0].appendChild(cssLink);	
		}.createDelegate(this));
	};
	
	this.loadAdditionalScripts = function() {
		Ext.each(this.jsFiles, function(jsFile) {
			var scriptTag = window.document.createElement('script');
			scriptTag.setAttribute('rel', 'stylesheet');
			scriptTag.setAttribute('type', 'text/javascript');
			scriptTag.setAttribute('src', './' + this.getViewPath() + jsFile.name);
			window.document.getElementsByTagName('head')[0].appendChild(scriptTag);
		}.createDelegate(this));
	};
	
	this.isLoaded = function() {
		return this.loaded;
	};

};
