

ScreenCollection : {

	/* ScreenCollection contructor */
	function ScreenCollection (name) {
		this.name = name;
		this.activeScreenIndex = 0;
		
		this.M_Screen_Data = eval('window.' + this.name + '_M_Screen_Data');
		this.BB_Screen_Data = eval('window.' + this.name + '_BB_Screen_Data');
		this.Z_Screen_Data = eval('window.' + this.name + '_Z_Screen_Data');
		
		
		this.max = this.M_Screen_Data.length;
		this.monitorScreens = new Array();
		this.blackBoxScreens = new Array();
		this.zoomScreens = new Array();
		
		this.createScreens();
		
		// store the collection in an array
		if (!ScreenCollection.collections) { ScreenCollection.collections = new Array() }
		this.collectionIndex = ScreenCollection.collections.length;
		ScreenCollection.collections[this.collectionIndex] = this;
		
		// also store the collection as a property
		ScreenCollection[this.name] = this;
		
		
	}


	/* class variables */
	ScreenCollection.M_Screen_X_Offset = 304;
	ScreenCollection.M_Screen_Y_Offset = 38;
	ScreenCollection.BB_Screen_X_Offset = 5;
	ScreenCollection.BB_Screen_Y_Offset = 255;
	ScreenCollection.Z_Screen_X_Offset = 41;
	ScreenCollection.Z_Screen_Y_Offset = 68;
	
	ScreenCollection.Layer_Index = 10;
	
	ScreenCollection.activeCollection = null;
	
	/* class methods */
	ScreenCollection.getBrowserWidth  = function () { return EasyDyn.getBrowserWidth() };
	ScreenCollection.getBrowserHeight = function () { return EasyDyn.getBrowserHeight() };
	ScreenCollection.initCoords = function () {

		ScreenCollection.Base_X = (ScreenCollection.getBrowserWidth() - 574) / 2 ;
		ScreenCollection.Base_Y = (ScreenCollection.getBrowserHeight() - 434) / 2 ;
		//alert(ScreenCollection.Base_X + ":" + ScreenCollection.Base_Y);
		ScreenCollection.M_Screen_X = ScreenCollection.Base_X + ScreenCollection.M_Screen_X_Offset;
		ScreenCollection.M_Screen_Y = ScreenCollection.Base_Y + ScreenCollection.M_Screen_Y_Offset;
		
		ScreenCollection.BB_Screen_X = ScreenCollection.Base_X + ScreenCollection.BB_Screen_X_Offset;
		ScreenCollection.BB_Screen_Y = ScreenCollection.Base_Y + ScreenCollection.BB_Screen_Y_Offset;
		
		ScreenCollection.Z_Screen_X = ScreenCollection.Base_X + ScreenCollection.Z_Screen_X_Offset;
		ScreenCollection.Z_Screen_Y = ScreenCollection.Base_Y + ScreenCollection.Z_Screen_Y_Offset;
	}
	
	ScreenCollection.jumpToCollection = function (name) {
		thisCollection = eval('ScreenCollection[\'' + name + '\']');
		//alert(thisCollection);
		// hide old collection?
		ScreenCollection.activeCollection.collapse();
		ScreenCollection.activeCollection = thisCollection;
		thisCollection.start();
		if(thisCollection.monitorScreens.length > 1) {
			playCloseEncounters();	
		}
	}
	
	
	
	/* instance methods */
	// init methods
	ScreenCollection.prototype.createScreens = function () {
		for (var i = 0;i < this.max;i++) {
			this.monitorScreens[i] = new Screen(this.M_Screen_Data[i]);
			this.blackBoxScreens[i] = new Screen(this.BB_Screen_Data[i]);
			if (this.Z_Screen_Data) {
				this.zoomScreens[i] = new Screen(this.Z_Screen_Data[i]);
			}
		}
	}
	
	ScreenCollection.prototype.initScreens = function () {
		for (var i = 0;i < this.max;i++) {
			this.initMScreens(++ScreenCollection.Layer_Index);
			this.initBBScreens(++ScreenCollection.Layer_Index);
			if (this.zoomScreens.length > 0) {
				this.initZScreens(++ScreenCollection.Layer_Index);
			}
		}
	}
	
	ScreenCollection.prototype.initMScreens = function (counter) {
		for (var i = 0;i < this.max;i++) {
			this.monitorScreens[i].setZ(i + counter);
			this.monitorScreens[i].moveToXY(ScreenCollection.M_Screen_X, ScreenCollection.M_Screen_Y);
			//this.monitorScreens[i].show();
		}
	}
	
	ScreenCollection.prototype.initBBScreens = function (counter) {
		for (var i = 0;i < this.max;i++) {
			this.blackBoxScreens[i].setZ(i + counter);
			this.blackBoxScreens[i].moveToXY(ScreenCollection.BB_Screen_X, ScreenCollection.BB_Screen_Y);
			//this.blackBoxScreens[i].show();
		}
	}
	
	ScreenCollection.prototype.initZScreens = function (counter) {
		for (var i = 0;i < this.max;i++) {
			this.zoomScreens[i].setZ(i + counter);
			this.zoomScreens[i].moveToXY(ScreenCollection.Z_Screen_X, ScreenCollection.Z_Screen_Y);
			//this.zoomScreens[i].show();
		}
	}
	
	// navigation methods
	ScreenCollection.prototype.start = function () {
		this.activeScreenIndex = 0;
		this.monitorScreens[this.activeScreenIndex].show();
		this.blackBoxScreens[this.activeScreenIndex].show();
		
	}
	
	ScreenCollection.prototype.collapse = function () {
		for (var i=0; i < this.max; i++) {
			this.monitorScreens[i].hide();
			this.blackBoxScreens[i].hide();
		}		
	}
	
	ScreenCollection.prototype.next = function () {
		this.previousScreenIndex = this.activeScreenIndex++;
		if (this.activeScreenIndex > (this.max - 1)) { this.activeScreenIndex = 0; }
		this.monitorScreens[this.previousScreenIndex].hide();
		this.blackBoxScreens[this.previousScreenIndex].hide();
		this.monitorScreens[this.activeScreenIndex].show();
		this.blackBoxScreens[this.activeScreenIndex].show();
	}
	
	ScreenCollection.prototype.previous = function () {
		this.nextScreenIndex = this.activeScreenIndex--;
		if (this.activeScreenIndex < 0) { this.activeScreenIndex = (this.max - 1); }
		this.monitorScreens[this.nextScreenIndex].hide();
		this.blackBoxScreens[this.nextScreenIndex].hide();
		this.monitorScreens[this.activeScreenIndex].show();
		this.blackBoxScreens[this.activeScreenIndex].show();
	}
	
	
	ScreenCollection.prototype.zoomNext = function () {
		this.previousScreenIndex = this.activeScreenIndex++;
		if (this.activeScreenIndex > (this.max - 1)) { this.activeScreenIndex = 0; }
		this.zoomScreens[this.previousScreenIndex].hide();
		this.zoomScreens[this.activeScreenIndex].show();
	}
	
	ScreenCollection.prototype.zoomPrevious = function () {
		this.nextScreenIndex = this.activeScreenIndex--;
		if (this.activeScreenIndex < 0) { this.activeScreenIndex = (this.max - 1); }
		this.zoomScreens[this.nextScreenIndex].hide();
		this.zoomScreens[this.activeScreenIndex].show();
	}
	
	ScreenCollection.prototype.zoom = function () {
		if (this.zoomScreens.length > 0) {
			window.document.bgColor  = '#2F3093';
			this.monitorScreens[this.activeScreenIndex].hide();
			this.blackBoxScreens[this.activeScreenIndex].hide();
			ScreenCollection.zoomLayer.show();
			this.zoomScreens[this.activeScreenIndex].show();
		}
	}
	
	ScreenCollection.prototype.telescope = function () {
		window.document.bgColor = '#FFFFFF';
		this.zoomScreens[this.activeScreenIndex].hide();
		ScreenCollection.zoomLayer.hide();
		this.monitorScreens[this.activeScreenIndex].show();
		this.blackBoxScreens[this.activeScreenIndex].show();
	}

	
}



Screen : {

	/* Screen constructor */
	/* inherits from EasyDyn
	function EasyDyn(id, winRef,text, visibility,
					 width,x, y, fontFamily, fontSize, fontWeight,
					  bgColor, color, borderColor,
					   borderWidth, borderStyle, padding)
	
	*/	
	function Screen (data) {
		this.base = EasyDyn;
		//alert(data.id)
		this.base(data.id, window, data.text, 'hidden',
			data.width, 0, 0, data.fontFamily, 
			data.fontSize, data.fontWeight,
			data.bgcolor, data.color,null,
			null,null,'0px');
	
	}

	Screen.prototype = new EasyDyn; //inherits from EasyDyn
}




