﻿$(function() {
	//loop through wbr classes
	$('.wbr').each(function() {
		var text = $(this).html();
		//split the words by spaces and html characters
		var words = text.split(/([\s,]+|&.*?;|<.*?>)/);

		//loop through each word
		for (var i = 0; i < words.length; i++) {
			var word = words[i];
			//if the word is longer than 10 chars and not a html tag
			if (word.match(/^[^&< ].{11,}$/)) {
				var parsedWord = '';
				//loop through each char of the word
				for (var j = 0; j < word.length; j++) {
					//add <wbr> tag after char
					parsedWord = parsedWord + word.charAt(j) + '<wbr />';
				}
				//replace word in original text
				text = text.replace(word, parsedWord);
			}
		}
		//place the parsed text back in original object
		$(this).html(text);
	});
});


$(function() {
	var loadedImages = new Array();
	function preloadImages() {
		for (var i = 0; i < arguments.length; i++) {
			loadedImages[i] = new Image();
			loadedImages[i].src = '/Files/System/images/' + arguments[i];
		}
	}
	
	preloadImages(
		'btn_header_right-a-hover.gif',
		'btn_header_left-a-hover.gif',
		'li_menu_cosmetica.gif',
		'li_menu_voeding.gif',
		'li_menu_vitamine-mineralen.gif',
		'li_menu_dieetvoeding.gif',
		'li_menu_thee-kruiden.gif',
		'li_menu_fyto-homeopathie.gif',
		'li_menu_sport.gif',
		'li_menu_diversen.gif',
		'li_menu_reform-eco.gif',
		'btn_right-a-hover.gif',
		'btn_left-a-hover.gif',
		'btn-ecom_right-a.gif',
		'btn-ecom_left-a.gif',
		'btn_shopping-cart_right-a.hover.gif',
		'btn_shopping-cart_left-a.hover.gif',
		'input_btn_ok.hover.gif',
		'bg_paging_left-a.hover.gif',
		'bg_paging_right-a.hover.gif'
	);
});