$(document).ready(function() {
	//------------------main media tabs----------------------
	//When page loads...
	$(".tab_content1").hide(); //Hide all content
	$("ul.tabs1 li:first").addClass("active").show(); //Activate first tab
	$(".tab_content1:first").show(); //Show first tab content
	
	//Agenda archief tabs
	$('.agntabs li').click(function(){
		switch_agntabs($(this));
	});
 	switch_agntabs($('.active'));
	
	//On Click Event
	$("ul.tabs1 li").click(function() {

		$("ul.tabs1 li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content1").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
    

	$("#footer span").FontEffect( {
    	shadow          :true, // Apply the shadow effect
    	shadowColor     :"#000",// The color of the shadow
    	shadowOffsetTop :1,     // The top offset position (px)
    	shadowOffsetLeft:1,     // The left offset position (px)
    	shadowBlur      :2,     // The shadow blur 1=none,2=low,3=high
    	shadowOpacity   :0.1   // The opacity of the shadow (0=none,1=all)
	})
	
	/*form validations*/
	$("#contactForm").validate({  //voorletters achternaam adres postcode plaats telefoon mobiel email opmerkingen
		rules: {
			voorletters: 	{required: true,minlength: 2},
			achternaam: 	{required: true,minlength: 2},
			adres: 			{required: true,minlength: 2},
			postcode:		{minlength: 2},
			plaats: 		{minlength: 2},
			telefoon: 		{minlength: 2},
			mobiel:			{minlength: 2},
			email: 			{required:true, email:true},
			opmerkingen: 	{required: true,minlength: 2}
		}
	});
	
	$("#boekForm").validate({  //datum tijd plaats gelegenheid bedrijfsnaam contactpersoon adres psotcode woonplaats telefoon email
		rules: {
			datum:			{required: true,minlength: 2},
			tijd:			{required: true},
			plaats:			{required: true,minlength: 2},
			gelegenheid:	{minlength: 2},
			bedrijfsnaam:	{minlength: 2},
			contactpersoon:	{required: true,minlength: 2},
			adres:			{minlength: 2},
			postcode:		{minlength: 2},
			woonplaats:		{required: true,minlength: 2},
			telefoon:		{required: true,minlength: 2},
			email:			{required:true, email:true}
		}
		
	});
	
	$("#gastenboekForm").validate({  //naam woonplaats email website opmerkingen
		rules: {
			naam: 			{required: true,minlength: 2},
			woonplaats: 	{minlength: 2},
			email: 			{email:true},
			website: 		{minlength: 2},
			opmerkingen: 	{required: true,minlength: 2}
		}
	
	});
	
	$("#lidwordenForm").validate({  //voornaam. achternaam. adres postcode woonplaats. telefoon. 2e telefoon email. geboortedatum. geslacht. beroep eigen auto ervaring motivatie 
		rules: {
			voornaam:		{required: true,minlength: 2},
			achternaam:		{required: true,minlength: 2},
			adres:			{minlength: 2},
			postcode:		{minlength: 4},
			woonplaats:		{required: true,minlength: 2},
			telefoon:		{required: true,minlength: 8},
			telefoon2:		{minlength: 8},
			email:			{required:true, email:true},
			gebdat:			{required: true,minlength: 8},
			geslacht:		{required: true},
			beroep:			{},
			eigenauto:		{},
			ervaring:		{minlength: 8},
			motivatie:		{minlength: 8}
			
		}
	});
	
	$("#cdsForm").validate({  //voorletters achternaam adres postcode woonplaats email telefoon mobiel opmerkingen
		rules: {
			cd_onze:		{required: true,number:true},
			cd_live:		{required: true,number:true},
			voorletters:	{required: true},
			achternaam:		{required: true,minlength: 2},
			adres:			{required: true,minlength: 2},
			postcode:		{required: true,minlength: 4},
			woonplaats:		{required: true,minlength: 2},
			email:			{required: true, email:true},
			telefoon:		{minlength: 8},
			mobiel:			{minlength: 8}
		}
	});
	
	$("#cv100Form").validate({  //aanmelden voorletters achternaam gebdat geslacht adres postcode woonplaats email telefoon mobiel vrije_tekst vermelden_naam vermelden_email
		rules: {
			aanmelden:		{required: true},
			voorletters:	{required: true},
			achternaam:		{required: true,minlength: 2},
			gebdat:			{required: true,minlength: 8},
			geslacht:		{required: true},
			adres:			{minlength: 2},
			postcode:		{minlength: 4},
			woonplaats:		{required: true,minlength: 2},
			email:			{required:true, email:true},
			telefoon:		{minlength: 8},
			mobiel:			{minlength: 8},
			vrije_tekst:	{maxlength:50}
		}
	});
	
	
});



function switch_agntabs(obj)
{
	$('.agntab-content').fadeOut();
	$('.agntabs li').removeClass("active");
	var id = obj.attr("rel");
 
	$('#'+id).fadeIn();
	obj.addClass("active");
}

/***  slideshow homepage ***/
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    var $sibs  = $active.siblings();
    var rndNum = Math.floor(Math.random() * $sibs.length );
    var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

function getgallery(media,pageid,title){
	if (media=='foto') {
		url='gallery.asp?media=foto&pageid='+pageid;
		$('#page_links').load(url, function() {
			 $(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_square'});
		});
	} else if (media=='video') {
		url='gallery.asp?media=video&pageid='+pageid+'&title='+title;
		//alert('target: '+url);
		$('#page_links').load(url, function() {
			//$("ul.demo1").ytplaylist({addThumbs:true, autoPlay: false, holderId: 'ytvideo'});
		});
	} else if (media=='audio') {
		url='gallery.asp?media=audio&pageid='+pageid;
		$('#page_links').load(url, function() {
		});
	}
}
function getnews(id){
	url='nieuws.asp?nav=niet&n='+id;
	//alert(url);
	$('#page_links').load(url, function() {
			//
		});
}