// JavaScript Document
// introducing fadeToggle
jQuery.fn.fadeToggle = function (speed, easing, callback) {
	return this.animate({
		opacity: 'toggle'
	}, speed, easing, callback);
};

// introducing jQuery Tabs
$(function () {
	var tabContainers = $('div.equipTabs > div');
	tabContainers.hide().filter(':first').show();

	$('.tabNavigation a').click(function () {
		tabContainers.fadeOut();
		tabContainers.filter(this.hash).fadeIn();
		$('.tabNavigation li').removeClass('selected');
		$(this).parent().addClass('selected');
		return false;
	}).filter(':first').click();
});



function setupLabel() {
        if ($('.label_check input').length) {
            $('.label_check').each(function(){ 
                $(this).removeClass('c_on');
            });
            $('.label_check input:checked').each(function(){ 
                $(this).parent('label').addClass('c_on');
            });                
        };
        if ($('.label_radio input').length) {
            $('.label_radio').each(function(){ 
                $(this).removeClass('r_on');
            });
            $('.label_radio input:checked').each(function(){ 
                $(this).parent('label').addClass('r_on');
            });
        };
    };


// create custom tooltip effect for jQuery Tooltip
$.tools.tooltip.addEffect("bouncy",

// opening animation

function (done) {
	this.getTip().animate({
		top: '+=15'
	}, 500, 'bouncy', done).show();
},

// closing animation

function (done) {
	this.getTip().animate({
		top: '-=15'
	}, 500, 'bouncy', function () {
		$(this).hide();
		done.call();
	});

});



$(document).ready(function () {
	
	$("#cubeSlider .grid_4:eq(0), #cubeSlider .grid_4:eq(2)").click(function(){
		myUrl = $(this).find("a").attr("href");
		myUrl = myUrl.replace('cube-bikes/','');
		myRoot = document.URL.replace('cube-bikes/','');
	    window.location=myRoot+myUrl; return false;
	  });
	$("#cubeSlider .grid_4:eq(0), #cubeSlider .grid_4:eq(2), #cubeSlider .grid_4:eq(4)").live("mouseenter", function() {
	        $(this).addClass('hover'); 
	    }).live("mouseleave", function() {
	        $(this).removeClass('hover');
	    });
	  
	
	    $('body').addClass('has-js');
        $('.label_check, .label_radio').click(function(){
            setupLabel();
        });
        setupLabel(); 

	$('#rightColBikes .contenttable tr :nth-child(2)').css('font-weight', 'bold');
	

	// introducing jQuery Tooltip
	$(".trigger").tooltip({
		effect: 'slide'
	});
    
	
	$(".cubeStart #cubeSlider .grid_4 .news:last-child").addClass('last')
	
});

