	$(document).ready(function() {
	
	
		/*******************************************************************************
		/*	fonts
			temporary: #actie_leukste_buurvrouw h1 - h3
		/******************************************************************************/
		Cufon.set('fontFamily', 'RotisSansSerif').replace('#actie_powerpad h2, .home h2, .beitswijzer-filter h1, #actie_leukste_buurvrouw h1, #actie_leukste_buurvrouw h2, #actie_leukste_buurvrouw_winnaar h1, #actie_leukste_buurvrouw_winnaar cufon, #actie_leukste_buurvrouw_winnaar h1 span,#actie_leukste_buurvrouw_winnaar h2,#actie_leukste_buurvrouw_winnaar .biografie h3,#actie_leukste_buurvrouw_winnaar .biografie h4,.uitschuif-lijst h3, .beitswijzer-filter h2, .beitswijzer h3, .product h1, .product h2, .product-higlights li, .boodschappenlijst h1, .product .widget h3, .widgets .widget h2, .default-template h1, .default-template h2, .plain-page h1, .plain-page h2, .contact h1, .contact h2, .tips-categories h3, .tips h1, #tips-faq ul div.highlight h3, .cetabever .widgets .tekst h2, .cetabever h1, .cetabever h2, #carousel h1');
				
		Cufon.set('fontFamily', 'RotisSansSerif').replace('#navigation a', {
			hover: true, textShadow: '#333 2px 2px'
		});	
		Cufon.set('fontFamily', 'Rotis Sans Serif Std ExtraBold').replace('#menu ul li')('h3')('#right-up');
		
		Cufon.set('fontFamily', 'Rotis Sans Serif Std').replace('#right-center')('#right-down');			
		
		if($('#shopping-list-count').length){
		     $('#shopping-list-count').html(cookieCountProducts());
		}		
		
		$('.shopping-list-add a').each(function(){
		    $(this).click(function(e) {
		        e.preventDefault();
		        cookieAddProduct(this.getAttribute('rel'));
				return false;
		    });
		    
		})
		
		/* WEER ONLINE WIDGET */
		$('.weatheroverview a').attr('href','http://www.weeronline.nl');

		/*******************************************************************************
		/*	TIPS ballon
		/******************************************************************************/
		
	  if($('.ui-tabs-nav li').length == 1){
		  setTimeout(function() {
			  $("#tips-advies-ballon").fadeOut(500);
		  }, 2500);
		  $('.tips-van-dirk-foto').hover(function(){
			  $('#tips-advies-ballon').toggle('active');									
		  });
	   } else {
		$('.ui-tabs-nav li:last-child a').click(function()  {
			setTimeout(function() {
				$("#tips-advies-ballon").fadeOut(500);
			}, 2500);
			$('.tips-van-dirk-foto').hover(function(){
				$('#tips-advies-ballon').toggle('active');									
			});
		});
	   }
		
		/*******************************************************************************
		/*	slim bekeken
		/******************************************************************************/
	
		$('.current').addClass('active');
		$('.slim-bekeken-link').click(function(e){
			e.preventDefault();						
			$('.active').removeClass('active');
			$("div[rel='"+this.rel+"']").toggleClass('active');			
		});		
	
		/*******************************************************************************
		/*	home carousel
		/******************************************************************************/
	
		$(window).load(function(){		
	
			// Standaard breedtes
			var zoomWidth = '130px';	
			var mouseoutWidth = '94px';
			var zoomWidthBigProducts = '154px';
			var mouseoutWidthBigProducts = '134px';	
			
			var animatieIndex = 0;
			var animatieFinished = 0;
			
			// Een keer alle potjes animeren
			setTimeout(function(){
				animatie = setInterval(function(){
					obj = $(".beits-producten li:eq("+animatieIndex+")").find("img").stop(false,true);
					if(!obj.length){
						clearInterval(animatie);
						animatieFinished = 1;
						return false
					}			
					objPosition = (obj.hasClass("groot-product")) ? "10px" : "23px";
					objWidth = (obj.hasClass("groot-product")) ? "154px" : "135px";			 			
					objMouseoutWidth = (obj.hasClass("groot-product")) ? "134px" : "94px";
					
					obj.animate({left: '-' + objPosition ,width: objWidth},700);
					obj.animate({left: '+='+ objPosition ,width: objMouseoutWidth},700);
					animatieIndex++;			
				},700);
			},0);		
			
			// Animeer potjes op hover
			$(".beits-producten li a").hover(function() { 		
				if(animatieFinished){
					this.productImg = $(this).find("img");														 
																			 
					if (this.productImg.hasClass("groot-product")) {	
						this.productImg.stop(false,true).animate({
							left: '-10px',
							width: zoomWidthBigProducts
						});
					} else {														 
						this.productImg.stop(false,true).animate({									 
							left: '-23px',
							width: zoomWidth
						});
					}
				}		
				
			},function(){	
				if(animatieFinished){
					if (this.productImg.hasClass("groot-product")) {		
					   this.productImg.stop(false,true).animate({
						  left: '+=10px',
						  width: mouseoutWidthBigProducts
					   });
					} else {
						this.productImg.stop(false,true).animate({
						  left: '+=23px',
						  width: mouseoutWidth
					   });
					}
				}
			});

	});	
	

	
		/*******************************************************************************
		/*	carousel tips van Dirk
		/******************************************************************************/

		if($(".tips-van-dirk-tab").length && (".tips-van-dirk-carousel li").length > 1){			
			$(".tips-van-dirk-tab a.next").addClass("visible"); 
			$(".tips-van-dirk-tab .next_inactief").removeClass("visible"); 
	
			var positie = 1;
			var shift = 380;
			var maxPositie = Math.round($(".tips-van-dirk-tab ul li").size());		
			
			
			$('.tips-van-dirk-carousel').cycle({ 
				fx: 'scrollHorz',							   
				timeout:  0, 
				speed:    500, 
				pause: 1,
				prev:    '.tips-van-dirk-tab .prev', 
				next:    '.tips-van-dirk-tab .next'
			});   
			
			$(".tips-van-dirk-tab a.next").click(function(e) {	
 			e.preventDefault();		
			  $(".tips-van-dirk-tab a.prev").addClass("visible");
			  $(".tips-van-dirk-tab .prev_inactief").removeClass("visible"); 
				positie ++;
				if(positie >= maxPositie){
					// haal de knop weg	
					$(".tips-van-dirk-tab .next").removeClass("visible"); 
					$(".tips-van-dirk-tab .next_inactief").addClass("visible"); 
				}	
				newPos = $(".tips-van-dirk-tab ul").position().left - shift;
				if ($(".tips-van-dirk-tabul").width() + newPos < $(".tips-van-dirk").width()) {
				  newPos = $(".tips-van-dirk").width() - $(".tips-van-dirk-tab  ul").width();
				}
			  $(".tips-van-dirk-tab  ul").animate({ left:newPos+"px"}, 1000);				
			});
			
			$(".tips-van-dirk-tab a.prev").click(function(e) {	
				e.preventDefault();						 					
				$(".tips-van-dirk-tab a.next").addClass("visible"); 
				$(".tips-van-dirk-tab .next_inactief").removeClass("visible"); 
				
				positie--;
				if(positie == 1){
				  $(".tips-van-dirk-tab .prev").removeClass("visible"); 
				  $(".tips-van-dirk-tab .prev_inactief").addClass("visible"); 
				}
				newPos = ($(".tips-van-dirk-tab ul").position().left + shift + 65);
				if (newPos > 0) newPos = 0;
				$(".tips-van-dirk-tab ").animate({ left:newPos+"px"}, 1000);
			}); 
		}

		/*******************************************************************************
		/*	email adres afschermen
		/******************************************************************************/
	
		$('.mail a').each(function(){
			e = this.rel.replace('/','@');
			this.href = 'mailto:' + e;
			$(this).text(e);
		});	
	
		/*******************************************************************************
		/*	search field header
		/******************************************************************************/
	
		$('.header-search').hover(function() {
			$('a.search, .search-input').toggle();
		});
		
		$('.search-input').hover(function() {
			$('a.search, .search-input').toggle();
		});
		
		$('.submit-search').submit(function() {
			$('a.search, .search-input').toggle();
		});
		
		$(".submit-search").keypress(function (e) {  
				 if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {  
					 $('button[type=submit] .default').click();  
					 return false;  
				 } else {  
					 return true;  
				 }  
		});  
		
	
		/*******************************************************************************
		/*	Verkooppunt zoeken
		/******************************************************************************/
		
		var inputPlaats = jQuery("input.input-reseller-locator");
		inputPlaats.attr("autocomplete","off");
		
		jQuery("input.submit-reseller-locator").click(function(){
			resellerSubmit();
			return false;
		});
	
		inputPlaats.keyup(function(e){
			if(e.keyCode == 13){ //enter
				resellerSubmit();
				return false;
			}
		});
	
		function resellerSubmit(){
			if(inputPlaats.val() == ""){
				alert("je hebt geen plaatsnaam ingevuld");
			} else {
				window.location = "/resellers?city="+inputPlaats.val();
			}
		}

/*******************************************************************************
	/*	Verkooppunt zoeken powerpad actie
	/******************************************************************************/

	var inputPlaatsShop = jQuery("input.input-reseller-locator-karwei2");
inputPlaatsShop.attr("autocomplete","off");
        
jQuery("input.submit-reseller-locator-karwei2").click(function() {
    shopSubmit();
    return false;
});
    
inputPlaatsShop.keyup(function(e) {
    if(e.keyCode == 13){ //enter
        shopSubmit();
        return false;
    }
});
    
function shopSubmit(){
    if(inputPlaatsShop.val() == "" || inputPlaatsShop.val() == "Bv. Amsterdam"){
        alert("je hebt geen plaatsnaam ingevuld");
    } else {
        window.location = "/shops?city="+inputPlaatsShop.val();
    }
}
	
		/*******************************************************************************
		/*	brochure download: nice checkboxes
		/******************************************************************************/
	
	
		$('.download-brochure label').attr("autocomplete","off").click(function() {			
			
			$(this).toggleClass('selected');
				
			var checkbox = $(this).find("input:checkbox").show();												   														   
			checkbox.checked = (checkbox.checked) ? 0 : 1;				
			
		});
	
	
		/*******************************************************************************
		/*	timeline
		/******************************************************************************/
										   
		// Voorkom verspringingen				   
		$("#timeline li a.preventDefault").click(function(e){
			e.preventDefault();							 
		});
			
		// Toon 1920 bij openen pagina	
		$("#timeline li.jaar_1920").addClass("active");
		// Verbegt 1920 bij selecteren ander jaartal
		$("#timeline li").hover(function() {												
			$("#timeline .jaar_1920 .content").removeClass("active");		
		});
		
		// Toon jaartal bij hover
		$("#timeline li").mouseover(function() {	
			$("#timeline li").removeClass("active");
			$(this,"#timeline li a").addClass("active");
		});
		
		
	});
	
		/*******************************************************************************
		/*	brochure download
		/******************************************************************************/
	
	function brochure(){
		var counter = 0; var i = 0; var url = ''; var url2 = '/media/CB_kleurkaart.zip';
		var input_obj = document.getElementsByTagName('input');
		var tracking = '/downloads/brochure';
		for (i=0; i < input_obj.length; i++){
			if (input_obj[i].type == 'checkbox'){
				if (input_obj[i].checked == true){
					counter++;
					tracking += '/'+input_obj[i].value.toLowerCase();
					url = url + String.fromCharCode(38) + 'CB_kleurkaart_' + input_obj[i].value +'.pdf';
				}
			}
		}

		if (counter > 0) {
			_gaq.push(
				['_trackPageview', tracking]
			);
		}

		if (counter == 1) {
		url = url.substr(1);
		window.open('/media/' + url);
		}	
		else if (counter == 2) {
		url = url2;
		window.location.href = '/media/CB_kleurkaart.zip';
		//window.open('/media/CB_kleurkaart.zip');
		}
		else alert("U heeft geen keuze gemaakt.");
	}
	
	$(function(){
	
		/*******************************************************************************
		/*	clear input values
		/******************************************************************************/
	
	
		$('input[type=text]').each(function() {
	
		   var default_value = this.value;
	
				$(this).focus(function(){
						if(this.value == default_value) {
								this.value = '';
						}
				});
	
				$(this).blur(function(){
						if(this.value == '') {
								this.value = default_value;
						}
				});
	
		});
	
		/*******************************************************************************
		/*	hide empty spans search results
		/******************************************************************************/
	
		$(".sample").each(function(){
			var value = $.trim($(this).text())
			if(value == ""){
				$(this).hide()
			}
		});
	
		/*******************************************************************************
		/*	jQuery externe links in nieuwe venster
		/**********************	*******************************************************/
	
	
		$('a[href^="http://"]')
		  .attr({
			target: "_blank", 
			title: "Opent in een nieuwe venster."
		  });
	
		/*******************************************************************************
		/*	foldingmenu_panel
		/******************************************************************************/
		if($("#foldingmenu_panel").length){	
			Cufon.replace('div#foldingmenu_panel h4 a', { fontFamily: 'RotisSansSerif', hover: true });
			$(function() {
				$("#foldingmenu_panel").accordion({
					collapsible: true,
					active: $('.active'),
					autoHeight: false
				});
			});
			$("body.cetabever #foldingmenu_panel a").click(function(){
				window.location=$(this).attr("href"); 
			});
		}
	
		/*******************************************************************************
		/*	accordion : tips & advies
		/******************************************************************************/
	
		if($("#tips-faq").length){	
			$(function() {
				$("#tips-faq").accordion({
					collapsible: true,
					active: $('.active'),
					autoHeight: false
				});
			}); 
		}
	
		/*******************************************************************************
		/*	accordion : de kracht van CB subpagina's
		/******************************************************************************/
	
		if($(".uitschuif-lijst").length){	
			$(function() {
				$(".uitschuif-lijst").accordion({
					collapsible: true,
					active: $('.active'),
					autoHeight: false
					
				});
			}); 
			$("#actie_leukste_buurvrouw .uitschuif-lijst").accordion({active: 1});
		}
		
		
	});	
	
		/*******************************************************************************
		/*	paint calculator
		/******************************************************************************/
	
	function calculatePaintAmount(){
		
		var paint = document.getElementById( "input-paint-calculator" ).value;
		var paintAmount = calculatorFactor    * parseInt(paint);
		var result=Math.round(paintAmount*10)/10
	
		if (paint == 0){
			alert('Voer alsjeblieft aantal vierkante meters in.');
		}
		else if(paint > 0){
				document.getElementById( "amount" ).innerHTML = "U heeft " +result+ " liters verf nodig.";
			}
	}
