window.addEvent('domready', function() {
	
	
/* slide panel */
	if($('slide_panel')) {
		
		var slide;
		slide = $('slide');
	
	
		var slided;
		slided = false;
	
		slide_in = new Fx.Morph(slide, {duration: '750', link: 'cancel', transition: 'expo:out'});
		
	
		$('info_slide_start').addEvents({
			'mouseenter': function(){
				if(!slided){
					slide_in.start({
						'top': 0
					});
				}
				slided = true;					
			},
			'mouseleave': function(){
				/*
				slide_in.start({
					'top': 520
				});
				slided = false;
				*/
			}
		});	
		
	}
	
	if($('slide_panel')) {
		slide.addEvent('mouseleave',function() {
			slide_in.start({
				'top': 520
			});
			slided = false;
		});	
	}
	
	if($('invisible_panel_closer')) {
		$('invisible_panel_closer').addEvent('mouseleave',function() {
			slide_in.start({
				'top': 520
			});
			slided = false;
		});	
	}
	
/* white info bar slider */
	if($('white_info_bar')){
		
		$('white_info_bar').setStyle('right',-600);
		
		info_in = new Fx.Morph($('white_info_bar'), {duration: '750', link: 'cancel', transition: 'expo:out'});		
		
	
		$('white_info_bar_slide').addEvents({
			'mouseenter': function(){				
				info_in.start({
					'right': 0,
					'opacity': [0,1]
				})
				$('white_info_bar_background').setStyle('visibility','hidden');
			},
			'mouseleave': function(){
				info_in.start({
					'right': -600,
					'opacity': [1,0]
				});
				$('white_info_bar_background').setStyle('visibility','visible');				
			}		
		})
	}
	
	
	
/* list hover showing arrow */

	var lis;
	lis = $('final_nav').getElements('li');	
	
	lis.each(function(el) {
		if(!el.hasClass('on')) {
			el.addEvents({
				'mouseenter': function() {
					el.addClass('active');
				},
				'mouseleave': function() {					
					el.removeClass('active');					
				}
			})	
		}			
	})
	
	

/*  scroll lists with image rollover  */

	$('lifestyle_scroll_up').addEvents({
		'mouseenter': function() {
			scroll_up($('final_nav_lifestyle_content').id);
			this.src="/images/scroll_up_on.gif";
			$clear(revert);	
		},
		'mouseleave': function() {
			$clear(scroller_up);
			this.src="/images/scroll_up.gif";
			revertTimer();
		}
	},this);
	
	$('lifestyle_scroll_down').addEvents({
		'mouseenter': function() {
			scroll_down($('final_nav_lifestyle_content').id);
			this.src="/images/scroll_down_on.gif";
			$clear(revert);
		},
		'mouseleave': function() {
			$clear(scroller_down);
			this.src="/images/scroll_down.gif";
			revertTimer();
		}
	});
	
		$('residential_scroll_up').addEvents({
		'mouseenter': function() {
			scroll_up($('final_nav_residential_content').id);
			this.src="/images/scroll_up_on.gif";
			$clear(revert);	
		},
		'mouseleave': function() {
			$clear(scroller_up);
			this.src="/images/scroll_up.gif";
			revertTimer();
		}
	},this);
	
	$('residential_scroll_down').addEvents({
		'mouseenter': function() {
			scroll_down($('final_nav_residential_content').id);
			this.src="/images/scroll_down_on.gif";
			$clear(revert);
		},
		'mouseleave': function() {
			$clear(scroller_down);
			this.src="/images/scroll_down.gif";
			revertTimer();
		}
	});
	
	
	
if($chk($('multi_scroll_up'))){
	$('multi_scroll_up').addEvents({
		'mouseenter': function() {
			scroll_up($('final_nav_multi_content').id);
			this.src="/images/scroll_up_on.gif";
			$clear(scroller_down);
		},
		'mouseleave': function() {
			$clear(scroller_up);
			this.src="/images/scroll_up.gif";
			revertTimer();
		}
	},this);

	$('multi_scroll_down').addEvents({
		'mouseenter': function() {
			scroll_down($('final_nav_multi_content').id);
			this.src="/images/scroll_down_on.gif";
			$clear(scroller_down);
		},
		'mouseleave': function() {
			$clear(scroller_down);
			this.src="/images/scroll_down.gif";
			revertTimer();
		}
	});
}
	
	
	
	
	
	
	
	
	
	
	


	$('press_scroll_up').addEvents({
		'mouseenter': function() {
			scroll_up($('innersky'));
			this.src="/images/scroll_up_on.gif";
			$clear(scroller_down);
		},
		'mouseleave': function() {
			$clear(scroller_up);
			this.src="/images/scroll_up.gif";
			revertTimer();
		}
	},this);

	$('press_scroll_down').addEvents({
		'mouseenter': function() {
		//	console.log($('innersky').getScroll().y);
			
			$clear(scroller_down);
			scroll_down($('innersky').id);
			this.src="/images/scroll_down_on.gif";
		},
		'mouseleave': function() {
			$clear(scroller_down);
			this.src="/images/scroll_down.gif";
			revertTimer();
		}
	});	
	
	/*
	$('multi_scroll_up').addEvents({
		'mouseenter': function() {
			scroll_up($('final_nav_multi_content').id);
			$clear(scroller_down);
		},
		'mouseleave': function() {
			$clear(scroller_up);
			revertTimer();
		}
	});

	$('multi_scroll_down').addEvents({
		'mouseenter': function() {			
			scroll_down($('final_nav_multi_content').id);
			$clear(scroller_down);
		},
		'mouseleave': function() {
			$clear(scroller_down);
			revertTimer();
		}
	});
	*/
	


	
});


var scroller_up 	= null;
var scroller_down 	= null;

function upper(el) {
	to_here = $(el).getScroll();	
	to_here = to_here.y - 1;
	$(el).scrollTo(0, to_here);			
}

function downer(el) {
	to_here = $(el).getScroll();	
	to_here = to_here.y + 1;	
	$(el).scrollTo(0, to_here);			
}

function scroll_up(el) {	
	scroller_up = function() { upper($(el).id) };
	scroller_up = scroller_up.periodical(25);
}


function scroll_down(el) {	
	scroller_down = function() { downer($(el).id) };
	scroller_down = scroller_down.periodical(25);
}
