// 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');
	});

	   $(".formfields .choice a.selector").click(function () {
	   	$(this).parents(".choice").addClass("active");
	   	//return false; //disabled postback
	   });

	// 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;
			}
		});
	};
	

}); // end ready function
