// JQUERY CUSTOM COMMANDS
function pageLoad() // start javascript when document is loaded
{
	// MAIN MENU
	$('#headerMenu li').hover(function() { // show hide submenu 
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});

	$('.boxUnFolded img').click(function() {
		$(this).parent().parent().find('input').attr('checked', '').click();
	});

	function equalHeight(group) {
		tallest = 0;
		group.each(function() {
			thisHeight = $(this).height();
			if (thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}
	equalHeight($(".productBlocks .item"));

	// ACCOUNT INPUT LABELS as background
	// fill or empty email field onDefault
	if ($(".accountEmail").val() == "") {
		$(".accountEmail").css({ backgroundImage: "url(/images/account_input_email.gif)" });
	} else {
		$(".accountEmail").css({ backgroundImage: "url(/images/account_input_empty.gif)" });
	};
	// fill or empty password field onDefault
	if ($(".accountPassword").val() == "") {
		$(".accountPassword").css({ backgroundImage: "url(/images/account_input_password.gif)" });
	} else {
		$(".accountPassword").css({ backgroundImage: "url(/images/account_input_empty.gif)" });
	};
	// empty fiels onClick
	$(".accountEmail, .accountPassword").click(function() {
		$(this).css({ backgroundImage: "url(/images/account_input_empty.gif)" });
	});
	// empty fiels onBlur
	$(".accountEmail, .accountPassword").focus(function() {
		$(this).css({ backgroundImage: "url(/images/account_input_empty.gif)" });
	});
	// refill emailfield onBlur
	$(".accountEmail").blur(function() {
		if ($(".accountEmail").val() == "") {
			$(".accountEmail").css({ backgroundImage: "url(/images/account_input_email.gif)" });
		} else {
			$(".accountEmail").css({ backgroundImage: "url(/images/account_input_empty.gif)" });
		};
	});
	// refill passfield onBlur
	$(".accountPassword").blur(function() {
		if ($(".accountPassword").val() == "") {
			$(".accountPassword").css({ backgroundImage: "url(/images/account_input_password.gif)" });
		} else {
			$(".accountPassword").css({ backgroundImage: "url(/images/account_input_empty.gif)" });
		};
	});

	

	// WORK FILTERS
	$('.dropdowncontainer .dropdown').hover(function() { // show hide submenu 
		$(this).find("ul").show();
	}, function() {
		$(this).find("ul").hide();
	});

	$('.dropdowncontainer li a').click(function() { // select active sub
		$(this).parents("ul").hide();
	});



	/* PRODUCT THUMBS  */
	$('.minipictures a').hover(function() {
		$(this).parents('.minipictures').find('a.active').removeClass('active');
		$(this).addClass('active');
	}, function() {
	});

	/* ACCOUNT DATA TOGGLE */
	/* particulier-zakelijk-overheid */
	$("input[class='private'][@checked]").parents('form').find('tr.zakelijk, tr.overheid').hide();
	$("input[class='private']").click(function() {
		$("input[class='private']").parents('form').find('tr.zakelijk, tr.overheid').hide();
	})
	$("input[class='government'][@checked]").parents('form').find('tr.zakelijk').hide().parents('form').find('tr.overheid').show();
	$("input[class='government']").click(function() {
		$("input[class='government']").parents('form').find('tr.zakelijk').hide().parents('form').find('tr.overheid').show();
	})
	$("input[class='business'][@checked]").parents('form').find('tr.overheid').hide().parents('form').find('tr.zakelijk').show();
	$("input[class='business']").click(function() {
		$("input[class='business']").parents('form').find('tr.overheid').hide().parents('form').find('tr.zakelijk').show();
	})


	/* ACCOUNT DATA TOGGLE */
	// Function for checkboxes
	$.fn.check = function(mode) {
		var mode = mode || 'on'; // if mode is undefined, use 'on' as default
		return this.each(function() {
			switch (mode) {
				case 'on':
					this.checked = true;
					break;
				case 'off':
					this.checked = false;
					break;
				case 'toggle':
					this.checked = !this.checked;
					break;
			}
		});
	};

	/* afleveradres A*/
	$("input[class='cbDeliveryAddress'][@checked]").parents('form').find('.afleveradres').show();
	$("input[class='cbDeliveryAddress']").not(":checked").parents('form').find('.afleveradres').hide();
	$("input[class='cbDeliveryAddress']").click(function() {
		if ($("input[class='cbDeliveryAddress']").is(":checked")) {
			$("input[class='cbPickup']").check('off');
			$(".afleveradres").show();
		} else {
			$(".afleveradres").hide();
		}
	});


	/* afhalen A */
	$("input[class='cbPickup']").click(function() {
		if ($("input[class='cbPickup']").is(":checked")) {
			$("input[class='cbDeliveryAddress']").check("off");
			$(".afleveradres").hide();
		} else {
		}
	});

	/* FAQ TOGGLE */
	$('.faqList .faqAnswer').hide();
	$('.faqList .faqQuestion a').click(function() {
		$(this).parents('.faqList').find(".faqAnswer").slideUp(200); // Hide all answers
		$(this).parents('.faqList').find('li').removeClass("active");
		$(this).parents('li').find(".faqAnswer").slideDown(200); // Show current answer
		$(this).parents('li').addClass("active");
		return false;
	});

	/* NEWS TOGGLE */
	$('.archiveList .archiveHeader a').click(function() {
		$(this).parents('.archiveList').find('li').removeClass("active");
		$(this).parents('li').addClass("active");
		return false;
	});
	
	// SHOPPING CART PRODUCT MOUSEOVER
	$('.shoppingCart .thumb').hover(function() {
		$(this).css('position', 'relative');
		$(this).find('.zoom').show();
	}, function() {
		$(this).find('.zoom').hide();
		$(this).css('position', 'static');
	});



	/* TAB MENU  */
	$('#tabA a').click(function() {
		$('#tabA').find("a").addClass('active'); // make this tab active
		$('#tabB').find("a").removeClass('active'); // make tab inactive
		$('#tabC').find("a").removeClass('active'); // make tab inactive
		$('#tabD').find("a").removeClass('active'); // make tab inactive
		$('#tabE').find("a").removeClass('active'); // make tab inactive
		$('#tabContentA').addClass('active'); // show this content
		$('#tabContentB').removeClass('active'); // hide other content
		$('#tabContentC').removeClass('active'); // hide other content
		$('#tabContentD').removeClass('active'); // hide other content
		$('#tabContentE').removeClass('active'); // hide other content
		return false;
	});
	$('#tabB a').click(function() {
		$('#tabA').find("a").removeClass('active'); // make tab inactive
		$('#tabB').find("a").addClass('active'); // make this tab active
		$('#tabC').find("a").removeClass('active'); // make tab inactive
		$('#tabD').find("a").removeClass('active'); // make tab inactive
		$('#tabE').find("a").removeClass('active'); // make tab inactive
		$('#tabContentA').removeClass('active'); // hide other content
		$('#tabContentB').addClass('active'); // show this content
		$('#tabContentC').removeClass('active'); // hide other content
		$('#tabContentD').removeClass('active'); // hide other content
		$('#tabContentE').removeClass('active'); // hide other content
		return false;
	});
	$('#tabC a').click(function() {
		$('#tabA').find("a").removeClass('active'); // make tab inactive
		$('#tabB').find("a").removeClass('active'); // make tab inactive
		$('#tabC').find("a").addClass('active'); // make this tab active
		$('#tabD').find("a").removeClass('active'); // make tab inactive
		$('#tabE').find("a").removeClass('active'); // make tab inactive
		$('#tabContentA').removeClass('active'); // hide other content
		$('#tabContentB').removeClass('active'); // hide other content
		$('#tabContentC').addClass('active'); // show this content
		$('#tabContentD').removeClass('active'); // hide other content
		$('#tabContentE').removeClass('active'); // hide other content
		return false;
	});
	$('#tabD a').click(function() {
		$('#tabA').find("a").removeClass('active'); // make tab inactive
		$('#tabB').find("a").removeClass('active'); // make tab inactive
		$('#tabC').find("a").removeClass('active'); // make tab inactive
		$('#tabD').find("a").addClass('active'); // make this tab active
		$('#tabE').find("a").removeClass('active'); // make tab inactive
		$('#tabContentA').removeClass('active'); // hide other content
		$('#tabContentB').removeClass('active'); // hide other content
		$('#tabContentC').removeClass('active'); // hide other content
		$('#tabContentD').addClass('active'); // show this content
		$('#tabContentE').removeClass('active'); // hide other content
		return false;
	});
	$('#tabE a').click(function() {
		$('#tabA').find("a").removeClass('active'); // make tab inactive
		$('#tabB').find("a").removeClass('active'); // make tab inactive
		$('#tabC').find("a").removeClass('active'); // make tab inactive
		$('#tabD').find("a").removeClass('active'); // make tab inactive
		$('#tabE').find("a").addClass('active'); // make this tab active
		$('#tabContentA').removeClass('active'); // hide other content
		$('#tabContentB').removeClass('active'); // hide other content
		$('#tabContentC').removeClass('active'); // hide other content
		$('#tabContentD').removeClass('active'); // hide other content
		$('#tabContentE').addClass('active'); // show this content
		return false;
	});

	$('.contact_reactieformulier').click(function() {
		$('#tabB a').click(); // doe alsof er op de tweede tab geklikt is
		return false;
	});

	$('.contact_routebeschrijving').click(function() {
		$('#tabC a').click(); // doe alsof er op de derde tab geklikt is
		return false;
	});

	/* STRAATNAAMBORDENCONFIGURATOR */
	$('li.kleurKeuze').hover(function() { // show kleurkeuze
		$(this).find('ul').show();
	}, function() {
		$(this).find('ul').hide();
	});

};   // end ready function

function activateTab(tab) {
	$('#tabA').find("a").removeClass('active'); // make tab inactive
	$('#tabB').find("a").removeClass('active'); // make tab in active
	$('#tabC').find("a").removeClass('active'); // make tab inactive
	$('#tabD').find("a").removeClass('active'); // make tab inactive
	$('#tabE').find("a").removeClass('active'); // make tab inactive
	$('#tab' + tab).find("a").addClass('active'); // make this tab active

	$('#tabContentA').removeClass('active'); // hide other content
	$('#tabContentB').removeClass('active'); // hide other content
	$('#tabContentC').removeClass('active'); // hide other content
	$('#tabContentD').removeClass('active'); // hide other content
	$('#tabContentE').removeClass('active'); // hide other content
	$('#tabContent' + tab).addClass('active'); // show this content

}