
Cufon.replace('.header ul.menu li a, .overview-title, li.recipe-register, div.recipe-register-div-notregistered, div.recipe-register-div-registered, div.recipe-title, a.unsubscribe-link', { fontFamily: 'AvenirLTStd' });
Cufon.replace('div.account h3,div.account h4,div.questions div.question div.questionText', { fontFamily: 'arial' });
Cufon.replace('div.account .info .title, ul.team li div .profession, ul.expert_short li a .profession, ul.expert_long li .profession, .results .result .result_content .label,.results .expertlinks .label,.minirapport .col2 ul.results li span.label,.minirapport .col1 .label, .expert-head, .special-head, .about-head, .news-head, .about-head, .tool-head, #MainContent_ContentHeader_MiniRapport_3_plhIntro h2', { fontFamily: 'GothamMedium' });
Cufon.replace('h1, div.account h2, .container .content div.questions h2, ul.team li div .name, ul.expert_short li a .name, ul.expert_long li .name, .tekst-kop, .tekst-inleiding, .tekst-subkop, .tekst-subsubkop, .tekst-quote', { fontFamily: 'LucidaGrande' });
Cufon.replace('span.ageresult, div.account .agebio .icon, .results .result .result_content .icon span,.minirapport .col2 ul.results li span.number,.minirapport .col1 ul.myage li, .age-first, .age-second, .age-third, .age, #calculation h3, .score, .content_header .info h2, .content_header .info h1, .points, h2.date, h2.owner, .partner-block h1.realage, .partner-block h2, .partner-block .more-partner span.title, .benchmark h1, .benchmark-small h1, .overlay-age, .previous-recipes', { fontFamily: 'gotham-bold' });
Cufon.replace('.results ul.tabs li a span.mid,.results .panes .pane_wrapper .pane ul li.record .text_wrapper .title latest-news h2', { fontFamily: 'LucidaGrande' });
Cufon.replace('h1.gezinnen, h1.episodes', { fontFamily: 'GothamMedium' });
Cufon.replace('div.recept-header h1, div.overview-title h1', { fontFamily: 'Avenir_LT_Std_Bold' });

jQuery.extend({
    random: function (min, max) {
        return Math.round(min + ((max - min) * (Math.random() % 1)));
    }
});


$(function () {
    if (jQuery('#slider-range').length > 0) {
        $("#slider-range").slider({
            range: true,
            min: 0,
            max: 100,
            values: [18, 40],
            slide: function (event, ui) {
                $("#amount").val(ui.values[0] + " jaar - " + ui.values[1] + " jaar");
                $("#amount-min").val(ui.values[0]);
                $("#amount-max").val(ui.values[1]);

            }
        });
        $("#amount").val($("#slider-range").slider("values", 0) +
		    " jaar - " + $("#slider-range").slider("values", 1) + " jaar");
        $("#amount-min").val($("#slider-range").slider("values", 0));
        $("#amount-max").val($("#slider-range").slider("values", 1));
        var i = 0;
        $("#slider-range").children().each(function () {
            var child = $(this);
            if (i == 2) {
                /*ui-slider-handle ui-state-default ui-corner-all rightslider*/
                $(child).removeClass("ui-state-default");
                $(child).addClass("ui-state-default-right");
            }
            i = i + 1;
        });
        if (typeof slidergrey == "undefined") {
            $(".ui-widget-content").addClass("greyedout");
            $(".ui-widget-header").addClass("greyedout");
            $("#amount").css({ color: "#ccc" });
        }
    }
});


jQuery(document).ready(function () {
	CalcAge();
    
	if (jQuery('#tickerfeed').length > 0) {
        $('#tickerfeed').vTicker({
            speed: 500,
            pause: 3000,
            showItems: 3,
            animation: 'fade',
            mousePause: true,
            height: 0,
            direction: 'down'
        });
    };

    if (jQuery('#tickerfeed-small').length > 0) {
        $('#tickerfeed-small').vTicker({
            speed: 500,
            pause: 3000,
            showItems: 2,
            animation: 'fade',
            mousePause: true,
            height: 0,
            direction: 'down'
        });
    };

    jQuery('.results li').hover(function () {
        jQuery(this).find('.label').show();
        jQuery(this).find('.number').hide();
    }, function () {
        jQuery(this).find('.label').hide();
        jQuery(this).find('.number').show();
    });

});

jQuery(document).ready(function () {
	var stickerage = $('.container .content .column1_2 .sticker_age');
	if (stickerage.length > 0) {
		stickerage.prev('h1').addClass('small');
	}
	PrepareColumns();
	$('.login').SingleTopLogin();
	$('.results').Dossier();
	$('.expert_long').ExpertLong();

	if ($("ul.tabs").length > 0) {
		$("ul.tabs").tabs("div.panes > div");
	}

	$('.content_header').find('li').hover(function () {
		$(this).find('.person').css('display', 'none');
		$(this).find('.info').css('display', 'block');
	}, function () {
		$(this).find('.person').css('display', 'block');
		$(this).find('.info').css('display', 'none');
	});

	$('#yourscore .friend').hover(function () {
		$(this).find('img').hide();
		$(this).find('.realage').show();
		$(this).find('.sticker .points').hide();
		$(this).find('.right').addClass('equal2');
		$(this).find('.age').show();
	}, function () {
		$(this).find('img').show();
		$(this).find('.realage').hide();
		$(this).find('.sticker .points').show();
		$(this).find('.right').removeClass('equal2');
		$(this).find('.age').hide();
	});

	$('.content-carroussel .item').hover(function () {
		$(this).addClass('active');
	}, function () {
		$(this).removeClass('active');
	});

});

function PrepareColumns() {
	$('.column1_2').each(function () {
		$(this).parents('div').addClass('seperator');
	});
};

jQuery(document).ready(function () {
    jQuery('.faq_title').click(function () {
        jQuery(this).next('div.faqtext').toggle();

        if( jQuery( this ).hasClass( 'close' ) ){
            jQuery(this).removeClass('close');
        } else {
            jQuery(this).addClass('close');
        }
    });
});

jQuery(document).ready(function () {
    function pulsate_frl() {
        
        $("#map_frl").
          animate({ opacity: 0.2 }, 1000, 'linear').
          animate({ opacity: 1 }, 1050, 'linear', pulsate_frl);
    }
    function pulsate_grn() {
        $("#map_grn").
          animate({ opacity: 0.2 }, 950, 'linear').
          animate({ opacity: 1 }, 1000, 'linear', pulsate_grn);
    }
    function pulsate_nhl() {
        $("#map_nhl").
          animate({ opacity: 0.2 }, 1100, 'linear').
          animate({ opacity: 1 }, 1075, 'linear', pulsate_nhl);
    }
    function pulsate_zhl() {
        $("#map_zhl").
          animate({ opacity: 0.2 }, 875, 'linear').
          animate({ opacity: 1 }, $.random(700, 1300), 'linear', pulsate_zhl);
    }
    function pulsate_zee() {
        $("#map_zee").
          animate({ opacity: 0.2 }, 925, 'linear').
          animate({ opacity: 1 }, 1000, 'linear', pulsate_zee);
    }
    function pulsate_flv() {
        $("#map_flv").
          animate({ opacity: 0.2 }, 1125, 'linear').
          animate({ opacity: 1 }, 980, 'linear', pulsate_flv);
    }
    function pulsate_gld() {
        $("#map_gld").
          animate({ opacity: 0.2 }, 1025, 'linear').
          animate({ opacity: 1 }, 975, 'linear', pulsate_gld);
    }
    function pulsate_ovr() {
        $("#map_ovr").
          animate({ opacity: 0.2 }, 1000, 'linear').
          animate({ opacity: 1 }, 1200, 'linear', pulsate_ovr);
    }
    function pulsate_drn() {
        $("#map_drn").
          animate({ opacity: 0.2 }, 900, 'linear').
          animate({ opacity: 1 }, 1000, 'linear', pulsate_drn);
    }
    function pulsate_nbr() {
        $("#map_nbr").
          animate({ opacity: 0.2 }, 950, 'linear').
          animate({ opacity: 1 }, 1050, 'linear', pulsate_nbr);
    }
    function pulsate_lmb() {
        $("#map_lmb").
          animate({ opacity: 0.2 }, 1100, 'linear').
          animate({ opacity: 1 }, 1150, 'linear', pulsate_lmb);
    }
    function pulsate_utr() {
        $("#map_utr").
          animate({ opacity: 0.2 }, 1075, 'linear').
          animate({ opacity: 1 }, 925, 'linear', pulsate_utr);
    }
    if (jQuery('.map').length > 0) {
        pulsate_frl();
        pulsate_grn();
        pulsate_nhl();
        pulsate_zhl();
        pulsate_zee();
        pulsate_flv();
        pulsate_gld();
        pulsate_ovr();
        pulsate_drn();
        pulsate_nbr();
        pulsate_lmb();
        pulsate_utr();
    }
});

jQuery.fn.ExpertLong = function () {
	$('li.first', this).each(function () {
		var $this = $(this);
		var $next = $this.next();

		if ($next.length > 0) {
			try {
				var i = Math.max($('.info', $this).height(), $('.info', $next).height());
				$('.info', $this).height(i);
				$('.info', $next).height(i);
			}
			catch (err) {
			}

			try {
				var u = Math.max($('ul', $this).height(), $('ul', $next).height());
				$('ul', $this).height(u);
				$('ul', $next).height(u);
			}
			catch (err) {
			}
		}
	});
};

jQuery.fn.Dossier = function () {
	//Short
	var $result = $('.result', $result);
	$('.result_content .actionplan', $result).hide();
	$('.result_content .expertlinks', $result).hide();
	$('.result_content', this).removeClass('open');

	$('.result_content a:eq(0)', $result).click(function (e) {
		e.preventDefault();
		var parent = $(this).parents('.result_content');
		$('.actionplan', parent).toggle('slow');
		$('.expertlinks', parent).toggle('slow', function () {
			//ie7 fix
			if (jQuery.browser.msie && jQuery.browser.version < 8) {
				$('.footer').html($('.footer').html());
			}
		});
		parent.toggleClass('open');
	});
	//Long
	$('.panes .pane_wrapper .pane ul li.record .text_wrapper > div', this).hide();
	$('.panes .pane_wrapper .pane ul li.record', this).removeClass('open');

	$('.panes .pane_wrapper .pane ul li.record .text_wrapper a.switch', this).click(function (e) {
		e.preventDefault();
		var $next = $(this).next();
		$next.toggle('slow', function () {
			//ie7 fix
			if (jQuery.browser.msie &&  jQuery.browser.version < 8) {
				$('.footer').html($('.footer').html());
			}
		});
		$(this).parents('li.record').toggleClass('open');

	});
}
jQuery.fn.SingleTopLogin = function () {
	var $this = $(this);
	var $password = $('input.password', $this);
	var $passwordtext = $('input.passwordtext', $this);

	if ($password.val() == '') {
		$password.hide();
		$passwordtext.show();
	}
	else {
		$passwordtext.hide();
	}

	$passwordtext.focus(function () {
		$passwordtext.hide();
		$password.show().focus();
	});

	$password.blur(function () {
		if ($(this).val() == '') {
			$password.hide();
			$passwordtext.show();
		}
	});

	$('input:not(.password, .passwordtext)', $this).DefaultValueField();
}

jQuery.fn.DefaultValueField = function () {
	$(this).each(function () {
		var word = $(this).val();

		$(this).blur(function () {
			if ($(this).val() == '') {
				$(this).val(word);
			}
		}).focus(function () {
			if ($(this).val() == word) {
				$(this).val('');
			}
		});

	});
};

(function ($) {
    $.tiny = $.tiny || {}; $.tiny.scrollbar = { options: { axis: 'y', wheel: 40, scroll: true, size: 'auto', sizethumb: 'auto'} }; $.fn.tinyscrollbar = function (options) { var options = $.extend({}, $.tiny.scrollbar.options, options); this.each(function () { $(this).data('tsb', new Scrollbar($(this), options)); }); return this; }; $.fn.tinyscrollbar_update = function (sScroll) { return $(this).data('tsb').update(sScroll); }; function Scrollbar(root, options) {
        var oSelf = this; var oWrapper = root; var oViewport = { obj: $('.viewport', root) }; var oContent = { obj: $('.overview', root) }; var oScrollbar = { obj: $('.scrollbar', root) }; var oTrack = { obj: $('.track', oScrollbar.obj) }; var oThumb = { obj: $('.thumb', oScrollbar.obj) }; var sAxis = options.axis == 'x', sDirection = sAxis ? 'left' : 'top', sSize = sAxis ? 'Width' : 'Height'; var iScroll, iPosition = { start: 0, now: 0 }, iMouse = {}; function initialize() { oSelf.update(); setEvents(); return oSelf; }
        this.update = function (sScroll) { oViewport[options.axis] = oViewport.obj[0]['offset' + sSize]; oContent[options.axis] = oContent.obj[0]['scroll' + sSize]; oContent.ratio = oViewport[options.axis] / oContent[options.axis]; oScrollbar.obj.toggleClass('disable', oContent.ratio >= 1); oTrack[options.axis] = options.size == 'auto' ? oViewport[options.axis] : options.size; oThumb[options.axis] = Math.min(oTrack[options.axis], Math.max(0, (options.sizethumb == 'auto' ? (oTrack[options.axis] * oContent.ratio) : options.sizethumb))); oScrollbar.ratio = options.sizethumb == 'auto' ? (oContent[options.axis] / oTrack[options.axis]) : (oContent[options.axis] - oViewport[options.axis]) / (oTrack[options.axis] - oThumb[options.axis]); iScroll = (sScroll == 'relative' && oContent.ratio <= 1) ? Math.min((oContent[options.axis] - oViewport[options.axis]), Math.max(0, iScroll)) : 0; iScroll = (sScroll == 'bottom' && oContent.ratio <= 1) ? (oContent[options.axis] - oViewport[options.axis]) : isNaN(parseInt(sScroll)) ? iScroll : parseInt(sScroll); setSize(); }; function setSize() { oThumb.obj.css(sDirection, iScroll / oScrollbar.ratio); oContent.obj.css(sDirection, -iScroll); iMouse['start'] = oThumb.obj.offset()[sDirection]; var sCssSize = sSize.toLowerCase(); oScrollbar.obj.css(sCssSize, oTrack[options.axis]); oTrack.obj.css(sCssSize, oTrack[options.axis]); oThumb.obj.css(sCssSize, oThumb[options.axis]); }; function setEvents() {
            oThumb.obj.bind('mousedown', start); oThumb.obj[0].ontouchstart = function (oEvent) { oEvent.preventDefault(); oThumb.obj.unbind('mousedown'); start(oEvent.touches[0]); return false; }; oTrack.obj.bind('mouseup', drag); if (options.scroll && this.addEventListener) { oWrapper[0].addEventListener('DOMMouseScroll', wheel, false); oWrapper[0].addEventListener('mousewheel', wheel, false); }
            else if (options.scroll) { oWrapper[0].onmousewheel = wheel; } 
        }; function start(oEvent) { iMouse.start = sAxis ? oEvent.pageX : oEvent.pageY; var oThumbDir = parseInt(oThumb.obj.css(sDirection)); iPosition.start = oThumbDir == 'auto' ? 0 : oThumbDir; $(document).bind('mousemove', drag); document.ontouchmove = function (oEvent) { $(document).unbind('mousemove'); drag(oEvent.touches[0]); }; $(document).bind('mouseup', end); oThumb.obj.bind('mouseup', end); oThumb.obj[0].ontouchend = document.ontouchend = function (oEvent) { $(document).unbind('mouseup'); oThumb.obj.unbind('mouseup'); end(oEvent.touches[0]); }; return false; }; function wheel(oEvent) { if (!(oContent.ratio >= 1)) { oEvent = $.event.fix(oEvent || window.event); var iDelta = oEvent.wheelDelta ? oEvent.wheelDelta / 120 : -oEvent.detail / 3; iScroll -= iDelta * options.wheel; iScroll = Math.min((oContent[options.axis] - oViewport[options.axis]), Math.max(0, iScroll)); oThumb.obj.css(sDirection, iScroll / oScrollbar.ratio); oContent.obj.css(sDirection, -iScroll); oEvent.preventDefault(); }; }; function end(oEvent) { $(document).unbind('mousemove', drag); $(document).unbind('mouseup', end); oThumb.obj.unbind('mouseup', end); document.ontouchmove = oThumb.obj[0].ontouchend = document.ontouchend = null; return false; }; function drag(oEvent) {
            if (!(oContent.ratio >= 1)) { iPosition.now = Math.min((oTrack[options.axis] - oThumb[options.axis]), Math.max(0, (iPosition.start + ((sAxis ? oEvent.pageX : oEvent.pageY) - iMouse.start)))); iScroll = iPosition.now * oScrollbar.ratio; oContent.obj.css(sDirection, -iScroll); oThumb.obj.css(sDirection, iPosition.now); ; }
            return false;
        }; return initialize();
    };
})(jQuery);

function PostbackWhenEnterPress(e) {    
    if (e.keyCode == 13){
        $('#login').click();
    }
};

function SelectHomeSpecial(triggerItem, itemId) {
    $(triggerItem).parent().parent().children().removeClass('selected')
    $(triggerItem).parent().addClass('selected')

    $('#specialHomeContainer').children().hide();
    $('#' + itemId).show();
}

$(function () {
    var ageSelectionDiv = $('div.age_selection');
    var daySelect = ageSelectionDiv.find('.day');
    var monthSelect = ageSelectionDiv.find('.month');
    var yearSelect = ageSelectionDiv.find('.year');

    daySelect.change(function () {
        CalcAge();
    });

    monthSelect.change(function () {
        CalcAge();
    });

    yearSelect.change(function () {
        CalcAge();
    });
});

function CalcAge() {
    var ageSelectionDiv = $('div.age_selection');
    var daySelect = ageSelectionDiv.find('.day');
    var monthSelect = ageSelectionDiv.find('.month');
    var yearSelect = ageSelectionDiv.find('.year');
    var ageIcon = $('div.agebio div.icon');

    var selectedDay = daySelect.val();
    var selectedMonth = monthSelect.val();
    var selectedYear = yearSelect.val();

    var birthDate = new Date(selectedYear, selectedMonth - 1, selectedDay);
    var now = new Date();

    var age = now.getFullYear() - selectedYear;

    if (((now.getMonth() + 1) < selectedMonth) || (((now.getMonth() + 1) == selectedMonth) && (now.getDate() < selectedDay)))
        age--;

    age = Math.floor(age);

    if (age > 100) {
        age = '?';
    }

    ageIcon.html(age);

    Cufon.replace('div.account .agebio .icon', { fontFamily: 'gotham-bold' });
}

var carrouselStart = 5;
var carrouselDelay = 1;

function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function () {
        carousel.stopAuto();
        setTimeout(function () { carousel.startAuto(carrouselDelay) }, (carrouselStart - carrouselDelay) * 1000);
    });

    carousel.buttonPrev.bind('click', function () {
        carousel.stopAuto();
        setTimeout(function () { carousel.startAuto(carrouselDelay) }, (carrouselStart - carrouselDelay) * 1000);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function () {
        carousel.stopAuto();
    }, function () {
        carousel.startAuto();
    });

    setTimeout(function () { carousel.startAuto(carrouselDelay) }, (carrouselStart - carrouselDelay) * 1000);
   };

jQuery(document).ready(function () {
	$("div.benchmark .data h1 span").liveCounter();
	$("div.benchmark-small .data h1 span").liveCounter();
});

(function( $ ){
 
    $.fn.digits = function() {
        return this.each(function() {
            $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1.") );
        })
    }
 
    $.fn.liveCounter = function( options ) {
 
        var settings = {
            'start_date'   : 'June 15, 2011 20:00:00',
            'start_cnt'    : 1437215 ,
            'wait_secs'    : 10,
            'increase_by'  : 1
        };
 
        return this.each(function() {
            if ( options ) {
                $.extend( settings, options );
            }
 
            var start_date = settings['start_date'];
            var start_cnt = settings['start_cnt'];
            var wait_secs = settings['wait_secs'];
            var increase_by = settings['increase_by'];
 
            var element = this;
 
            var date = Math.round( new Date(start_date).getTime() / 1000 );
            var today = Math.round( new Date().getTime() / 1000 );
 
            start_cnt += Math.round( (today - date) / wait_secs );
 
            $(element).text(start_cnt).digits();
 
            function updateCnt() {
                start_cnt = start_cnt + increase_by;
                $(element).text(start_cnt).digits();
				Cufon.replace('.benchmark h1 span, .benchmark-small h1 span', { fontFamily: 'gotham-bold' });
            }
 
            setInterval( updateCnt, wait_secs * 1000 );
        })
    }
 
})( jQuery );

