			HOMISSMEScenePostController = new Class({
				initialize: function($director, version) {
					this.director = $director;
					this.name = 'Post';

					GLOBAL['zcounter'] = 30;
					this.otherFrame = $('frame_post_' + 1);
					this.targetFrame = $('frame_post_' + 2);
					this.currentPostID;
					this.filter = 'lvedaily';
					$$('.Post_CloseButton').view('hide');

					// Morphs
					this.frame1FX = new Fx.Morph("frame_post_1", {
						duration: (new HOMISSMESettings).PAGE_TRANSITION_DURATION,
						link: 'cancel',
//						frameSkip: 'false',
						transition: (new HOMISSMESettings).PAGE_TRANSITION_TYPE
					});

					this.frame2FX = new Fx.Morph("frame_post_2", {
						duration: (new HOMISSMESettings).PAGE_TRANSITION_DURATION,
						link: 'cancel',
//						frameSkip: 'false',
						transition: (new HOMISSMESettings).PAGE_TRANSITION_TYPE
					});
					
					this.otherFrame = $('frame_post_' + 1);
					this.targetFrame = $('frame_post_' + 2);
					
					this.otherFrame.set('morph',{
						duration: (new HOMISSMESettings).PAGE_TRANSITION_DURATION,
						link: 'cancel',
 						transition: (new HOMISSMESettings).PAGE_TRANSITION_TYPE
					});
					
					this.targetFrame.set('morph',{
						duration: (new HOMISSMESettings).PAGE_TRANSITION_DURATION,
						link: 'cancel',
 						transition: (new HOMISSMESettings).PAGE_TRANSITION_TYPE
					});

 					this.isAnimating = false;
                    this.browserFixNeeded = false;
                     //BROWSER FIX//
                    if(Browser.safari && navigator.userAgent.contains('5.0.3')) this.browserFixNeeded = true;
                    if(Browser.safari4) this.browserFixNeeded = true;

					this.isActive = false;
     
				},


				PresentScene : function($scene) {
					//console.log("HOMISSMEPostController.PresentScene()");
 				},


			
			
				showPost: function($postid) {
					//console.log("HOMISSMEPostController.showPost($postid): " + $postid);
					this.otherFrame.get('morph').cancel();
					this.targetFrame.get('morph').cancel();
                    //if(Scene_Post.isAnimating) return;
					Scene_Post.isActive = true;
   					$$('.Post_CloseButton').view('hide');
 					Scene_Wall.firstPost = true;
					
 					var arg1 ='';
					
					if (Scene_Wall.isSearching) {
						Scene_Post.filter = 'search';
						arg1 = Scene_Wall.currentSearchString;
						if(Director.currentScene.name == "Archive") Scene_Post.filter = 'lveDaily';
					} else {
						Scene_Post.filter = 'lveDaily';
						if(Scene_Wall.currentFilterTag) Scene_Post.filter = Scene_Wall.currentFilterTag;
						if(Director.currentScene && Director.currentScene.name == "Archive") Scene_Post.filter = 'lveDaily';
					}
					
					var temp = this.otherFrame;
					this.otherFrame = this.targetFrame;
					this.targetFrame = temp;
					var windowurlquery = "pages/pagetemplate.php?id=" + $postid + "&filter=" + Scene_Post.filter + "&arg1=" + arg1;
					spinner.show();
  					this.targetFrame.getElements('iframe')[0].contentWindow.location.replace( windowurlquery );
                    if(Director.currentScene && Director.currentScene.name == "Wall"){
                        //console.log('---------fromwall-------');
                        this.frameReady($postid);//this is so the animation is in sync with the wall
                    }
                    if(Scene_Post.browserFixNeeded) Scene_Post.browserFix_start();
  					
				},  


				showPostWithUrl: function(url) {
 					//if(Scene_Post.isAnimating) return;
                    Scene_Post.isActive = true;
					Scene_Post.directorDidRequestResize();
					this.otherFrame = $('frame_post_' + 1);
					this.targetFrame = $('frame_post_' + 2);
 					
					this.targetFrame.setStyles({'z-index': 81 });
					this.otherFrame.setStyles({'z-index': 50 });
					
 					this.targetFrame.getElements('iframe')[0].contentWindow.location.replace(url);
 					this.targetFrame.getElements('iframe')[0].addEvent('load:once', function() {
						$$('.Post_CloseButton').view('show');
						$$('.Post_CloseButton').removeEvents();
						$$('.Post_CloseButton').addEvent('click', function() {
							Scene_Post.closeScene();
						});
					});
					this.frameReady(1, 'snap');
				},




				frameReady : function(index,fromIFrame) {
					//console.log("HOMISSMEPostController.frameReady(): " + index +", ");
					if(fromIFrame) spinner.kill();
                    if(index == this.currentPostID) return;
                    this.isAnimating = true;
                    var seq;
                    if(Director.currentScene && Director.currentScene.name == "Wall") seq = 'fromWall';
 					var targetFrame = this.targetFrame;
					var otherFrame = this.otherFrame;

					var sequence;
 					if(this.currentPostID && this.currentPostID < index) sequence = 'slideDown';
					if(this.currentPostID && this.currentPostID == -1) sequence = 'fadein';
					if(this.currentPostID && this.currentPostID > index) sequence = 'slideUp';
					if(!this.currentPostID) sequence = 'fadein';
					if ( seq ) sequence  = seq;
                    if(Director.version=='Low') sequence = 'fadein';
 
					this.currentPostID = index;
   					switch(sequence){
					
						case 'fromWall': 
                            //console.warn('fromWall');
 								targetFrame.setStyles({
									'left':0,
									'top':window.getSize().y + 25,
									'visibility':'visible',
									'z-index': 81,
									'height': window.getSize().y + 25
								}).view('show');
                                
   								targetFrame.morph({
 									'top':-25
 								}).chain(function(){ 
                                    Scene_Post.isAnimating = false; 
                                    if(Scene_Post.browserFixNeeded) Scene_Post.browserFix_end();
                                });  
                                                            
 							break;
							
						case 'fadein':
                                   //console.warn('fadein');
  								otherFrame.setStyles({'top': -25,'z-index':50 });
								otherFrame.view('show');
								var blankurl = "pageblank.php";
								Scene_Post.otherFrame.getElements('iframe')[0].contentWindow.location.replace( "pageblank.php" );
																
 								targetFrame.setStyles({
									'left':0,
									'top':-25,
									'visibility':'visible',
									'z-index': 81,
									'height': window.getSize().y + 25
								}).view('in').chain(function(){  
									Scene_Post.isAnimating = false;
								});
			
                                if(Scene_Post.browserFixNeeded) Scene_Post.browserFix_end();
							break;
						
						case 'slideUp':
                            //console.warn('slideUp');
                            
								Scene_Post.isAnimating = true;
								otherFrame.setStyles({'z-index':50,'top':-25}).view('show');
								otherFrame.morph({'top': -(window.getSize().y * .5) });
								Scene_Wall.firstPost = false;
  									
								targetFrame.setStyles({
									'left':0,
									'top':window.getSize().y,
									'visibility':'visible',
									'z-index': 81,
									'height': window.getSize().y + 25
								});
								targetFrame.view('show');
 
								targetFrame.morph({
									'top': -25
                                    
								}).chain(function(){
                                
									Scene_Post.isAnimating = false;
									var blankurl = "pageblank.php";
									Scene_Post.otherFrame.getElements('iframe')[0].contentWindow.location.replace( blankurl );
                                    if(Scene_Post.browserFixNeeded) Scene_Post.browserFix_end();

 
								});
								
 							break;
						
						case 'slideDown':
							//console.warn('slideDown');

 							Scene_Post.isAnimating = true;

 							targetFrame.setStyles({'top':-(window.getSize().y * .5),'height': window.getSize().y + 25}).view('show');
 
							targetFrame.morph({
								'top':-25
							}).chain(function(){
								this.element.setStyles({'z-index':81});
							});
							

							otherFrame.morph({
								'top': window.getSize().y
                                
							}).chain(function(){
                            
								this.element.setStyles({
									'z-index':50
								});
								this.element.view('hide');
								Scene_Post.isAnimating = false;
								//console.log('done;');
								var blankurl = "pages/pageblank.php?";
								Scene_Post.otherFrame.getElements('iframe')[0].contentWindow.location.replace(blankurl);
                                if(Scene_Post.browserFixNeeded) Scene_Post.browserFix_end();
                                
                                
							});
							
							break;
						
						default:
							Scene_Post.isAnimating = false;
						break;
					}
					
 					Scene_Wall.firstPost = false;
				},























				directorDidRequestResize : function() {
					Scene_Post.targetFrame.setStyles({ 'height': window.getSize().y + 25 });
 					Scene_Post.otherFrame.setStyles({ 'height': window.getSize().y + 25 });
                    $$('.frame_iframes').setStyles({'height':window.getSize().y});
 
 				},

				directorDidChangeVersionControl : function(version) {
				},



				closeScene : function() {
 					
					Scene_Post.otherFrame.get('morph').start({
						'top': [0, window.getSize().y]
					}).chain(function() {
 						Scene_Post.currentPostID = -1;
						Scene_Post.targetFrame.view('hide');
 						Scene_Post.otherFrame.view('hide');
						Scene_Post.isActive = false;
 						Scene_Post.isAnimating = false;
						var windowurlquery = "pages/pageblank.php?";
						Scene_Post.targetFrame.getElements('iframe')[0].contentWindow.location.replace( windowurlquery );
						Scene_Post.otherFrame.getElements('iframe')[0].contentWindow.location.replace( windowurlquery );
					});

					Scene_Post.targetFrame.get('morph').start({
						'top': [0, window.getSize().y]
					});
				},
                
                
                
                
                        //BROWSER FIX

                browserFix_start : function()
                {
                  $$('.frame_iframes').setStyles({'height':''});

                },

 
                browserFix_end : function()
                {
                  $$('.frame_iframes').setStyles({'height':window.getSize().y});

                }



});
			
			
			
			
		 
