
	//////////////////////////////////////
	//	CONTACT US
	//////////////////////////////////////
	
	function contactUs (){
		var email = $('contact_email').value.strip ().stripScripts ().stripTags ();
		var name = $('contact_name').value.strip ().stripScripts ().stripTags ();
		var message = $('contact_message').value.strip ().stripScripts ().stripTags ();
		
		if (email.blank () || name.blank () || message.blank ()){
			alert ('Vous devez remplir tous les champs');
			return;
		}
		
		if (!checkemail (email)){
			alert ('Email non valide');
			return;
		}
		
		var param = $H({
			'email': email,
			'name': name,
			'message': message
		});
		
		new Ajax.Request (ROOT_PATH+'remote/contactUs.php', {
			parameters: param.toQueryString (),
			onSuccess: function (xhr){
				var xml = xhr.responseXML;
				
				$('contact').update ('<div class="message_ok"><p>Merci !</p><p>Votre message vien d\'&ecirc;tre transmis &agrave; Aqualike qui vous r&eacute;pondra dans un d&eacute;lais de 48h.</p></div>');
			}
		});
	}
	
	
	//////////////////////////////////////
	//	SEARCH FIELD
	//////////////////////////////////////
	
	var searchField_clicked = 0;
	
	function clicSearch (field){
		if (searchField_clicked == 0){
			field.value = '';
		}
		
		searchField_clicked = 1;
	}
	
	
	//////////////////////////////////////
	//	MENU
	//////////////////////////////////////
	
	var timeout = new Array ();
	
	function initMenu (){
		var li = $$('#menu .fix');
		
		for (var i = 0; i < li.length; i ++){
			li[i].observe ('mouseover', classShow);
			li[i].observe ('mouseout', classHide);
		}
	}
	
	function classShow (){
		clearTimeout (timeout[this.readAttribute ('id')]);
		
		if (!this.hasClassName ('hover')){
			this.addClassName ('hover');
		}
	}
	
	function classHide (){
		var id = this.readAttribute ('id');
		
		timeout[id] = setTimeout (function (){
			classHide_callback (id);
		}, 10); 
	}
	
	function classHide_callback (id){
		if ($(id).hasClassName ('hover')){
			$(id).removeClassName ('hover');
		}
	}
	
	
	//////////////////////////////////////
	//	PRODUCT PIC
	//////////////////////////////////////
	
	var timeout_pic;
	var timeout_picWait;
	var last_date = 0;
	
	function changePic (date){
		if (date == last_date){
			return;
		}
		
		last_date = date;
		
		clearTimeout (timeout_pic);
		clearTimeout (timeout_picWait);
		
		timeout_pic = setTimeout (function (){
			//~ $('bigPic').hide ();
			
			//~ $('bigPic').writeAttribute ('src', ROOT_PATH + 'media/image/photo/448x300/' + date + '.jpg');
			
			var newImage = new Element ('img', {
				'id' : 'bigPic'
			});
			
			newImage.hide ();
			newImage.writeAttribute ('src', ROOT_PATH + 'media/image/photo/448x300/' + date + '.jpg');
			Element.replace($('bigPic'), newImage);
			
			picWait ();
		}, 210);
	}
	
	function picWait () {
		if (!$('bigPic').complete || (typeof $('bigPic').naturalWidth != 'undefined' && $('bigPic').naturalWidth == 0)){
			timeout_picWait = setTimeout ('picWait()', 20);
			
			return;
		}
		
		new Effect.Appear ('bigPic', {
			duration: .2,
			from: 0.2,
			to: 1
		});
	}
	
	
	//////////////////////////////////////
	//	BASKET
	//////////////////////////////////////
	
	function basket_add (id){
		var param = $H({
			'id': id
		});
		
		var choiceList = $$('#choiceList input');
		
		for (var i = 0; i < choiceList.length; i ++){
			if (choiceList[i].checked){
				param.set ('choice[' + i + ']', choiceList[i].value);
			}
		}
		
		if ($('colorList')){
			var colorList = $$('#colorList input');
			
			for (var i = 0; i < colorList.length; i ++){
				if (colorList[i].checked){
					param.set ('color', colorList[i].value);
				}
			}
		}else{
			param.set ('color', '');
		}
		
		new Ajax.Request (ROOT_PATH+'remote/basket_add.php', {
			parameters: param.toQueryString (),
			onSuccess: function (xhr){
				var xml = xhr.responseXML;
				
				if ($('basketEmpty')){
					$('basketEmpty').hide ();
					$('basketValidate').setStyle({
						'display': 'block'
					});
				}
				
				if ($('basketQuantity_' + XMLresult (xml, 0, 'n'))){
					$('basketQuantity_' + XMLresult (xml, 0, 'n')).update (parseInt ($('basketQuantity_' + XMLresult (xml, 0, 'n')).innerHTML) + 1);
				}else{
					var product = new Element ('li', {
						'id': 'basketContent_' + XMLresult (xml, 0, 'n')
					});
					
					product.insert (new Element ('b', {
						'id': 'basketQuantity_' + XMLresult (xml, 0, 'n')
					}).update (XMLresult (xml, 0, 'quatity')));
					
					var span = new Element ('span').update (XMLresult (xml, 0, 'product_name'));
					span.insert (new Element ('strong').update (XMLresult (xml, 0, 'product_priceshop') + ' &euro;'));
					span.insert (new Element ('s').update (XMLresult (xml, 0, 'product_pricedealer') + ' &euro;'));
					
					product.insert (span);
					$('basketContent').insert (product);
				}
				
				new Effect.Highlight ('basketContent_' + XMLresult (xml, 0, 'n'), {
					startcolor: "#ff6600",
					endcolor: "#e3e3e3",
					duration: 1
				});
			}
		});
	}
	
	
	//////////////////////////////////////
	//	CHECKOUT
	//////////////////////////////////////
	
	function chekout (){
		if ($('paymode')){
			var input = $$('#paymode input');
			
			for (var i = 0; i < input.length; i ++){
				if (input[i].checked){
					var paymode = input[i].value;
					break;
				}
			}
		}else{
			paymode = 2;
		}
		
		if (paymode == 1){
			document.paypal.submit ();
		}else
		if (paymode == 2){
			new Ajax.Request (ROOT_PATH+'remote/checkout.php', {
				parameters: 'paymode=' + paymode,
				onSuccess: function (xhr){
					window.location.replace(ROOT_PATH + 'commande/termineebis');
				}
			});
		}else{
			alert ('Une érreur est survenue. Contactez nous si se problème perciste.');
		}
	}
	
	
	//////////////////////////////////////
	//	BUDY BUBBLE
	//////////////////////////////////////
	
	var budyBubble_on = 0;
	
	function budyBubble (me, text){
		if (budyBubble_on == 0){
			budyBubble_on = 1;
			
			var bubble = new Element ('div', {
				'id': 'budyBubble'
			});
			
			bubble.insert (new Element ('div', {
				'class': 'top'
			}));
			
			bubble.insert (new Element ('div', {
				'class': 'middle'
			}).update (text));
			
			bubble.insert (new Element ('div', {
				'class': 'bottom'
			}));
			
			bubble.hide ();
			
			Element.insert(me, {
				'top': bubble
			});
			
			bubble.setStyle ({
				margin: '-' + bubble.getHeight () + 'px 0 0 -230px'
			});
			
			bubble.show ();
		}
	}
	
	function removeBudyBubble (){
		if (budyBubble_on == 1){
			budyBubble_on = 0;
			
			$('budyBubble').remove ();
		}
	}
