HOMISSMEFeatureController = new Class({
	
	initialize: function(version) {
		this.name = 'Feature';
		GLOBAL['zcounter'] = 10;
		this.self = this;
		this.Frame = $('frame_Featured');
		this.isFetching = false;
		this.isAnimating = false;
		this.currentView = 'PLAYLIST_IN_BACKGROUND';

		this.VideoController = new HOMISSMEVideoController();

		// TODO: these need to be fetched
		this.Feature_Titles = [
			'Alasdair McLellan<br>&lsquo;West End HOMISSME&rsquo;',
 			'Mert & Marcus<br>&lsquo;What Lies Beneath&rsquo;',
			'Ungaro<br>&lsquo;Cinq &Aacute; Sept&rsquo;'
			/*'Armani<br>&lsquo;Kind Of Blue&rsquo;'*/
 		];

		this.view = {
			title : $('Feature_Title'),
			home: $('Feature_Home_Button'),
			play : $('Feature_Play_Button'),
			nav : $('Feature_Navigation'),
			status: $('Feature_PlayerStatus'),
			archivebutton: $('Feature_Archive_Button'),
			archivetitle: $('Feature_Archive_Title'),
			videolines: $('videolines'),
			backtoplaylistbutton: $('Feature_Back_Button'),
			video_information_dialogue:  $('Feature_Information'),
			backinglayer : $('Feature_Backing_layer'),
 			hide : function(how, args) {
				var views = this;
 				if (args == undefined) var args = [];
				for (v in views) {
					if (args.some(function(item, index) {
						return item == v;
					})) continue;
					if (typeOf(views[v]) != "function") views[v].view(how);
					if (typeOf(views[v]) == "function" && v != 'hide') {
						var els = views[v]().view(how);
					}
				}
			}
		};
        
        this.currentVideoIndex = 0;
		this.subScene = '';
		this.timers = [];
		this.timer = '';
		this.timer.videoStatus = '';
		this.tCount = 0;
		this.FEATURE__totalcount = 2;
		js_fetch_feature_wall = false;
		this.modalScene = false;
	},

	PresentScene : function(fromscene) {
		Scene_Feature.subScene = null;
		
		this.setupEvents();
		this.showsubScene(Scene_Feature.subScene_FEATURES);
	},
 
 
 
 
	loadFlowPlayer: function() {
 
		// load flow player SWF
		this.VideoController.loadFlowPlayer();
	},

	loadBackground: function() {
		this.showsubScene(Scene_Feature.subScene_BACKGROUND);
	},

	showsubScene : function(scene) {
		if (Scene_Feature.subScene != scene) {
			if (Scene_Feature.subScene) {
				Scene_Feature.subScene.closeScene(scene);
			}
			if (Scene_Feature.modalScene) {
				Scene_Feature.modalScene.closeScene(scene);
				Scene_Feature.modalScene = false;
			}

			(Scene_Feature.subScene) = scene;
			Scene_Feature.subScene.PresentScene();
 
			switch (scene.name) {
				case 'subScene_SELECTEDFEATURE':
					break;

				case 'subScene_ARCHIVE':
					break;

				case 'subScene_FEATURES':
					break;

				default :
					break;
			}
		}
	},

	showmodalScene : function(modalScene, scene) {

		if (Scene_Feature.modalScene) {
			Scene_Feature.modalScene.closeScene(scene);
		}
		(Scene_Feature.modalScene) = modalScene;
		Scene_Feature.modalScene.PresentScene();

		if (scene) {
			switch (scene.name) {
				case 'subScene_SELECTEDFEATURE':
					break;

				case 'subScene_ARCHIVE':
					break;

				case 'subScene_FEATURES':
					break;

				default :
					break;
			}
		}
	},


		
	subScene_BACKGROUND: {
		name : 'subScene_BACKGROUND',

		PresentScene : function() {
			var parent = Scene_Feature;
 			this.view = {
				videolines : $('videolines')
			};
			this.view.hide = parent.view.hide;
			this.view.hide(1);
			
			Scene_Feature.currentVideoIndex = 0;
			Scene_Feature.VideoController.loadVideo_Backgrond_Playlist('startagain');
			this.Video.ref = this;
		},

		Video: {
			willBegin : function() { 
			},

			didStart : function() { 
                //so only if a video, play//
				//if($f("Feature_Video").getClip().extension != 'jpg') 
                if($f("Feature_Video").getClip().extension != 'jpg') Director.videoDidStartHandler();
  			},

			didPause : function() {
			},

			didResume : function() {
			},

			didFinish : function() {
			},

			willFinish : function() {
 				var self = this.ref; 
				Scene_Feature.currentVideoIndex ++;
				if (Scene_Feature.currentVideoIndex >= $f("Feature_Video").getPlaylist().length) {
                     Scene_Feature.currentVideoIndex = 0;
 					$f("Feature_Video").play();
				}
			},
			
			playlistDidChange : function(){
			}
		},
        
        sceneDidChangeVersion : function() {
            Scene_Feature.VideoController.loadVideo_Backgrond_Playlist('startover');
        },
     
		mouseIsSleeping : function() {
		},

		mouseIsActive : function() {
		},

 		sceneDidResize: function() {
		},

		closeScene : function() {
 			this.view.hide('out');
		}
	},














	subScene_FEATURES: {
		name : 'subScene_FEATURES',

		PresentScene : function() {
			var parent = Scene_Feature;
 
			this.view = {
				title : $('Feature_Title'),
				home: $('Feature_Home_Button'),
				play : $('Feature_Play_Button'),
				nav : $('Feature_Navigation'),
				archivebutton : $('Feature_Archive_Button'),
				videolines : $('videolines')
 			};

 			this.FEATURE__count = 0;
			this.Video.ref = this;
            var self = this;
			parent.VideoController.loadVideo_Playlist('startagain');
			this.LoadupPlaylistNavigation();
			this.presentNextInPlaylist();
			$f("Feature_Video").getPlugin("controls").hide(); 
			$f().setVolume(0);
 			this.PositionViews();
			this.view.hide = parent.view.hide;
 			this.view.play.setStyles({'background':"url('img/nav/navbits.png') -140px -270px"});
			 setTimeout(function(){    self.view.hide(1);   }, 1300);
            Scene_Feature.currentVideoIndex = 0;
			$('frame_Featured').setStyle("opacity", 1.0);
			$('Feature_Navigation').setStyle("opacity", 1.0);
			this.setupEvents();
		},

		PositionViews : function() {
			this.view.title.position();
			this.view.play.position({'offset':{x:0,y:180}});
		},

		LoadupPlaylistNavigation : function() {
			var parent = Scene_Feature;
			if ($$('#Feature_Navigation a').length > 0) {
				$$('#Feature_Navigation a').removeClass('Active');
				$$('#Feature_Navigation a')[parent.FEATURE__totalcount].addClass('Active');
				return;//already added radios//
			}

			for (var a = parent.FEATURE__totalcount; a >= 0; a--) {
				var controller = this;
				this.FEATURE__count++;
				var navIcon = new Element('a');

				navIcon.inject('Feature_Navigation', 'bottom');
				navIcon.index = a;
				navIcon.addEvent('click', function(event) {
					if (event) event.preventDefault();
					$$('#Feature_Navigation a').removeClass('Active');
					$$('#Feature_Navigation a').removeClass('Activestart');
					this.addClass('Active');
					controller.userDidPressRadioButton(this.index);
				});
				if (a == 0) navIcon.addClass('Active');
			}
		},

		userDidPressRadioButton : function(index) {
			$f("Feature_Video").play(index);
			Scene_Feature.currentVideoIndex = index;
			this.presentNextInPlaylist();
		},

		presentNextInPlaylist : function() {
			var parent = Scene_Feature;
			this.view.title.set('html', Scene_Feature.Feature_Titles[Scene_Feature.currentVideoIndex]);
			this.view.title.position();
			$$('#Feature_Navigation a').removeClass('Active');
			$$('#Feature_Navigation a')[Math.abs(Scene_Feature.currentVideoIndex - parent.FEATURE__totalcount)].addClass('Active');
		},

		Video : {
			ref : this,
 
			willBegin : function() {
                 var self = this.ref;
                setTimeout(function() {   self.presentNextInPlaylist(); },100);
			},

			didStart : function() {
                 if($f("Feature_Video").getClip().extension != 'jpg') Director.videoDidStartHandler();
  				
			},

			didPause : function() {
			},

			didResume : function() {
			},

			willFinish : function() {
				var self = this.ref;
				Scene_Feature.currentVideoIndex ++;
                if (Scene_Feature.currentVideoIndex >= $f("Feature_Video").getPlaylist().length) {
					Scene_Feature.currentVideoIndex = 0;
					$f("Feature_Video").play();
				}
			},

			didFinish : function() {

			},
			
			playlistDidChange : function(){}
 			
		},

        sceneDidChangeVersion : function() {
            Scene_Feature.VideoController.loadVideo_Playlist('startover');
        },
        
		userDidPressPlay: function() {
			Scene_Feature.subScene_SELECTEDFEATURE.passSelectedObject = {type:'video', url: featureplaylistfullurls[Scene_Feature.currentVideoIndex].url, 'scaling':'Scale' };
			Scene_Feature.showsubScene(Scene_Feature.subScene_SELECTEDFEATURE);
		},

		setupEvents : function() {
			var self = this;
			this.view.archivebutton.addEvent('click', function(event) {
				Scene_Feature.showmodalScene(Scene_Feature.modalScene_ARCHIVE, self);
			});
			this.view.play.addEvent('click', function(event) {
				if (event) {
					event.preventDefault();
				}
				self.userDidPressPlay();
			});

			this.view.home.addEvent('click', function(event){
 				if(event) event.preventDefault();
 				Director.featureCloseHandler();
				//Scene_Feature.showsubScene( Scene_Feature.subScene_BACKGROUND );
			});

		},

		mouseIsSleeping : function() {
		},

		mouseIsActive : function() {
		},


		RemoveEvents : function() {
			this.view.archivebutton.removeEvents();
			this.view.play.removeEvents();
			this.view.home.removeEvents();
		},

		sceneDidResize : function() {
			this.PositionViews();
		},

		closeScene : function() {
 			this.RemoveEvents();
			this.view.hide('out');
		}
	},




	
	subScene_SELECTEDFEATURE: {
		name : 'subScene_SELECTEDFEATURE',

		PresentScene : function() {
			var parent = Scene_Feature;
 
			this.view = {
				home: $('Feature_Home_Button'),
				play : $('Feature_Play_Button'),
				status: $('Feature_PlayerStatus'),
				backtoplaylistbutton : $('Feature_Back_Button'),
				video_information_dialogue :  $('Feature_Information'),
				backinglayer : $('Feature_Backing_layer')
			};
			this.Video.ref = this;
			this.view.hide = parent.view.hide;
			foo = this;
			this.setupEvents();
			this.processObject();

		},

		processObject : function() {
 			var obj = this.passSelectedObject;

			switch (obj.type.toLowerCase()) {
				case "video" :
					Scene_Feature.VideoController.loadVideo(obj);
					break;

				case "gallery" :
					Scene_Post.PresentScene();
					Scene_Post.showPostWithUrl(obj.url);
					break;
			}
		},

		Video :
		{
			ref : this,

			willBegin : function() {
				this.ref.view.status.set('html', 'Loading');
				this.ref.view.status.view('in');
 			},

			didStart : function() {
				//start playing//
				var scene = this;
				this.ref.view.status.set('html', 'Playing');
				this.ref.view.status.view('in').wait(500).chain(function() {
					this.element.view('out');
					$f("Feature_Video").setVolume(80);
				});
				this.ref.view.play.view('out');
				this.ref.view.backtoplaylistbutton.view('out');
			},

			didPause : function() {
				this.ref.view.status.set('html', 'Paused');
				this.ref.view.status.view('in').wait(500).chain(function() {
					this.element.view('out');
				});
				//this.ref.view.play.set('html', 'Resume');//TODO
				this.ref.view.play.setStyles({'background':"url('img/nav/navbits.png') -160px -309px"});
				this.ref.view.play.position({'offset':{x:0,y:-40}}).view('in');
				this.ref.view.backtoplaylistbutton.position({'offset':{x:0,y:20}}).view('in');
			},

			didResume : function() {
				this.ref.view.status.set('html', 'Playing');//TODO
 				this.ref.view.status.view('in').wait(500).chain(function() {
					this.element.view('out');
				});
				this.ref.view.play.view('out');
				this.ref.view.backtoplaylistbutton.view('out');
			},

			didFinish : function() {
				//this.ref.view.play.set('html', 'Play Again');//TODO
				this.ref.view.play.setStyles({'background':"url('img/nav/navbits.png') -173px -360px"});
 				this.ref.view.play.position({'offset':{x:0,y:-40}}).view('in');
				this.ref.view.backtoplaylistbutton.position({'offset':{x:0,y:20}}).view('in');
 			},

			willFinish : function() {
			},
			
			playlistDidChange : function(){}


		},


		userDidPressPlay: function() {
			Scene_Feature.VideoController.resumeVideo();
		},

		userDidPressBackToFeature : function() {
			Scene_Feature.showsubScene(Scene_Feature.subScene_FEATURES);
		},


		pauseFeature : function() {
		Scene_Feature.VideoController.pauseVideo();
		},

		resumeFeature : function() {
		Scene_Feature.VideoController.resumeVideo();
		},

		PositionViews : function() {
			this.view.play.position({'offset':{x:0,y:-40}});
			this.view.backtoplaylistbutton.position({'offset':{x:0,y:20}});
		},

		setupEvents : function() {
			var self = this;
			self.view.backtoplaylistbutton.addEvent('click', function(event) {
				if (event) {
					event.preventDefault();
			}
				self.userDidPressBackToFeature();
			});

			$$('.Post_CloseButton').addEvent('click', function(event) {
				if (event) {
					event.preventDefault();
				}
				if (Scene_Feature.isAnimating || Scene_Feature.isFetching) return;
			});

			this.view.play.addEvent('click', function(event) {
				if (event) {
					event.preventDefault();
				}
				self.userDidPressPlay();
			});
		},


		mouseIsSleeping : function() {
		//	this.view.home.view(0);
			this.view.backtoplaylistbutton.position({'offset':{x:0,y:0}}).view(0);
		},

		mouseIsActive : function() {
		//	this.view.home.view(1);
			this.view.backtoplaylistbutton.position({'offset':{x:0,y:0}}).view(1);
		},

		RemoveEvents : function() {
			this.view.backtoplaylistbutton.removeEvents();
			this.view.play.removeEvents('click');
			$$('.Post_CloseButton').removeEvents();
		},

		sceneDidResize : function() {
			this.PositionViews();
		},

		closeScene : function() {
 			this.RemoveEvents();
			this.view.hide('out');
		}
	},


















	modalScene_ARCHIVE: {
		name: 'modalScene_ARCHIVE',

		PresentScene : function() {
			var parent = Scene_Feature;
 			this.view = {
				archivebutton : $('Feature_Archive_Close_Button'),
				archivetitle : $('Feature_Archive_Title'),
				archiveleftbutton : $('Feature_Previous_Button'),
				archiverightbutton :   $('Feature_Next_Button'),
				backinglayer : $('Feature_Backing_layer'),
				wallArea : $('Feature-wall-area')
			};

			//FOR F ARCHIVE//
			this.currentPanelNum = 0;
			this.totalThumbnailsInOnePanel = 4;
			this.navigationRangeNum = 5;
			this.navigationMaxPanels = 10;

			this.view.wallArea.set('morph', {
				'link':'cancel',
				'onComplete': function() {
					Scene_Feature.isAnimating = false;
				},
				'onStart': function() {
					Scene_Feature.isAnimating = true;
				}
			});

			this.PositionViews();
			this.setupEvents();
			this.view.hide = parent.view.hide;
			this.view.hide(1);
			this.userDidPressPageNo(this.currentPanelNum);
			this.reConfigureEvents();
			this.repositionThumbs();

		},

		PositionViews : function() {
			this.view.wallArea.position();
		},


		userDidPressPageNo : function (panelNo) {

			if (panelNo == '++') {
				this.currentPanelNum++;
			} else
			if (panelNo == '--') {
				this.currentPanelNum--;
			} else
			if (panelNo != '++' && panelNo != '--') {
				this.currentPanelNum = panelNo;
			}

			var a = this.totalThumbnailsInOnePanel;
			var b = this.panelfurthestExtent;//ie 5,10,15,20

			if (this.currentPanelNum <= 0) {
				this.currentPanelNum = 0;
				this.view.archiveleftbutton.view(0);
			} else {
				this.view.archiveleftbutton.view(1);
			}
			if (this.currentPanelNum >= this.navigationMaxPanels - 1) {
				this.currentPanelNum = Math.max(this.navigationMaxPanels - 1, 0);
				this.view.archiverightbutton.view(0);
			} else {
				this.view.archiverightbutton.view(1);
			}

			this.view.wallArea.morph({'left': -(window.getSize().x * this.currentPanelNum) });
			if (this.doThumbNailsForPanelExist(this.currentPanelNum)) this.repositionThumbs();
		},


		doThumbNailsForPanelExist : function(panelNo) {
			var a = this.totalThumbnailsInOnePanel; //ie 18
			var b = this;
			var features = $$('.feature-item-container').filter(function(items, index) {
				return ( (items.indexer >= b.totalThumbnailsInOnePanel * panelNo) && (items.indexer < b.totalThumbnailsInOnePanel * (panelNo + 1)) );
			});// so return true if within panel index range
			if (features.length >= this.totalThumbnailsInOnePanel) return true;
			var c = $$('.feature-item-container').getLast();
			var lastElIndex = 0;
			if (c != undefined) lastElIndex = c.indexer + 1;
			var str_fromnumber = lastElIndex;
			this.go_fetch_thumbnails(str_fromnumber, ( ((a * panelNo) + a) - str_fromnumber), this.currentFilterTag);
			return false;
		},



		repositionThumbs: function() {

			//Work out how many we can fit//
			var self = this;
 
			var spacing = 50;
			var headerfooterexlusion = 0;
			var sideexlusion = 200;
			var h = 240 + spacing;
			var w = 350 + spacing;
			var col = Math.floor((window.getSize().x - sideexlusion) / w);
			var row = Math.floor((window.getSize().y - headerfooterexlusion) / h);
			row = 1;
			containerWidth = (window.getSize().x - sideexlusion) / col;
			containerHeight = h;
			this.oldelnum = this.currentPanelNum  * this.totalThumbnailsInOnePanel;

			//(RE)Position feature Thumbnails // 
			this.totalThumbnailsInOnePanel = (row * col);
			if (js_fetch_feature_wall) this.navigationMaxPanels = Math.ceil(js_fetch_feature_wall.elCount / this.totalThumbnailsInOnePanel);
			var newpanelextent = Math.floor($$('.feature-item-container').length / this.totalThumbnailsInOnePanel);
			this.currentPanelNum = Math.floor(this.oldelnum / this.totalThumbnailsInOnePanel);
  			if (this.currentPanelNum > newpanelextent) this.currentPanelNum = newpanelextent-1;
 
			var t = this.totalThumbnailsInOnePanel * this.totalThumbnailsInOnePanel;
			//$$('.feature-text-frame p').setStyles({'font-size':14,'line-height':15});
			$$('.feature-text-frame span').setStyles({'font-size':10,'line-height':1,'padding-top':0});
			var c = 0; //column if(panelNo) c = panelNo * this.totalThumbnailsInOnePanel;
			var r = 0;//row
			var p = 0;  //panel
			var pp = 0; //start panel
			p = 0;
 
			$$('.feature-item-container').each(function(feature, index) {

				featureimageWidth = 350;
				featureimageheight = 240; //0.683 ratio
				//size and position feature//
				if (feature.indexer == undefined) feature.indexer = feature.get('wallindex').toInt();
				feature.setStyles({'width': containerWidth});
				var featurepositionleft = ( (c % col) * containerWidth) + (window.getSize().x * Math.floor(feature.indexer / self.totalThumbnailsInOnePanel) + 100);
				var featurepositiontop = r * containerHeight;
				var hh = ((window.getSize().y - containerHeight * row) / 2) - 20;

 				feature.setStyles({'top':  0,'left':  featurepositionleft});
				feature.staticX = featurepositionleft;
				feature.staticY = 0;
				feature.getFirst().setStyles({'width': containerWidth,'height': featureimageheight});

	
				feature.getElements('.feature-item-img')[0].setStyles({
					'width':		 featureimageWidth,
					'height':	 featureimageheight,
					'margin-top':  -(featureimageheight * .5),
					'margin-left':  -(featureimageWidth * .5)
				});
				feature.getElements('.feature-text-container')[0].setStyles({
					'width':		 featureimageWidth,
					'margin-left':  -(featureimageWidth * .5),
					'height':		 featureimageheight,
					'margin-top': 0
				});
				feature.getElements('.feature-text-frame')[0].setStyles({'width': featureimageWidth });
				c++;
				if ((c % col) == 0 && c != 0) {
					r++;
				}
				if ((r % row) == 0 && r != 0) {
					r = 0;
					p++;
				}
			});
		},

		go_fetch_thumbnails: function(startNumber, fetchCount, typetag) {
			this.isFetching = true;
			spinner.show();
			var self = this;  
			var newhtml = new Request.HTML({url:'pullNextBatch.php','async':true,  
				'onSuccess':function(responseTree, responseElements, responseHTML, responseJavaScript) {
					self.didRecieveNewThumbnails(newhtml);
					Scene_Feature.isFetching = false;
				},

				'onFailure': function() {
					Scene_Feature.isFetching = false;
				}

			}).get({'s': startNumber,'fetchno':100 , 'typetag' :'lvefeature','newtagrequest':'true','mode':'feature' });
		},



		didRecieveNewThumbnails : function(newhtml) {
			var self = this;
 			$('Feature-wall-area').adopt(newhtml.response.tree);
			spinner.hide();

			self.repositionThumbs();
 			self.navigationMaxPanels = Math.ceil(js_fetch_feature_wall.elCount / self.totalThumbnailsInOnePanel);
			self.reConfigureEvents();
			Scene_Feature.isFetching = false;

		},


		reConfigureEvents  : function() {
			$$('.feature-item-container').removeEvents();
			$$('.feature-item-container').each(function(feature, index) {



				

				feature.addEvent('mouseover', function(event) {
					if (Scene_Feature.isFetching || Scene_Feature.isAnimating) return;
					feature.getElements('.feature-item-img')[0].setStyles({'opacity':0});
					feature.getElements('.feature-text-frame')[0].setStyles({'top':THUMBNAIL_HEIGHT * .5 });
				});

				feature.addEvent('mouseout', function(event) {
					if (Scene_Feature.isFetching || Scene_Feature.isAnimating) return;
					feature.getElements('.feature-item-img')[0].setStyles({'opacity':1});
					feature.getElements('.feature-text-frame')[0].setStyles({'top':300});
				});

				feature.addEvent('click', function(event) {
					if (Scene_Feature.isFetching || Scene_Feature.isAnimating) return;
					if (event) event.preventDefault();
					var elurl = this.get('wallurl');
					var eltype = this.get('walltype');

					//if a special url (ie gallery page) show modally
					if (eltype == 'video') {
						//get scaling mode attribute//
						var elscaling = this.get('viewmode'); 
						if(elscaling=='null') elscaling = 'Fit';
						Scene_Feature.subScene_SELECTEDFEATURE.passSelectedObject ={type:eltype,url:elurl,scaling:elscaling};
 						Scene_Feature.showsubScene(Scene_Feature.subScene_SELECTEDFEATURE);
					} else {
						Scene_Feature.subScene_SELECTEDFEATURE.passSelectedObject ={type:eltype,url:elurl};
						Scene_Feature.showmodalScene(Scene_Feature.subScene_SELECTEDFEATURE);
					}
					feature.getElements('.feature-item-img')[0].setStyles({'opacity':1});
					feature.getElements('.feature-text-frame')[0].setStyles({'top':300});
				});


				// add image load events
				feature.getElement("img").addEvent("load", function() {
					var postid = this.parentNode.parentNode.parentNode.getAttribute('featureid');
 					this.parentNode.parentNode.parentNode.set('morph', {
						duration: 1000,
						link: 'cancel'
					}).morph({
						opacity: [0, 1]
					});
				});
			});

		},


		setupEvents : function() {
			var self = this;

			// 'x' button on slideshow
			this.view.archivebutton.addEvent('click', function(event) {
				self.closeScene();
			});
			

			this.view.archiveleftbutton.addEvent('click', function(event) {
				if (event) {
					event.preventDefault();
				}
				if (Scene_Feature.isAnimating || Scene_Feature.isFetching) return;
				self.userDidPressPageNo('--');
			});

			this.view.archiverightbutton.addEvent('click', function(event) {
				if (event) {
					event.preventDefault();
				}
				if (Scene_Feature.isAnimating || Scene_Feature.isFetching) return;
				self.userDidPressPageNo('++');
			});

		},

		RemoveEvents : function() {
			this.view.archivebutton.removeEvents();
			this.view.archiveleftbutton.removeEvents();
			this.view.archiverightbutton.removeEvents();
			$$('.feature-item-container').removeEvents();
		},


		sceneDidResize : function() {
			this.PositionViews();
			this.repositionThumbs();
			this.userDidPressPageNo(this.currentPanelNum);
 
		},

		closeScene : function() {
 			this.RemoveEvents();
			this.view.hide(0);
		}
	},















	/* EVENTS */

	intervalcheck : function() {
 	},


	setupEvents :function() {

		MOUSESLEEPING = null;
		document.onmousemove = null;
		document.onmousemove = function(event) {
			var mouseevent = event || window.event;
			clearTimeout(MOUSESLEEPING);
			if (MOUSESLEEPING) MOUSESLEEPING = false;
			Scene_Feature.mouseIsActive();
			MOUSESLEEPING = setTimeout(function() {
				MOUSESLEEPING = true;
				Scene_Feature.mouseIsSleeping();
			}, 1000);
		}  


		$('Feature_Play_Button').addEvent('mouseover', function(event) {
			if (event) {
				event.preventDefault();
			}
			$('videolines').setStyles({'background-image':'url(library/features/dots.png)'});
		});


		$('Feature_Play_Button').addEvent('mouseout', function(event) {
			if (event) {
				event.preventDefault();
			}
			$('videolines').setStyles({'background-image':'url(library/features/dots.png)'});
		});

		$$('.hover').addEvent('mouseover', function(event) {
			if (event) {
				event.preventDefault();
			}
			this.view(1);
		});

		$$('.hover').addEvent('mouseout', function(event) {
			if (event) {
				event.preventDefault();
			}
			this.view(0.001);
		});

		//setInterval('Scene_Feature.intervalcheck()', 500);
	},


	removeEventsFromFeature : function() {
		document.onmousemove = null;
		window.onblur = null;
		window.onfocus = null;
		clearTimeout(MOUSESLEEPING);

		this.view.play.removeEvents();
		this.view.home.removeEvents();
		this.view.status.removeEvents();
		this.view.archivebutton.removeEvents();

		$$('.feature-item-container').removeEvents();
		$('Feature_Previous_Button').removeEvents();
		$('Feature_Next_Button').removeEvents();
		$$('.Post_CloseButton').removeEvents();
		$$('.hover').removeEvents();
	},

	/* SUBCLASSED METHODS*/

	directorDidRequestResize : function() {
		if (Scene_Feature.subScene) Scene_Feature.subScene.sceneDidResize();
		if (Scene_Feature.modalScene) Scene_Feature.modalScene.sceneDidResize();
		/*$('Feature_Video').setStyles({
			'width':window.getSize().x,
			'height':window.getSize().y
		});*/
	},

	directorDidChangeVersionControl : function(version) {
        if (Scene_Feature.subScene) Scene_Feature.subScene.sceneDidChangeVersion();
 
	},



	/* MOUSE CONTROL */
	mouseIsSleeping : function() {
		if ($f().isPlaying()) {
			Scene_Feature.subScene.mouseIsSleeping();

		}
	},

	mouseIsActive : function() {
		if ($f().isPlaying()) {
			Scene_Feature.subScene.mouseIsActive();
 		}
	},

	pauseFeature : function() {
		Scene_Feature.VideoController.pauseVideo();
	},

	resumeFeature : function() {
		Scene_Feature.VideoController.resumeVideo();
	},

	closeScene : function(fromScene) {
		//called from eventcontroller (clicking home button)
		for (timer in this.timers) {
			clearTimeout(timer);
		}

		if (Scene_Feature.subScene) {
			Scene_Feature.subScene.closeScene(fromScene);
		}
		if (Scene_Feature.modalScene) {
			Scene_Feature.modalScene.closeScene(fromScene);
			Scene_Feature.modalScene = false;
		}
		Scene_Feature.removeEventsFromFeature();
		Scene_Feature.showsubScene(Scene_Feature.subScene_BACKGROUND);
	}
});
