jQuery.noConflict();
jQuery(document).ready(function($){

	// slow scroll to top 
	$('a[href=#top]').click(
		function(){
			$('html, body').animate({scrollTop:0}, 'slow');
		return false;
		});
	
	// support navigation 
	$('.extraLinks').hover(
		function(){
			$('.extraLinksSafety').stop().animate({width:"60px"}, 150).css({paddingLeft:"40px",textIndent:"0px",marginLeft:"15px"});
			$('.extraLinksFAQ').stop().animate({width:"60px"}, 150).css({paddingLeft:"40px",textIndent:"0px",marginLeft:"15px"});
			$('.extraLinksInstallation').stop().animate({width:"116px"}, 150).css({paddingLeft:"40px",textIndent:"0px",marginLeft:"15px"});
			$('.extraLinksCompatibility').stop().animate({width:"116px"}, 150).css({paddingLeft:"40px",textIndent:"0px",marginLeft:"15px"});
			$('.extraLinksSupport').stop().animate({width:"78px"}, 150).css({paddingLeft:"40px",textIndent:"0px",marginLeft:"15px"});
		}, 
		function(){
			$('.extraLinksSafety').stop().animate({width:"29px"}, 150).css({paddingLeft:"0px",textIndent:"-9999px",marginLeft:"20px"});
			$('.extraLinksFAQ').stop().animate({width:"29px"}, 150).css({paddingLeft:"0px",textIndent:"-9999px",marginLeft:"20px"});
			$('.extraLinksInstallation').stop().animate({width:"29px"}, 150).css({paddingLeft:"0px",textIndent:"-9999px",marginLeft:"20px"});
			$('.extraLinksCompatibility').stop().animate({width:"29px"}, 150).css({paddingLeft:"0px",textIndent:"-9999px",marginLeft:"20px"});
			$('.extraLinksSupport').stop().animate({width:"29px"}, 150).css({paddingLeft:"0px",textIndent:"-9999px",marginLeft:"20px"});

		});	
		
	// contact form slideout 
	$('.contactForm').hover(
		function(){
			$('.contactInfo').stop().animate({width:"410px"}, 150);
			$('.contactFormContents').stop().animate({width:"310px"}, 150).css({opacity:"1"});
			$('.contactFormFade').fadeOut(300);
			$('.contactNote').css({opacity:"1.0"});
			$('.contactFormOpen').animate({height:"81px"}, 0);
		}, 
		function(){
			$('.contactInfo').stop().animate({width:"630px"}, 150);
			$('.contactFormContents').stop().animate({width:"90px"}, 150).css({opacity:"0.2"});
			$('.contactFormFade').fadeIn(300);
			$('.contactNote').css({opacity:"0.0"});
			$('.contactFormOpen').animate({height:"127px"}, 0);
		});	
	
	// catalog browse by price dropdown 
	$('.browse-panel').hover(
		function(){
			$('.browsePanel').stop().animate({height:"100%"}, 150);
		}, 
		function(){
			$('.browsePanel').stop().animate({height:"44px"}, 150);
		});	
			
	// animate the newsletter signup box (index) 
	$('#newsletterForm').hover(
		function(){
			$(".newsletterMore").stop().show().animate({height:"122px"}, 150).fadeTo(150, 1);	
		}, 
		function(){
			$(".newsletterMore").stop().fadeTo(150, 0).animate({height:"0px"}, 150);
		});	

	$(".newsletterMore").hide();
		
	
	// onclick appear install pages 
	$(function() {
		$('.installationDerailleursLink').click(function(e) {
			$('.installationBrakes').fadeOut(200);
			$('.installationDerailleurs').fadeIn(200);	
		});			
		$('.installationBrakesLink').click(function(e) {
			$('.installationDerailleurs').fadeOut(200);
			$('.installationBrakes').fadeIn(200);	
		});
	});

	$(function() {
		// jQuery Tabs
		$(".tab_content").hide(); //Hide all content
		$("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content
		$("ul.tabs li").click(function() {
			$("ul.tabs li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content
			var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
			$(activeTab).fadeIn(); //Fade in the active content
			return false;
		});
	});
	// image rollover 
	function initRollovers() {
		if (!document.getElementById) return
		
		var aPreLoad = new Array();
		var sTempSrc;
		var aImages = document.getElementsByTagName('img');
	
		for (var i = 0; i < aImages.length; i++) {		
			if (aImages[i].className == 'imgover') {
				var src = aImages[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_on'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				
				aImages[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				
				aImages[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
		}
	}
	window.onload = initRollovers;
	
});	// end (document).ready
