$(document).ready(function(){
	$(".CheckBoxClass").change(function(){
		if($(this).is(":checked")){
			$(this).next("label").addClass("LabelSelected");
		}else{
			$(this).next("label").removeClass("LabelSelected");
		}
	});
	$(".CheckBoxClass2").change(function(){
		if($(this).is(":checked")){
			$(this).next("label").addClass("LabelSelected2");
		}else{
			$(this).next("label").removeClass("LabelSelected2");
		}
	});
});

$(document).ready(function() {

	$("#country_id").selectbox();

    
	$(".formvalidation").validate({
		errorLabelContainer: $(".formvalidation div.error")
	});
	
	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();	
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}

	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);

	/* Author: Bas van Ginkel */
	
	$('#highlight a.slide0').mouseover(function () {
		$('#highlight_visual').cycle('pause');
		$('#highlight_visual').cycle(0); 
	});
	
	$('#highlight a.slide1').mouseover(function () {
		$('#highlight_visual').cycle('pause');
		$('#highlight_visual').cycle(1); 
	});

	$('#highlight a.slide2').mouseover(function () {
		$('#highlight_visual').cycle('pause');
		$('#highlight_visual').cycle(2); 
	});

	$('.harmonica_extra').hide();
	$('.initial_open').show();
	$('.initial_closed').hide();

	$('.harmonica a.harmonica_meer').mouseover(function (){
		$('.harmonica_extra').slideUp();
		$('.harmonica_meer').slideDown();
		
		if ( $(this).hasClass('remove') ) {
			$(this).hide();
		}
		
		$(this).parentsUntil('.harmonica').parent().children().slideDown();
	})
	
	$('div.harmonica_product div.cat_beschrijving').click(function (){
			
		if ( $(this).parent().hasClass('open') ) {
			return false;
		}
		
		$('.harmonica_product').removeClass('open');
		$(this).parent().addClass('open');
		$('.harmonica_extra').slideUp();
		$(this).parent().children().slideDown();
	})

	$('#submenu li ul').hide();
	$('#submenu li.parent-actief ul').show();
	$('#submenu li.actief.has-children ul').show();

	$('#submenu li.level-1 > a').click(function (){
		$('#submenu li ul').slideUp();
		$('#submenu li').removeClass('actief');
		$(this).parent().children().slideDown();
		$(this).parent().addClass('actief');
		return false;
	})

	$('a[rel=product_image]').fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
	});
	
	$('a[rel=product_image2]').fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
	});

	$(".popup").fancybox({
			'transitionIn'	: 'none',
			'transitionOut'	: 'none'
	});

	$('#productshots_large').cycle({
		fx: 'fade',
		timeout: '6000'
	});

	$('#productshots a.slide0').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(0); 
	});

	$('#productshots a.slide1').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(1); 
	});

	$('#productshots a.slide2').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(2); 
	});

	$('#productshots a.slide3').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(3); 
	});

	$('#productshots a.slide4').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(4); 
	});

	$('#productshots a.slide5').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(5); 
	});

	$('#productshots a.slide6').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(6); 
	});

	$('#productshots a.slide7').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(7); 
	});

	$('#productshots a.slide8').mouseover(function () {
		$('#productshots_large').cycle('pause');
		$('#productshots_large').cycle(8); 
	});

	$('#country_id').change(function () {
		
		if ( $('#country_id option:selected').text() == 'Nederlands') {
			window.location = "http://autec.ctrlv.eu/"; 
		} else if ( $('#country_id option:selected').text() == 'English') {
			window.location = "http://autec.ctrlv.eu/index.php/en/";		
		} else if ( $('#country_id option:selected').text() == 'Deutsch') {
			window.location = "http://autec.ctrlv.eu/index.php/de/";
		}
	
	});
	

});



