// Ensure that all product lists are the same height
$(document).ready(function() {
	
	if(typeof(DesignMode) != 'undefined') {
		return;
	}
	$('.PhotoView > a').attr('href','?display_mode=1');
	$('.DetailView > a').attr('href','?display_mode=2');
	$('.ListView > a').attr('href','?display_mode=3');

	$("#SideCategoryList li > a:contains('Oranje')").css({'color':'#ed6900'});
	
	//Thijs Bug Fix Fancybox
	$('.fancyGroup[href$="http://www.stressballen.nl/product_images/"]').remove();

	//Remove Email button if IE7
	if ($.browser.msie && $.browser.version <= 7) {
		$("#LayoutColumn2 .cartContainer ul li .email").parent('li').css('display', 'none');
	}

	//Sandy
	if (window!=top){top.location.href=location.href;}
	
	//Auto select Nederland bij afrekenen
	$("#FormField_11 option[value='Nederland']").attr('selected', 'selected');
	
	//define the type display type of the category	
	if($('.ProductList.List > li').length>0){
		if($('.ProductList.List.microList > li').length>0){
			$('.BackToTop a').hide();
		}
		var catDisplay="List";
	}else if($('.ProductList > li').length>0 ){
		var catDisplay="Grid";
		$('.BackToTop a').hide();
	}else{
		$('.BackToTop a').hide();
	}	
	
	$('#mmFormContactContainer').hide();
	
	$('#price_from').keydown(function(e) {
		var a=e.keyCode;
		//alert(event.keyCode);
		 if(a == '188' || a=='8' || a=='190' || (a>='0' && a<='57') || (a>='91' && a<='150')) {
			 return true;
		 }else{
			return false; 
		 }
	});
		
	buildNewHeight();
	
	MM_SlideMenu();
	
	$('.mmProductContactToggle').css({'cursor': 'pointer'});
	$('.mmProductContactToggle').click(function(){
		$('#mmFormContactContainer').slideToggle(1000, function(){
			buildNewHeight();
		});
		return false;
	});

	$(".sortHeader").click(function(){
		$(".sortList").slideToggle(500);
	});	

	$(".sortList").hover(function(){
		//$(".sortList").stop().slideDown(500);
		//$(".sortList").slideDown(500);
		
	},function(){
		//$(".sortList").stop(true,false);
		$(".sortList").slideUp(500);
	});	
	
	if(getURLParam('pageInfo')=='contact' || getURLParam('pageInfo')=='send'){
		$('.BulkDiscount').hide(); 
		$('.AddCartButton').hide(); 
		$('.ProductPrice').hide();
		
		$('.PrimaryProductDetails .ProductMain ').css({top:'-13px'});
		$('.ProductDetailsGrid').hide();

		$('.ProductAddToCart').hide(); 
		
	}else if(getURLParam('pageInfo')=='print'){
		//$('.BulkDiscount').hide(); 
		$('.AddCartButton').hide(); 
		//$('.ProductPrice').hide();
		
		$('.PrimaryProductDetails .ProductMain ').css({top:'-37px'});
		$('.ProductDetailsGrid').css({top:'-8px'});
		//$('.ProductDetailsGrid').hide();
		$('.ProductAddToCart').hide(); 
		$('#ProductReviews .FloatLeft').hide(); 
		$('#ProductReviews').hide(); 
		$('.mmProductVarList2').hide(); 
		
		window.print();		
			
	}
	$('#SuggestiveCartContent .ProductList > li:gt(4)').hide();
	$('.ProductOptionList select :eq(1)').attr("disabled", false);
	
	
	$('.ProductList.List > li:last').css({'border-bottom':'none'});

	var bodyheight = $('body').height();
	var windowheight = $(window).height();
	if(bodyheight>windowheight){
		$('#fancy_overlay').css({'height':bodyheight});
	}

	$(".InfoMessage strong:contains('Gefeliciteerd')").hide();
	$(".InfoMessage b:contains('Gefeliciteerd')").hide();

	//ProductImage
	if(catDisplay=='List'){
		if($('.ProductImage').length>0){
			$('.ProductImage').each(function(){
				$(this).children('.fancyList').prev('.fancyGroup').addClass('fancyTrigger').removeClass('fancyGroup').removeAttr('href');
			});
			$(".fancyGroup").fancybox({ 
				'hideOnContentClick': false,
				'fixedNavigation':true, 
				'overlayShow': true
			});
			
		}else{
			$(".fancyGroup").fancybox({ 
				'hideOnContentClick': false,
				'fixedNavigation':true, 
				'overlayShow': true
			});
		}

		$(".fancySingle").fancybox({ 
			'hideOnContentClick': false,
			'fixedNavigation':false, 
			'overlayShow': true
		});
		
	}else if(catDisplay=='Grid'){
		$('.ProductList > li').hover(function(){
			$(this).css({'border':'1px solid #D80D04' });
		},function(){
			$(this).css({'border':'1px solid #999999'});
		});	
	}
	
	$('.fancyTrigger').click(function(){
		var a=$(this).attr('rel');
		//alert(a);  :first
		$(this).next('.fancyList').children('.fancyGroup:first').trigger('click');
	});	

	$('.TopLinkList li:not(.popPage)').hide(0);

	$('.popPage').click(function(){
		$('.TopLinkList li:not(.popPage)').toggle(0);	
	});		
});
