$(document).ready(function(){
	
	/* Standaard fomulieren submitten */
	$(".ajaxform").submit(function(){
		var $this	= $(this);
		$.ajax({
			type:			'POST',
			url: 			HLINK+'public/js/ajax/submitform.php',
			data:			$this.serialize(),
			success:		function(data){
				var $messbox	= $this.find(".messbox");
				$('.messbox').hide();

				switch(data.status)
				{
					case 'error':
						$messbox.fadeOut(function(){
							$messbox.html(data.message).attr('class','messbox error');
							$messbox.fadeIn();
							$('html, body').animate({ scrollTop: 0 },'slow');
						});
					break;
					case 'success':
						$messbox.fadeOut(function(){
							$messbox.html(data.message).attr('class','messbox success');
							$messbox.fadeIn();
							$(".ajaxform")[0].reset();
							if(data.pageforward!='') {
								window.location.href = data.pageforward;
							}
							if(data.reloadpage!='') {
								document.location.reload();
							}
							$('.hide-after-submit').css('display','none');
							$('html, body').animate({ scrollTop: 0 },'slow');
						});
						setTimeout(function(){$messbox.fadeOut();},5000);
					break;
				}
			}
		});
		return false;
	});
	
	
	$('#teaserClue').hide();
	$('.teaser2Outer:eq(0) img:last').mouseenter(function(){
		$('#teaserClue').show('slow',
		function(){
		setTimeout( function(){
			$('#teaserClue').hide('fast');}, 2000);
		});
	});
    $('#teaser1Outer').cycle({
		fx: 'fade',
		speed:5000,
		random:  1 
    });
    
    $(".inloggen").click(function () {
    	$("#uitklappen").fadeToggle()
    });
	
	$(".hoversocial").hover(function () {
		$(this).attr("src", $(this).attr("src").replace(".png", "_over.png"));
	}, function() {
		$(this).attr("src", $(this).attr("src").replace("_over.png", ".png"));
	});	
	
	$(".rekmod").change(function() {
        $('.rekmod-option').hide();
        var tmp = '.'+this.value;
        $(tmp).show();
    });	
    
	$('.media').media({
		width: 400,
		height: 24,
		autoplay: false
	}); 
	
	$("#youtube").fancybox({
		'type': 'iframe'
	});

	


	
	$(".inline").fancybox();
	
	$('#lessthansix div').css('display','none')
	$('.datepicker').datepicker({
		dateFormat: 'dd-mm-yy',
		changeMonth: true,
		changeYear: true,
		showWeek: true,
		yearRange: '1900:2020'
	});
	
	
	$('.aant_werkn').change(function(){
		$('#lessthansix div').css('display','none')
		for(i=0;i<=$(this).val();i++){
			$('#employee'+i).css('display','block');
		}
	});
	
	
	// KERST
	/*
	$("#button1").tooltip({
		effect: 'toggle',
		position: 'top center',
	});
	$("#button2").tooltip({
		effect: 'toggle',
		position: 'top center'
	});
	*/
	
	function changebox(box, sender) {
		$(".stripTransmitter").stopTime("asld");
         $(".box").each(function() {
			$(this).hide();
		})
		$(box).show();
		
	}
	
	$(".profiel_l").bind("mouseup", function() {
		changebox("#box2", this);
		jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current");
	});
	$(".goudentip_l").bind("mouseup", function() {
		changebox("#box3", this);
		jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current");
    });
	
	$(".filmpje_l").bind("mouseup", function() {
		changebox("#box4", this);
		jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current");
		
    });
	
	$("#closebox").bind('mouseup', function() {
		parent.$.fancybox.close;
	});
	

	$('.extra').click(function () {
		return false;
	});
	
	
	$('.tooltip').css({'bottom':'30px','left':'-30px'});
	
	$('#a1').hover(function () {
		$('#tooltip1').fadeIn();
	}, function () {
		$('#tooltip1').fadeOut();
	});
	
	$('#a2').hover(function () {
		$('#tooltip2').fadeIn();
	}, function () {
		$('#tooltip2').fadeOut();
	});
	
});

$(window).bind("load", function() {
	$("div#gallery").slideViewerPro({
		easeFunc: "easeInOutExpo",
        easeTime: 750,
        galBorderWidth: 6,
        galBorderColor: "#ff0000",
        thumbsPercentReduction: 12,
        thumbs: 5,
        thumbsTopMargin: 3,
        thumbsRightMargin: 3,
        thumbsBorderWidth: 3,
        thumbsBorderColor: "#d8d8d8",
        thumbsActiveBorderColor: "#ff0000",
        thumbsBorderOpacity: 1.0, // could be 0, 0.1 up to 1.0
        thumbsActiveBorderOpacity: 1.0, // could be 0, 0.1 up to 1.0
        autoslide: true,
        asTimer: 5000,
        buttonsWidth: 20,
        buttonsTextColor: "#ff0000",
        leftButtonInner: "-",
        rightButtonInner: "+", 
        typo: false,
        navigator: 'text'
	});

});
