(function($) {
	jQuery(document).ready(function() {

		/**
		 * Gestion des inputs d'enregistrement ŕ la newsletter
		 */
		var input_default_value = new Array;
		$('#form_newsletter input[type=text]').blur(function() {		
			if ($(this).val() == '')
				$(this).attr('value', input_default_value[$(this).attr('id')]);

		});
		
		$('#form_newsletter input[type=text]').focus(function() {
			if (typeof input_default_value[$(this).attr('id')] == 'undefined')
				input_default_value[$(this).attr('id')] = $(this).val();
			if ($(this).val() == input_default_value[$(this).attr('id')])
				$(this).attr('value', '');
		});
		
		

		$('#div_searchfield input[type=text]').blur(function() {		
			if ($(this).val() == '')
				$(this).attr('value', input_default_value[$(this).attr('id')]);

		});
		$('#div_searchfield input[type=text]').focus(function() {
			if (typeof input_default_value[$(this).attr('id')] == 'undefined')
				input_default_value[$(this).attr('id')] = $(this).val();
			if ($(this).val() == input_default_value[$(this).attr('id')])
				$(this).attr('value', '');
		});
		
		/**
		 * Vérification du formulaire d'enregistrement ŕ la newsletter
		 */
		$('#form_newsletter').submit(function() {
			var check = true;
			var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
			
			list = ['newsletter_firstname', 'newsletter_lastname', 'newsletter_email', 'select_language'];
			for (i in list)
			{
				if (
					$('#' + list[i]).val() == '' || $('#' + list[i]).val() == 'First Name' || $('#' + list[i]).val() == 'Last Name' || $('#' + list[i]).val() == 'E-mail'
					|| (list[i] == 'newsletter_email' && !filter.test($('#newsletter_email').val()))
					)
				{
					$('#' + list[i]).css('borderColor', 'red');
					$('#' + list[i]).css('backgroundColor', '#FFEAEA');
					check = false;
				}
				else
				{
					$('#' + list[i]).css('borderColor', 'black');
					$('#' + list[i]).css('backgroundColor', 'white');
				}
			}
			return (check);
		});
		
		if ($('#newslist').size()) 
		{
			$('#newslist').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 15});
			$('.jScrollArrowUp').html(''); //Specialement pour IE6
			$('.jScrollArrowDown').html(''); 
		}
		
		
	if ($('#commentfield').size()) {
		$('#commentfield').keyup(function() {
			if ($('#commentfield').val().length > 150)
				$('#commentfield').val($('#commentfield').val().substr(0, 150));
			$(this).parent().find('label').text('Comment (' + $('#commentfield').val().length + '/150): ');
			$(this).parent().find('label').css('width', '150px');
		});
	}
	});
})(jQuery)

