(function($) {
    var cache = [];
    // Arguments are image paths relative to the current page.
        $.preLoadImages = function() {
        var args_len = arguments.length;
        for (var i = args_len; i--;) {
          var cacheImage = document.createElement('img');
          cacheImage.src = arguments[i];
          cache.push(cacheImage);
        }
    }
	jQuery.noConflict();
    $("document").ready(function() {

		var showAllAudio = $('body#home #element2041461_826301 div.rss');
		if (showAllAudio) {showAllAudio.html('<a href="/car-audio" class="showAll">toon alle audio aanbiedingen »</a>');}
	
		var searchButton = $("input.searchButton");
		if(searchButton.val() != '') {
			searchButton.val('zoek');
		}
		var submitButton = $(".submitButtonContainer input.submitButton");
		if(submitButton.val() != '') {
			submitButton.val('verzenden');
		}
		var goBack = $(".blogBack a, .eventBack a");
		if(goBack.text() != '') {
			goBack.text("< ga terug");
		}
		var attachment = $(".postAttachment a");
		if(attachment.text() != '') {
			attachment.attr('title', 'klik op deze link om het bestand ('+attachment.text()+ ') te downloaden');
			attachment.text("download");
			attachment.attr('target', 'external_link');
		}
		var searchResults = $(".detail h1");
		if(searchResults.text() == 'Search Results') {
			searchResults.text("Zoekresulaten");
		}
		var addCommentLink = $("a#addCommentLink");
		if( addCommentLink.text() !='') {
			addCommentLink.text("Geef hieronder een reactie");
		}
		var translateCaptchaCode = $("span#MainContent_0_0_captcha_MessageLabel");
		if( translateCaptchaCode.text() !='') {
			translateCaptchaCode.text("Type de code hieronder over in het invulveld in het veld eronder:");
		}
		var addComment = $("h3.addComment");
		if( addComment.text() !='') {
			addComment.text("Voeg een nieuwe reactie toe");
		}
		var btnSubmitComment = $("#MainContent_0_0_pnlCommentsForm input#MainContent_0_0_btnSubmit");
		if( btnSubmitComment.val() != 'undefined') {
			btnSubmitComment.val("verzend reactie");
		}
		function translateCommentlabels(){
			var yourNameLabel = $("#MainContent_0_0_pnlCommentsForm .commentsForm p:nth-child(1) label");
			yourNameLabel.text('Uw naam');
		}
        /* hide second addressfield in contact form */
		var hideSecondAddress = $('div.fieldContent p.fieldRow:nth-child(2)');
		if (hideSecondAddress) { hideSecondAddress.hide(); }
        
        /* make blog article on homepage clickable */
		$('.blogList ul li').click(function(){
			var jLink = $(this).find('h2.postTitle a').attr('href');
			window.location = jLink;
        });

		/* jQuery logica voor EVENEMENTEN pagina's */
		$('.eventDate').each(function(index) {
			var myDate = new Date($(this).html());
			var curr_date = myDate.getDate();
			var curr_day = myDate.getDay();
			var curr_month = myDate.getMonth();
			var curr_year = myDate.getFullYear();
	
			curr_day +='';
			curr_day = curr_day.replace("0", "zondag, ");
			curr_day = curr_day.replace("1", "maandag, ");
			curr_day = curr_day.replace("2", "dinsdag, ");
			curr_day = curr_day.replace("3", "woensdag, ");
			curr_day = curr_day.replace("4", "donderdag, ");
			curr_day = curr_day.replace("5", "vrijdag, ");
			curr_day = curr_day.replace("6", "zaterdag, ");
	
			curr_month +='';
			curr_month = curr_month.replace(/10/, "november");
			curr_month = curr_month.replace(/11/, "december");
			curr_month = curr_month.replace(/0/, "januari");
			curr_month = curr_month.replace(/1/, "februari");
			curr_month = curr_month.replace(/2/, "maart");
			curr_month = curr_month.replace(/3/, "april");
			curr_month = curr_month.replace(/4/, "mei");
			curr_month = curr_month.replace(/5/, "juni");
			curr_month = curr_month.replace(/6/, "juli");
			curr_month = curr_month.replace(/7/, "augustus");
			curr_month = curr_month.replace(/8/, "september");
			curr_month = curr_month.replace(/9/, "oktober");
	
			$(this).html(curr_day + curr_date + " " + curr_month + " " + curr_year);
		
		});
    });

})(jQuery)
