// JQUERY CUSTOM COMMANDS
$(document).ready( function() {  // start javascript when document is loaded
    
    /* SEO */
    $('#seo').clone().addClass('seo').appendTo('#primaryContent');
    $('#seo').remove();

	/* TOOLTIPS */
	$('.tooltip').hide();
	$('.tooltipLink').hover(function() {
	    $(this).find('.tooltip').fadeIn(500);
		return false;
	}, function() {
	    $(this).find('.tooltip').fadeOut(100);
		return false;
	});
	
	// MAIN MENU
	$('#mainMenu li').hover(function() { // show hide submenu 
	    $(this).addClass('hover');
	}, function() {
	    $(this).removeClass('hover');
	});
	
	// ACCOUNT INPUT LABELS as background
	$(".accountEmail:empty").css({ backgroundImage : "url(/images/account_input_email.gif)" });
	$(".accountPassword:empty").css({ backgroundImage : "url(/images/account_input_password.gif)" });
	$(".accountEmail, .accountPassword").click(function() {
		$(this).css({ backgroundImage : "url(images/account_input_empty.gif)" });
	});
	
	// SUBCATEGORIES
	$('.subCategoryList').find('li:gt(4)').not('.more').hide();
	$(".subCategoryList .more a").click(function() {
		$('.subCategoryList li').show();
		$('.subCategoryList li.more').hide();
		$('.subCategoryList').css({ minHeight : "150px" });
	});
	
	// SERVICE
	$('.serviceList li').not('.active').find('.content').hide();
	$(".serviceList li .title").click(function() {
		$('.serviceList li').removeClass('active').find('.content').hide();
		$(this).parents('li').addClass('active').find('.content').show();
	});
	
	/* FAQ */
	$(".faq .faqAnswer").hide();
	$(".faq .faqQuestion a").click(function() {
		$(this).parents("#content").find(".faqAnswer").slideUp(200); // Hide all answers
		$(this).parents("#content").find("li").removeClass("active");
	    $(this).parents("li").find(".faqAnswer").slideDown(200); // Show current answer
		$(this).parents("li").addClass("active");
		return false;
	});
	
	/* 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 */
	$("input[@id='fc_afleveradres'][@checked]").parents('.cartForm').find('.afleveradres').show();
	$("input[@id='fc_afleveradres']").not(":checked").parents('.cartForm').find('.afleveradres').hide();
	$("input[@id='fc_afleveradres']").click(function () {
      if ($("input[@id='fc_afleveradres']").is(":checked")) {
	  	$("input[@id='fc_afhalenwinkel']").check('off');
		$(".zorgwinkel").hide();
        $(".afleveradres").show();
      } else {
        $(".afleveradres").hide();
      }
    });
	/* zorgwinkel */
	$("input[@id='fc_afhalenwinkel'][@checked]").parents('.cartForm').find('.zorgwinkel').show();
	$("input[@id='fc_afhalenwinkel']").not(":checked").parents('.cartForm').find('.zorgwinkel').hide();
	$("input[@id='fc_afhalenwinkel']").click(function () {
      if ($("input[@id='fc_afhalenwinkel']").is(":checked")) {
        $("input[@id='fc_afleveradres']").check("off");
		$(".afleveradres").hide();
		$(".zorgwinkel").show();
      } else {
        $(".zorgwinkel").hide();
      }
    });
	/* afleveradres B */
	$("input[@id='fc_afleveradres_B'][@checked]").parents('.cartForm').find('.afleveradres_B').show();
	$("input[@id='fc_afleveradres_B']").not(":checked").parents('.cartForm').find('.afleveradres_B').hide();
	$("input[@id='fc_afleveradres_B']").click(function () {
      if ($("input[@id='fc_afleveradres_B']").is(":checked")) {
	  	$("input[@id='fc_afhalenwinkel_B']").check('off');
		$(".zorgwinkel_B").hide();
        $(".afleveradres_B").show();
      } else {
        $(".afleveradres_B").hide();
      }
    });
	/* zorgwinkel B */
	$("input[@id='fc_afhalenwinkel_B'][@checked]").parents('.cartForm').find('.zorgwinkel_B').show();
	$("input[@id='fc_afhalenwinkel_B']").not(":checked").parents('.cartForm').find('.zorgwinkel_B').hide();
	$("input[@id='fc_afhalenwinkel_B']").click(function () {
      if ($("input[@id='fc_afhalenwinkel_B']").is(":checked")) {
        $("input[@id='fc_afleveradres_B']").check("off");
		$(".afleveradres_B").hide();
		$(".zorgwinkel_B").show();
      } else {
        $(".zorgwinkel_B").hide();
      }
    });

}); // end ready function


