
jQuery(document).ready(function($) {
	$(".smallImage").mouseover(function(){
		document.getElementById('mainHref').href = '/images/.catalogFiles/'+ $(this).attr("rel") +'_big.jpg';
		document.getElementById('mainThumb').src = '/images/.catalogFiles/'+ $(this).attr("rel") +'_medium.jpg';
	});
		      
	$(".filter").hover(function(){
		$(this).css({'z-index' : '8'});
		document.getElementById('filter_choose_' + $(this).attr("rel")).style.display = 'block';   	
	}, function() {
		$(this).css({'z-index' : '7'});
		document.getElementById('filter_choose_' + $(this).attr("rel")).style.display = 'none';
	});
		      	      
	$('a[rel*=facebox]').facebox({
		loading_image : '/inc/facebox/loading.gif',
		close_image   : '/inc/facebox/closelabel.gif'
	})
	
	
	if($('element').length != 0){
		var shopLeftHeight = $("div#bodyContainer").height() - $("div#shopLeft").position().left - $("div#bodyHeader").height() - $("div#footerHolder").height() - 100;
		$("div#shopLeft").height(shopLeftHeight);
	}
	
	function addLogosLeft() {
		$("div#shopLeft").children("ul[id*='filterBox']").children("li[rel*='Merk']").each(function(){
			var relString = $(this).attr("rel");
			var relString = relString.split(",").pop();
			var logoUrl = "/img/logos/tt_logo_" + relString + ".png";
			var btnName = $(this).html();
			
			$(this).html('<img src="' + logoUrl + '" alt="' + btnName + '">');
		});
	}
	
	function addLogosHome() {
		$("div.homePageBlocks").children("div.homePageBlocksContentWrapper").children("div.homePageBlocksContent").children("div[rel*='Merk']").each(function(){
			var relString = $(this).attr("rel");
			var relString = relString.split(",").pop();
			var logoUrl = "/img/logos/tt_logo_" + relString + ".png";
			var btnName = $(this).html();
			
			$(this).html('<img src="' + logoUrl + '" alt="' + btnName + '">');
		});
	}
	
	

		/* merken popup system */
		if (window.location.pathname.match('/23/') == '/23/'){

			$('#bodyHeader').append('<div id="brandcontainer" style="display: none"><div class="div_scroll"></div></div>');
			
			/* hide all exept first IMG onload */
			var i = 0;
			$(".ContentRow .ContentItemThird .pageEditblockContent").each(function(){
				var html = $(this).html();
				
				if (html.match('/merken/') == '/merken/'){
					html = html.replace('.jpg','_big.jpg');
					html = html.replace('/merken/', '/merken/groot/');
				}	
				
				$('#brandcontainer').append('<div class="brand_block_fancy" id="brandblock'+i+'" >'+html+'</div>');
				
				
				
				$('#brandblock'+i).children('img').wrap('<div class="imgDiv"></div>');
				
/* 				src = $('#brandblock'+i).children('img').attr('src'); */

				


				$(this).children().each(function(){
					var child = $(this);
					
					if (child.is('p')){
						if (child.children('img').length == 0){
 							child.hide(); 
						}
						else{
							child.children('img').wrap('<a class="brandimage" href="#brandblock'+i+'"></a>');
						}
					}
					else{
						if (child.is('img') != true){
 							child.hide(); 
						}
					}
					
					if (child.is('img')){
						child.wrap('<a class="brandimage" href="#brandblock'+i+'"></a>');
					}
				});
				
				i++;
			});
	
			$('.brandimage').fancybox({'type':'inline'});
		}		
		/* merken popup system END */
		
/* 	productfinder_videobox	 */


	$.localScroll();

	$("a#prodfindvid").facebox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
			
			
	if($("#vidbox").length){
		jwplayer("vidbox").setup({
					flashplayer: "/js/player.swf", 
					file: '/video/Productfinder.flv', 
					height: 270, 
					width: 480
				});
	}

/* 	END productfinder_videobox	 */	
				
	$('#searchterm').keypress(function(e){
		if(e.which == 13){
			$('#srchFrm').submit();
		}
	});	

	//addLogosLeft();
	addLogosHome();
	
	$("div.chooseFilterItem").hover(function(){
		$(this).css({'backgroundColor' : '#f2f2f2'});
	}, function () {
		$(this).css({'backgroundColor' : '#ffffff'});
	});
	
	if ( $("div.scrollable").length > 0 ) {
		var scrollerOffset = $("div.scrollable").position();

		var scrollerX = scrollerOffset.left;
		var scrollerY = scrollerOffset.top + ( ( $("div.scrollable").height() / 2 ) - ( $("div.scrollerNavi").height() / 2 ) - 15 );
		
		$("div.scrollerNavi").css({'top' : scrollerY });
		$("div.scrollerNavi").css({'left' : scrollerX });
	}				
})
