$(document).ready(function(){
	
	var fadein=150;
	var fadeout=400;
	
	$(".home_blok").hover(
		function() {
			$(this).find('.grey').stop().animate({"opacity": "0"}, fadein);
			$(this).find('.tekst').css('margin-left','-210px');
			$(this).find('.tekst').stop().animate({"margin-left": "0"}, fadein);
		},
		function() {
			$(this).find('.grey').stop().animate({"opacity": "1"}, fadeout);
			$(this).find('.tekst').stop().animate({"margin-left": "210px"}, fadeout);
		}
	);

	$("#hmenu li").hover( 
		function() { $(this).addClass("iehover"); $(this).css('color','#FFF') }, 
			function() { $(this).removeClass("iehover"); } 
	);

	$("a.fancybox").fancybox();
	
	$("#educatie a.fancybox").fancybox({
		'autoDimensions' : false,
		'type' : 'iframe',
		'width' : 900,
		'height' : 500
	});
	
    $('#slideshow').cycle({
        fx:     'fade',
        speed:  500,
        timeout: 5000,
        pager:  '#nav',
		slideExpr: 'img'
    });
   
    $('#bannershow').cycle({
        fx:     'fade',
        speed:  500,
        timeout: 5000,
		pause: 1
    });
	
	$("#map_tip a[title]").clearQueue().stop().tooltip({
		offset: [-10, 2],
		effect: 'slide',
		direction:'down',
		bounce: true,
		slideInSpeed: 200,
		slideOutSpeed: 100,
		delay:20
	});
	
	$("#verhuur_tip a[title]").clearQueue().stop().tooltip({
		offset: [-10, 2],
		effect: 'slide',
		direction:'down',
		slideInSpeed: 200,
		slideOutSpeed: 100,
		bounce: true,
		delay:20
	});
	
	$("#aform").validate();
	
	$('.period1').rotate({
	bind:
		{
        mouseover : function() { 
            $(this).rotate({animateTo:10})
        },
        mouseout : function() { 
            $(this).rotate({animateTo:0})
        }
		}
	});
	$('.period2').rotate({
	bind:
		{
        mouseover : function() { 
            $(this).rotate({animateTo:15})
        },
        mouseout : function() { 
            $(this).rotate({animateTo:0})
        }
		}
	});
	$('.period3').rotate({
	bind:
		{
        mouseover : function() { 
            $(this).rotate({animateTo:-10})
        },
        mouseout : function() { 
            $(this).rotate({animateTo:0})
        }
		}
	});
	$('.period4').rotate({
	bind:
		{
        mouseover : function() { 
            $(this).rotate({animateTo:-15})
        },
        mouseout : function() { 
            $(this).rotate({animateTo:0})
        }
		}
	});
	
	var tel=0;

	function load_tweets(){
		$('.tweets').load('/inc/tweets.php',function(){
			tel++;
			$('.tweets').cycle({
				fx: 'scrollUp',
				timeout: 5000,
				speed: 1000,
				//autostop: 1, 
				end:      function() {  
					load_tweets();
				}
			});
		
		});
	}
	
	load_tweets();
	
	function stamp(){
		$('.stamp img').css("display", "block").css("opacity", "0").animate({width:'130px',height:'130px', opacity:1}, {queue:false, duration: 1000, easing: 'easeOutElastic'});
	}
	setTimeout(stamp, 1000);
	
	$('.flip_logo').bind("click",function(){
		// $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):
		var elem = $(this);
		// data('flipped') is a flag we set when we flip the element:
		if(elem.data('flipped')){
			// If the element has already been flipped, use the revertFlip method
			// defined by the plug-in to revert to the default state automatically:
			elem.revertFlip();
			// Unsetting the flag:
			elem.data('flipped',false)
		}else{
			// Using the flip method defined by the plugin:
			elem.flip({
				direction:'lr',
				speed: 350,
				color: '#E9E9E9',
				onBefore: function(){
					// Insert the contents of the .sponsorData div (hidden from view with display:none)
					// into the clicked .sponsorFlip div before the flipping animation starts:
					elem.html(elem.siblings('.flip_data').html());
				}
			});
			// Setting the flag:
			elem.data('flipped',true);
		}
	});

});

