/* ================
	Navigation Main
================= */
$(document).ready(function () {
	$('#navMain ul li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(300);
		},
		
		function () {
			//hide its submenu
			$('ul', this).fadeOut(200);			
		}
	);
});

/* ================
	Nivo Slider
	http://nivo.dev7studios.com/
================= */
$(document).ready(function () {
    $('#nivo-slider').nivoSlider({
        animSpeed:500, // Slide transition speed
        pauseTime:7500, // How long each slide will show
        startSlide:'random', // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        keyboardNav:false
	});
});

/* ================
	Spotlight Tabs
	http://www.sohtanaka.com/web-design/simple-tabs-w-css-jquery/
================= */
$(document).ready(function() {
	//When page loads...
	$(".tabContent").hide(); //Hide all content
	$("nav#navSpotlight ul li.first").addClass("active").show(); //Activate first tab
	$(".tabContent.first").show(); //Show first tab content

	//On Click Event
	$("nav#navSpotlight ul li").click(function() {
		$("nav#navSpotlight ul li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tabContent").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;
	});
});

/* ================
	Paginate
	http://bassistance.de/jquery-plugins/jquery-plugin-validation/
================= */
$(document).ready(function() {
	$("#blairboxBerichten").paginate({
		limit: 15, content: 'li.paginate'
	});
	$("#profielTags").paginate({
		limit: 9, content: 'td.profielTags'
	});
});

/* ================
	Popup
	http://www.vegabit.com/jquery_bubble_popup_v2/
================= */
$(document).ready(function(){
	$('.popup').each(function() {
		var $this = $(this);
		
		$this.CreateBubblePopup({
			position: 'top',
			align: 'center',
			innerHtml: $this.attr('title'),
			innerHtmlStyle: {
				color: '#fff',
				'text-align': 'center'
			},
			themeName: 'all-blue',
			themePath: 'images/jquerybubblepopup-theme'
		});
	});

	$(function(){
		$(".popup").hover(function(){
			$(this).stop().attr('title', '');},
			function(){$(this).stop().attr();
		});
	});
});

/* ================
	Activiteit Toggle
================= */
$(document).ready(function(){
	$('.activiteitToggle').click(function() {
		var activiteitToggle = $(this).find("a").attr("href");
		$(activiteitToggle).slideToggle('500');
		
		return false;
	});
	
	$('#activiteitenUitvouwen').click(function() {
		$('.activiteitBody').slideToggle('500');	
		
		return false;
	});
});

/* ================
	Quicksearch
	https://github.com/riklomas/quicksearch
================= */
$(document).ready(function () {
	$('input#superZoek').quicksearch('table tbody tr');
});

/* ================
	Table sort
	http://tablesorter.com/docs/
================= */
$(document).ready(function() { 
	 $("#tableSort").tablesorter({
    }); 
});

/* ================
	Validate Form
	http://bassistance.de/jquery-plugins/jquery-plugin-validation/
================= */
$(document).ready(function() {
	$("#informatiepakketForm").validate();
	$("#nieuwWachtwoordForm").validate();
	$(".instellingenForm").validate();
});

/* ================
	Placeholder
	http://webdeveloper.beforeseven.com/jquery/default-text-field-value-disappears-focus
================= */
/**
* The following variables may be adjusted
*/
var active_color = '#000'; // Colour of user provided text
var inactive_color = '#7f7f7f'; // Colour of default text

/**
* No need to modify anything below this line
*/

$(document).ready(function() {
  $("input.placeholder").css("color", inactive_color);
  var placeholder = new Array();
  $("input.placeholder").focus(function() {
    if (!placeholder[this.id]) {
      placeholder[this.id] = this.value;
    }
    if (this.value == placeholder[this.id]) {
      this.value = '';
      this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.value = placeholder[this.id];
      }
    });
  });
});
  
/*==========================
	getQueryString
	http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx
============== */
function getQueryString(key, default_) {
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
