function submitSearch( event )
{
	$('search_mini_form').submit();
	Event.stop(event);
}

function effectThumbs()
{
	var large_img = $$('#article-info .article-picture .product-picture img')[0];
	$$('#article-info .article-picture .thumbs a img').each(function( img ){
img.observe('mouseover', function(e) {
if( large_img.src != img.getAttribute('longdesc') )
{
large_img.hide();
large_img.src = img.getAttribute('longdesc');
$$('#article-info .article-picture .button-zoom a')[0].href = img.up().href;
large_img.appear();
}
});
});
}

function toggleMenu(elm,index){}

function mycarousel_initCallback(carousel) {
jQuery('.carrousel a').bind('click', function() {
// move the carousel depending on the number of the link
carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
// put the selected class on the right link
jQuery('.carrousel a').removeClass('selected');
jQuery(this).addClass('selected');
return false;
});
// Pause autoscrolling if the user moves with the cursor over the clip.
carousel.clip.hover(function() {
carousel.stopAuto();
}, function() {
carousel.startAuto();
});
};
function mycarousel_itemVisibleInCallback(carousel,obejctli,liindex,listate) {
	jQuery('.carrousel a').removeClass("selected");
	jQuery('.carrousel a:eq('+ (liindex-1) +')').addClass("selected");
}

window.onload = function ()
{
	$$('.with-js').invoke('show')
	$$('.without-js').invoke('hide')
// Formulaire de recherche
	//$$('#search_mini_form .search-button a')[0].observe('click', submitSearch);
if( $('mycarousel') )
	{
jQuery("#mycarousel").jcarousel({
scroll: 1,
initCallback: mycarousel_initCallback,
itemVisibleInCallback: mycarousel_itemVisibleInCallback,
// This tells jCarousel NOT to autobuild prev/next buttons
buttonNextHTML: null,
buttonPrevHTML: null,
auto:5,
wrap: 'last'
});
	}
$$('#search').each(function( input ){
input.observe('focus', function(e) {
if (input.value == input.defaultValue) input.value = '';
});
input.observe('blur', function(e) {
if (input.value == '') input.value = input.defaultValue;
});
	});
//Détail produit - affichage des images
	if( $$('#article-info .article-picture .product-picture')[0] )
	{
$$('#article-info .article-picture .product-picture')[0].setStyle({height: '209px'});
effectThumbs();
	}
// Liste des produits - blocs de taille identique sur une même ligne
	$$('#listing li.clear, .listing li.clear').each(function(element){
elems = $$('#listing li, .listing li');
pos = elems.indexOf(element);
nextPos = elems.indexOf(element.next('li.clear'));
if( nextPos == -1 )
nextPos = elems.indexOf(element.next('li.last'))+1;
if(nextPos == -1 && element.next())
nextPos = pos +2;
maxHeight = 0;
for(i=pos;i<nextPos;i=i+1){
if( maxHeight < elems[i].getHeight() )
maxHeight = elems[i].getHeight()
}
for(i=pos;i<nextPos;i=i+1)
elems[i].down(".frame").down(".product").setStyle({'height':maxHeight+"px"});
	});
/*var inputs = [$('billing:street1'), $('billing:street2'), $('billing:city'), $('billing:postcode'), $('billing:country_id')];
	inputs.each(function(elm){
elm.observe('blur', addressValidation);
	});*/
// Effet de hover sur de lien pour mettre les img en couleur
	$$('.img-color').invoke('observe', 'mouseover', function(event){
img = this.down();
img.src = img.src.replace('_gris', '');
	});
	$$('.img-color').invoke('observe', 'mouseout', function(event){
img = this.down();
img.src = img.src.replace(/(\/images\/[^\.]+)/i,'$1_gris');
	});
}

