GE_Main.mapCSSToFn('homepage_rollover',
	function(el) {

		var imgEl = $(el);
		var offSrc = imgEl.src.toString().replace("off","on");
		var imgOnEl = new Element("img", {style:"position:absolute;top:0;left:0;display:none;", src:offSrc, alt:""});

		var pEl = imgEl.up();
		pEl.setStyle({position:"relative", display:"block"});
		pEl.appendChild(imgOnEl);

	   pEl.observe("mouseover", function(e) {
			if (GE_detectMouseEnter(this._p,e)) {
				new Effect.Appear(this._e, { duration: 0.1 });
			}
			e.stop();
      }.bindAsEventListener( { _p:pEl, _e:imgOnEl}));

      pEl.observe("mouseout", function(e) {
			if (GE_detectMouseLeave(this._p,e)) {
				new Effect.Fade(this._e, { duration: 0.1 });
			}
			e.stop();
      }.bindAsEventListener( { _p:pEl, _e:imgOnEl}));
   }
);


var GE_site_home = Class.create( {
	
	feature_enabled: false,
	header: null,
	content: null,
	footer: null,
	search: null,
	navigation: null,
	feature: null,
	secondary_feature: null,
	stock_quote: null,
	home_text: null,
	footer_logo: null,
	minisite_buttons: null,
	flash_url: null,
	flash_height: 0,
	flash_ver: 0,
	flash_bg: null,
	
	initialize: function() {
		// set variables for feature
		this.flash_url = featureFlashUrl; //'innovation/water/ge_water_feature.swf';
		this.flash_height = featureFlashHeight; //520;
		this.flash_ver = featureFlashVer; //'9';
		this.flash_bg = featureFlashBG; //'#ffffff';
		
		// collect global elements
		this.header = $('ge_header');
		this.content = $('ge_content').down('.primary_content');
		this.footer = $('ge_footer');

		// collect elements of home page
		this.search = $('ge_search');
		this.navigation = $('ge_navigation');
		this.feature_teaser = this.content.down('.feature');
		this.secondary_feature = this.content.down('.secondary_feature');
		this.stock_quote = this.content.down('.stock_quote');
		this.home_text = this.content.down('.home_text');
		this.footer_logo = this.footer.down('.olympics');

		// create feature elements
		this.minisite_buttons = new Element('div',{className:'minisite_buttons'});
		this.minisite_buttons
			.insert( new Element('a',{className:'button_link',title:'Innovation',href:GE_baselink+'innovation/index.html'}).insert( new Element('img',{src:GE_baselink+'html_view/images/btn_innovation.gif',alt:'Innovation'}) ) )
			.insert( new Element('a',{className:'button_link',title:'GE.com Home',href:GE_baselink+'index.html'}).observe('click',function(e){ e.stop(); this.toggle_view(); }.bind(this)).insert( new Element('img',{src:GE_baselink+'html_view/images/btn_gecom_home.gif',alt:'GE.com Home'}) ) )
			.setOpacity(0.0);
		this.feature_movie = new Element('div',{id:'ge_feature'}).hide();
		
		//hijack monogram behavior
		$('ge_header').down('a img').observe('click',function(e){ e.stop(); if (this.feature_enabled) this.toggle_view(); }.bind(this));
	},
	
	toggle_view: function() {
		// ------- redirect to feature page instead of transition
		document.location.href=GE_baselink+'innovation/masdar/index.html';
		return;
		// ------- end temp
		
		var h = this.get_homepage_effects();
		var f = this.get_feature_effects();
		if (this.feature_enabled) {
			this.load_homepage(h,f);
		} else {
			this.load_feature(h,f);
		}
	},
	
	load_feature: function(homepage_effects,feature_effects) {
		new Effect.Parallel(homepage_effects,{duration:0.8,afterFinish:
			function(){
				var effects = [];
				effects.push( this.o.get_content_resize(this.o.flash_height+36) );
				effects.push( this.o.get_content_position(-60) );
				new Effect.Parallel(effects,{
					duration:0.8,
					beforeStart:
						function(){
							$('ge_footer').setStyle({minHeight:'98px'});
						},
					afterFinish:
						function(){
							new Effect.Parallel(this.f,{duration:0.8,afterFinish:
								function(){
									this.feature_movie.setStyle({position:'relative',top:'-30px',paddingTop:'30px'}).show();
									this.feature_enabled = true;
								}.bind(this.o)
							});
						}.bind({o:this.o,f:this.f})
					}
				);
			}.bind({o:this,f:feature_effects})
		});
	},
	
	load_homepage: function(homepage_effects,feature_effects) {
		new Effect.Parallel(feature_effects,{duration:0.8,afterFinish:
			function(){
				var effects = [];
				effects.push( this.o.get_content_resize(523) );
				effects.push( this.o.get_content_position(0) );
				new Effect.Parallel(effects,{duration:0.8,afterFinish:
					function(){
						new Effect.Parallel(this.h,{duration:0.8,afterFinish:
							function(){
								$('ge_footer').setStyle({minHeight:'13px'});
								this.feature_enabled = false;
							}.bind(this.o)
						});
					}.bind({o:this.o,h:this.h})
				});
			}.bind({o:this,h:homepage_effects})
		});
	},
	
	get_homepage_effects: function() {
		var effects = new Array();
		if (this.feature_enabled) {
			if (this.search) effects.push( new Effect.Appear(this.search,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.header.insert({bottom:this.search}); }.bind(this)}) );
			if (this.navigation) effects.push( new Effect.Appear(this.navigation,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.navigation.setStyle({visibility:'visible'}).setOpacity(0.0) }.bind(this)}) );
			if (this.home_text) effects.push( new Effect.Appear(this.home_text,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.content.insert({bottom:this.home_text}); }.bind(this)}) );
			if (this.stock_quote) effects.push( new Effect.Appear(this.stock_quote,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.content.insert({bottom:this.stock_quote}); }.bind(this)}) );
			if (this.feature_teaser) effects.push( new Effect.Appear(this.feature_teaser,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.content.insert({bottom:this.feature_teaser}); }.bind(this)}) );
			if (this.secondary_feature) effects.push( new Effect.Appear(this.secondary_feature,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.content.insert({bottom:this.secondary_feature}); }.bind(this)}) );
			if (this.footer_logo) {
				effects.push( new Effect.Appear(this.footer_logo,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.footer.down('ul').insert({top:this.footer_logo}); }.bind(this)}) );
				effects.push( new Effect.Morph(this.footer_logo,{sync:true,style:'margin-left:0'}) );
			}
		} else {
			if (this.search) effects.push( new Effect.Appear(this.search,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.search.hide().setOpacity(0.0).remove(); }.bind(this)}) );
			if (this.navigation) effects.push( new Effect.Appear(this.navigation,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.navigation.setStyle({visibility:'hidden'}).setOpacity(1.0); }.bind(this)}) );
			if (this.home_text) effects.push( new Effect.Appear(this.home_text,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.home_text.hide().setOpacity(0.0).remove(); }.bind(this)}) );
			if (this.stock_quote) effects.push( new Effect.Appear(this.stock_quote,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.stock_quote.hide().setOpacity(0.0).remove(); }.bind(this)}) );
			if (this.feature_teaser) effects.push( new Effect.Appear(this.feature_teaser,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.feature_teaser.hide().setOpacity(0.0).remove(); }.bind(this)}) );
			if (this.secondary_feature) effects.push( new Effect.Appear(this.secondary_feature,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.secondary_feature.hide().setOpacity(0.0).remove(); }.bind(this)}) );
			if (this.footer_logo) {
				effects.push( new Effect.Appear(this.footer_logo,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.footer_logo.hide().setOpacity(0.0).remove(); }.bind(this)}) );
				effects.push( new Effect.Morph(this.footer_logo,{sync:true,style:'margin-left:-200px'}) );
			}
		}
		return effects;
	},
	
	get_feature_effects: function() {
		var effects = new Array();
		if (this.feature_enabled) {
			if (this.minisite_buttons) effects.push( new Effect.Appear(this.minisite_buttons,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.minisite_buttons.hide().setOpacity(0.0).remove(); }.bind(this)}) );
			if (this.feature_movie) effects.push( new Effect.Appear(this.feature_movie,{sync:true,from:1.0,to:0.0,afterFinish:function(){ this.feature_movie.hide().remove().setOpacity(1.0); }.bind(this)}) );
		} else {
			if (this.minisite_buttons) { effects.push( new Effect.Appear(this.minisite_buttons,{sync:true,from:0.0,to:1.0,beforeStart:function(){ this.header.insert({bottom:this.minisite_buttons}); }.bind(this)}) ); }
			if (this.feature_movie) {
				this.content.insert({bottom:this.feature_movie});

				var placeholderId = this.feature_movie.insert( new Element('div') ).down().identify() 

				var flashvars = {}; 
				flashvars.baselink = GE_baselink; 
				flashvars.o_switch = ( typeof(s_account) != 'undefined' ) ? s_account : 'ge-onesectheatre';
				// flashvars.o_switch=escape("staging"); 

				var params = {}; 
				params.bgcolor=this.flash_bg; 
				params.quality="high"; 
				params.salign="tl"; 
				params.wmode="opaque"; 

				var attributes = {}; 

				swfobject.embedSWF(GE_baselink+this.flash_url, placeholderId, "745", this.flash_height, this.flash_ver, null, flashvars, params, attributes); 

				/*var so = new SWFObject(GE_baselink+this.flash_url, 'movie', '745', this.flash_height, this.flash_ver, '#ffffff');
				so.addParam('quality','high');
				so.addParam('salign','tl');
				so.addParam('wmode','transparent');
				so.addVariable('baselink',GE_baselink);
				so.addVariable("o_switch",escape("staging"));
				so.write('ge_feature');*/
			}
		}
		return effects;
	},
	
	get_content_resize: function(h) {
		return new Effect.Morph('ge_content',{sync:true,style:'min-height:'+h+'px'});
	},
	
	get_content_position: function(h) {
		return new Effect.Morph('ge_content',{sync:true,style:'margin-top:'+h+'px'});
	}
	
});

GE_site_home._instance = null;
GE_site_home.getInstance = function() {
	if (GE_site_home._instance == null) GE_site_home._instance = new GE_site_home();
	return GE_site_home._instance;
}

function GE_site_home_flash_toggle() {
	sh = GE_site_home.getInstance();
	sh.toggle_view();
}