jQuery(function() {
	
	jQuery('#lnkfr').click(function() {
		alert('La version française du site sera disponible sous peu.');	
		return false;
	});
	jQuery('.dealerlink').click(function() {
		Lightview.options.viewport = false;
		return true;
	});
	// Warn for unavailable links for the moment.
	jQuery('a.warn').click(function() { 
		alert('Not available at the moment.');
		this.blur();
		return false; 
	});

	// Search btn over 
	jQuery('#search a').hover(function() {
		jQuery(this).find('.hover').stop(false,true).fadeIn(300);
	},function() {
		jQuery(this).find('.hover').stop(false,true).fadeOut(300);
	});
	var menuto = new Array();
	// MAIN MENU
	jQuery('.menuitem a.active').find('.hover').show();
	jQuery('.menuitem a').hover(function() {
		if (jQuery(this).hasClass('active')) return false;
		jQuery(this).find('.hover').stop(false,true).fadeIn(300);
	},function() {
		if (jQuery(this).hasClass('active')) return;
		jQuery(this).find('.hover').stop(false,true).fadeOut(300);
	});

	
	
	// SUB MENU...
	jQuery('.submenu a.active').parent().show();
	 
	jQuery('.submenu a.active').find('.hover').show();
	jQuery('.submenu a').hover(function() {
		if (jQuery(this).hasClass('active')) return;
		jQuery(this).find('.hover').stop(false,true).fadeIn(300);
	},function() {
		if (jQuery(this).hasClass('active')) return;
		jQuery(this).find('.hover').stop(false,true).fadeOut(300);
	});
	
	// THIRD MENU!
	jQuery('#leftmenu a.active').find('.hover').show();
	jQuery('#leftmenu a').hover(function() {
		if (jQuery(this).hasClass('active')) return false;
		jQuery(this).find('.hover').stop(false,true).fadeIn(300);
	},function() {
		if (jQuery(this).hasClass('active')) return;
		jQuery(this).find('.hover').stop(false,true).fadeOut(300);
	});
	
	jQuery('.btnQuality, .catalogsmall, #tblprev, #tblnext, .tableoptionsin a').hover(function() {
		jQuery(this).find('.hover').stop(false,true).fadeIn(300);
	},function() {
		jQuery(this).find('.hover').stop(false,true).fadeOut(300);
	});
	jQuery('.tableoptionsin a').click(function() {
		jQuery('.tableoptionsin img.sel').hide();
		jQuery(this).find('.sel').show();
		jQuery('.tablerightin').hide();
		jQuery('#right-'+jQuery(this).attr('id').toString().substring(4)).show().preloadvisible();
		return false;
	});
	jQuery('.tableoptionsin a:first').click();
	jQuery('#btnChaise').click(function() { 
		var so = new SWFObject("../swf/chaise.swf", "flashbox", 510,348, "8", "#FFFFFF");
	  so.write("flashbox");	   	
		return false;	
	});

	jQuery('#btnStool').click(function() { 
		var so = new SWFObject("../swf/stool.swf", "flashbox", 510,348, "8", "#FFFFFF");
	  so.write("flashbox");	   	
		return false;	
	});
	
	jQuery('#btnTable').click(function() { 
		var so = new SWFObject("../swf/table.swf", "flashbox", 510,348, "8", "#FFFFFF");
	  so.write("flashbox");	   	
		return false;	
	});
	
	jQuery('#btnBuffet').click(function() { 
		var so = new SWFObject("../swf/buffet.swf", "flashbox", 510,348, "8", "#FFFFFF");
	  so.write("flashbox");	   	
		return false;	
	});
	
	jQuery('.catalognext').click(function() {
		jQuery('#page1').hide();
		jQuery('#page2').show();
		return false;
	});
	
	jQuery('.catalogprev').click(function() {
		jQuery('#page2').hide();
		jQuery('#page1').show();
		return false;
	});

	jQuery('.leglist a').click(function() {
		jQuery('.leglist a').removeClass('sel');
		jQuery(this).addClass('sel');
		/*var $img = jQuery(this).find('img:eq(0)'); 		
		Lightview.show({
			rel:'image',
			href:$img.attr('src').toString().replace(/([A-Z0-9]{2,3}\.[a-z]{3})$/,"big/$1"),
			title:$img.attr('alt')
		}); */
		this.blur();
		//return false;
	});
	
	jQuery('.singlelist a').click(function() {
		jQuery('.singlelist a').removeClass('sel');
		jQuery(this).addClass('sel');
		/*var $img = jQuery(this).find('img:eq(0)'); 		
		Lightview.show({
			rel:'image',
			href:$img.attr('src').toString().replace(/([A-Z0-9]{1,3}\.[a-z]{3})$/,"big/$1"),
			title:$img.attr('alt')
		}); */
		this.blur();
		//return false;
	});
	
	jQuery('.doublelist a').click(function() {
		jQuery('.doublelist a').removeClass('sel');
		jQuery(this).addClass('sel');
		/*var $img = jQuery(this).find('img:eq(0)'); 		
		Lightview.show({
			rel:'image',
			href:$img.attr('src').toString().replace(/([A-Z0-9]{1,3}\.[a-z]{3})$/,"big/$1"),
			title:$img.attr('alt')
		}); */
		this.blur();
		//return false;
	});
	
	jQuery('.edgelist a').click(function() {
		jQuery('.edgelist a').removeClass('sel');
		jQuery(this).addClass('sel');
		var $img = jQuery(this).find('img:eq(0)'); 		
		/*Lightview.show({
			rel:'image',
			href:$img.attr('src').toString().replace(/([A-Z0-9]{1,3}\.[a-z]{3})$/,"big/$1"),
			title:$img.attr('alt')
		}); */
		this.blur();
		/*return false;*/
	});
	
	/*jQuery('.colorlist a').click(function() {
		jQuery('.colorlist a').removeClass('sel');
		jQuery(this).addClass('sel');
		this.blur();
		return false;
	});*/
	jQuery('.colorlist a').click(function() {
		jQuery('.colorlist a').removeClass('sel');
		jQuery(this).addClass('sel');
		/*var $img = jQuery(this).find('img:eq(0)'); 		
		Lightview.show({
			rel:'image',
			href:$img.attr('src').toString().replace(/([A-Z0-9]{2,3}\.[a-z]{3})$/,"big/$1"),
			title:$img.attr('alt')
		}); */
		
		
		this.blur();
		// return false;
	});
	
	
	jQuery('.corianlist a').click(function() {
		jQuery('.corianlist a').removeClass('sel');
		jQuery(this).addClass('sel');
		/*var $img = jQuery(this).find('img:eq(0)'); 		
		Lightview.show({
			rel:'image',
			href:$img.attr('src').toString().replace(/([A-Z0-9]{1,3}\.[a-z]{3})$/,"big/$1"),
			title:$img.attr('alt')
		}); */
		this.blur();
		//return false;
	});
	
	jQuery('.fabricslist a').click(function() {
		jQuery('.fabricslist a').removeClass('sel');
		jQuery(this).addClass('sel');
		/*
		var $img = jQuery(this).find('img:eq(0)'); 	
		var imgtitle = $img.attr('src').toString();
		imgtitle = imgtitle.substr(imgtitle.length-6,2);
		Lightview.show({
			rel:'image',
			href:$img.attr('src').toString().replace(/([A-Z0-9]{2,3}\.[a-z]{3})$/,"big/$1"),
			title:imgtitle
		}); 
		//alert(imgtitle);
		*/
		this.blur();
		//return false;
	});
	
	
	jQuery('#doublenext').click(function() {
		jQuery('#double1').hide();
		jQuery('#double2').show();
	});
	
	jQuery('#doubleprev').click(function() {
		jQuery('#double2').hide();
		jQuery('#double1').show();
	});
	
	jQuery('#colortypein a').click(function() {
		jQuery('#colortypein .selected').removeClass('selected');
		jQuery(this).addClass('selected');
		jQuery('.colorlist').hide();
		jQuery('#color-'+jQuery(this).attr('id').toString().substring(3)).show().preloadvisible();
		this.blur();
		return false;
	});
	
	jQuery('#fabricstypein a').click(function() {
		jQuery('#fabricstypein .selected').removeClass('selected');
		jQuery(this).addClass('selected');
		jQuery('.fabricslist').hide();
		jQuery('#fabrics-'+jQuery(this).attr('id').toString().substring(3)).show().preloadvisible();
		this.blur();
		return false;
	});
	
	jQuery('#viewallchair').click(function() {
		jQuery('#pagepad').hide();
		jQuery('.chairpage:first').addClass('currentpage').show().preloadimgs();
		if (navigator.userAgent.match(/msie 6/i)) jQuery('.currentpage .tablelist > a:last').css('marginRight',0);
		return false;
	});
	
	jQuery('.chairsnext').click(function() {
		jQuery('.currentpage').hide().removeClass('currentpage').next().addClass('currentpage').show().preloadimgs();
		if (navigator.userAgent.match(/msie 6/i)) jQuery('.currentpage .tablelist > a:last').css('marginRight',0);
		return false;
	});
	
	jQuery('.chairsprev').click(function() {
		jQuery('.currentpage').hide().removeClass('currentpage').prev().addClass('currentpage').show();
		return false;
	});
	
	jQuery('.chairitemsize').hover(function() {
		jQuery('.tableimage').data('oldsrc',jQuery('.tableimage').attr('src')).attr('src','/images/canadel/chairsize.jpg');
	},function() {
		jQuery('.tableimage').attr('src',jQuery('.tableimage').data('oldsrc'));
	});
	
	jQuery('.benchitemsize').hover(function() {
		jQuery('.tableimage').data('oldsrc',jQuery('.tableimage').attr('src')).attr('src','/images/canadel/benchsize.jpg');
	},function() {
		jQuery('.tableimage').attr('src',jQuery('.tableimage').data('oldsrc'));
	});
	
	jQuery('.stoolitemsize').hover(function() {
		jQuery('.tableimage').data('oldsrc',jQuery('.tableimage').attr('src')).attr('src','/images/canadel/stoolsize.jpg');
	},function() {
		jQuery('.tableimage').attr('src',jQuery('.tableimage').data('oldsrc'));
	});
	
	
	jQuery("#chaircaroussel").jCarouselLite({
    btnNext: ".chairbottomnext",
    btnPrev: ".chairbottomprev",
    visible: 9,
    scroll: 9,
    speed : 2000
	});
	
	jQuery("#othercaroussel").jCarouselLite({
    btnNext: ".chairbottomnext",
    btnPrev: ".chairbottomprev",
    visible: 5,
    scroll: 5,
    speed : 2000
	});
	
	
	jQuery("#buffetcaroussel").jCarouselLite({
    btnNext: ".chairbottomnext",
    btnPrev: ".chairbottomprev",
    visible: 9,
    scroll: 9,
    speed : 2000
	});
	
	if (jQuery('#matte-caroussel').is(':visible')) {
		jQuery('#matte-caroussel').jCarouselLite({
	    btnNext: "#matte-next",
	    btnPrev: "#matte-prev",
	    visible: 9,
	    scroll: 9,
	    speed : 2000
		}).data('inited',1);
	}
	if (jQuery('#glossy-caroussel').is(':visible')) {
		jQuery('#glossy-caroussel').jCarouselLite({
	    btnNext: "#glossy-next",
	    btnPrev: "#glossy-prev",
	    visible: 9,
	    scroll: 9,
	    speed : 2000
		}).data('inited',1);
	}
	if (jQuery('#antique-caroussel').is(':visible')) {
		jQuery('#antique-caroussel').jCarouselLite({
	    btnNext: "#antique-next",
	    btnPrev: "#antique-prev",
	    visible: 9,
	    scroll: 9,
	    speed : 2000
		}).data('inited',1);
	}
	
	jQuery('#custtypelistin a').click(function() {
		if (jQuery(this).hasClass('selected')) return false;
		jQuery('#custbottomin > div').hide();
		jQuery('#custtypelistin a').removeClass('selected');
		jQuery(this).addClass('selected');
		var typelist = jQuery(this).attr('id').toString().substring(3);
		jQuery('#list-'+typelist).show().preloadimgs();
		if (jQuery('#'+typelist+'-caroussel').data('inited') != 1) {
			jQuery('#'+typelist+'-caroussel').jCarouselLite({
		    btnNext: '#'+typelist+'-next',
		    btnPrev: '#'+typelist+'-prev',
		    visible: 9,
		    scroll: 9,
		    speed : 2000
			}).data('inited',1);
		}
		return false;
	});
	
	
	/* NAVIG COLORS */
	jQuery('#viewallcolors').click(function() {
		jQuery('#pagepad').hide();
		jQuery('.colorpage:first').addClass('currentpage').show().preloadimgs();
		return false;
	});
	
	jQuery('.colorsnext').click(function() {
		jQuery('.currentpage').hide().removeClass('currentpage').next().addClass('currentpage').show().preloadimgs();
		return false;
	});
	
	jQuery('.colorsprev').click(function() {
		jQuery('.currentpage').hide().removeClass('currentpage').prev().addClass('currentpage').show();
		return false;
	});
	
	jQuery('.leglist a img, .colorlist a img, .fabricslist a img,.singlelist a img, .doublelist a img, .edgelist a img, .corianlist a img, .finishlist a, .qtip').qtip({
   content: false,
   style: { name: 'green', tip: true },
   show: 'mouseover',
   hide: 'mouseout'
	});
	
	jQuery('.gallery-thumbs .next').click(function() {
		jQuery(this).parent().hide().next().show();
		return false;
	});
	
	jQuery('.gallery-thumbs .prev').click(function() {
		jQuery(this).parent().hide().prev().show();
		return false;
	});
	
	jQuery('.galnext').click(function() {
		jQuery(this).parent().hide().next().show();
		return false;
	});
	
	jQuery('.galprev').click(function() {
		jQuery(this).parent().hide().prev().show();
		return false;
	});
	
});