$(document).ready(function() {
						   
	var ua		= navigator.userAgent.toLowerCase();
	var check	= function(r) {
            return r.test(ua);
	}
	var isIE9 = Ext.isIE && check(/msie 9/);

	if (Ext.isIE6 && !isIE9) {
		
		var IE6Panel	= Ext.get('IE6isEvil');
		var panelHeight	= Ext.get('container').getBottom() + 225;
		if (panelHeight < 1200) {panelHeight = 1200;}
		var target;
		var current;
		
		IE6Panel.setHeight(panelHeight);
		
		Ext.get('IE6isEvil_langBtn').addListener('click', function(e) {
			if (e.target.innerHTML == 'English') {
				current	= 'fr';
				target	= 'en';
			}
			else {
				current	= 'en';
				target	= 'fr';
			}
			
			Ext.get('IE6isEvil_langBtn_'+current).fadeOut({
				useDisplay	: true,
				callback	: function() {
					Ext.get('IE6isEvil_langBtn_'+target).fadeIn({
						useDisplay	: true
					});
				}
			});
			
			Ext.get('IE6isEvil_closeBtn_'+current).fadeOut({
				useDisplay	: true,
				callback	: function(){
					Ext.get('IE6isEvil_closeBtn_'+target).fadeIn({
						useDisplay	: true
					});
				}
			});
			
			Ext.get('IE6isEvil_'+current).fadeOut({
				useDisplay	: true,
				callback	: function(){
					Ext.get('IE6isEvil_'+target).fadeIn({
						useDisplay	: true
					});
				}
			});
		});
		
		Ext.get('IE6isEvil_closeBtn').addListener('click', function(e) {
			IE6Panel.hide(true);
		});
		
		IE6Panel.show(true);
	}
	
	if ( Ext.get('commentform') ) {
		
		var author	= Ext.get('comform_author');
		var email	= Ext.get('comform_email');
		var url		= Ext.get('comform_url');
		var comment	= Ext.get('comform_comment');
		
		if (author) {
			author.addListener('focus', function() {
				if (author.dom.value == avenue8.lang.author) {
					author.dom.value = '';
				}
			});
			author.addListener('blur', function() {
				if (author.dom.value == '') {
					author.dom.value = avenue8.lang.author;
				}
			});
		}
		
		if (email) {
			email.addListener('focus', function() {
				if (email.dom.value == avenue8.lang.email) {
					email.dom.value = '';
				}
			});
			email.addListener('blur', function() {
				if (email.dom.value == '') {
					email.dom.value = avenue8.lang.email;
				}
			});
		}
		
		if (url) {
			url.addListener('focus', function() {
				if (url.dom.value == avenue8.lang.url) {
					url.dom.value = '';
				}
			});
			url.addListener('blur', function() {
				if (url.dom.value == '') {
					url.dom.value = avenue8.lang.url;
				}
			});
		}
		
		if (comment) {
			comment.addListener('focus', function() {
				if (comment.dom.value == avenue8.lang.comment) {
					comment.dom.value = '';
				}
			});
			comment.addListener('blur', function() {
				if (comment.dom.value == '') {
					comment.dom.value = avenue8.lang.comment;
				}
			});
		}
		
	}
	
});

function showContactPanel() {

	var el = Ext.get('contact');
	
	if (!el.isVisible()) {
		el.slideIn('t', {
			easing		: 'easeOut',
			duration	: .5
		});
	}
	else {
		hideContactPanel();
	}
}

function hideContactPanel() {
	
	var el = Ext.get('contact');
	
	el.slideOut('t', {
		easing		: 'easeOut',
		duration	: .5,
		remove		: false,
		useDisplay	: true
	});
}


window.scrollV;

function scrollOpacity(e, t, o) {

	var hiddenPage 			= Ext.get('hiddenPage');
	var hiddenOpacity		= hiddenPage.getStyle('opacity');
	var scrollValue			= Ext.get(document).getScroll().top;
	var background_position	= parseInt(Ext.getBody().getStyle('background-position-y'));
		
	if(!Ext.isPrimitive()){
		background_position	= parseInt(Ext.getBody().getStyle('background-position').split(' ')[1]);
	}
	
	var scrollSpeed			= 10;
	var contactPanel		= Ext.get('contact');
	
	if (window.scrollV < scrollValue) {
		Ext.getBody().setStyle('background-position','center '+(background_position-scrollSpeed)+'px');
	}
	else if (scrollValue == 0) {
		Ext.getBody().setStyle('background-position','center 0px');
	}
	else {
		if (background_position < 0) {
			Ext.getBody().setStyle('background-position','center '+(background_position+scrollSpeed)+'px');
		}
		else {
			Ext.getBody().setStyle('background-position','center 0px');
		}
	}
	
	if (scrollValue > 0){
		if (contactPanel.isVisible()) {
			hideContactPanel();
		}
	
		hiddenPage.setOpacity(.75, {duration: .50, easing: 'easeOut'});
	}
	else if (scrollValue == 0){
		hiddenPage.setOpacity(0, {duration: .50, easing: 'easeOut'});
	}
	
	window.scrollV = scrollValue;
}

