/*
	GovertMuijs.nl ~ jQuery functions 
	Author: J.N. van Oosten (www.jannico.nl)
	Creation date: 12-03-2010
	Description: General jquery functions & calls
	Copyright (C) Jan Nico van Oosten
*/

"use strict";

// --------------------------------------------------------------------------------
// functions to start on document.ready
// --------------------------------------------------------------------------------	
function initMuijsMenu(){
	// --------------------------------------------------------------------------------
	// initialise the megamenu
	// --------------------------------------------------------------------------------			
	$("#menu a.m_menu").megamenu(".m_menu_content", {
	});	
	
	// --------------------------------------------------------------------------------
	// Remove title tooltips for readability
	// --------------------------------------------------------------------------------			
	$("#menu a").removeAttr("title");
}

function initMuijs(){
	// --------------------------------------------------------------------------------
	//set class for every 3rd thumb in the sidebar
	// --------------------------------------------------------------------------------	
	//If the thumbs exist
	if($("div.side_block p.thumbs").length){
		//Loop through each image
		$("div.side_block p.thumbs a:nth-child(3n)").each(function(){
				$(this).addClass("last");
			}
		);
	}
	
	// --------------------------------------------------------------------------------
	// smooth page scrolling
	// --------------------------------------------------------------------------------	
	$('a.top').click(function() {
		var elementClicked = $(this).attr("href");
		var destination = $(elementClicked).offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 500 );
		return false;
	});

	// --------------------------------------------------------------------------------
	// start colorbox (lightbox)
	// --------------------------------------------------------------------------------	
	$('a.thumblink').click(function(){
		var r = $(this).attr("rel");
		$("a.thumblink[rel='"+r+"']").colorbox({slideshow:true, slideshowAuto:"", opacity:"0.6"});
	});

	$('a.iframelink').click(function(){
		$(this).colorbox({width:"80%", height:"80%", iframe:true});;
	});	
	
	// --------------------------------------------------------------------------------
	// set lower menu font-size + corresponding padding in safari
	// --------------------------------------------------------------------------------
	if($.browser.safari) {
		$("div#menu li.menu_item a").css("font-size", "1.1em" ).css("padding","11px 12px 8px 14px");
	}
	
	// --------------------------------------------------------------------------------
	// header image bottom border in FF
	// --------------------------------------------------------------------------------
	if($.browser.mozilla) {
		$("div#header").css("font-size", "1.1em" ).css("margin-top","-13px");
	}
	
	// --------------------------------------------------------------------------------
	// toggle timeline about govert muijs page
	// --------------------------------------------------------------------------------	
	$("p a.timeline_toggle").click( function() {
		$("div#timeline").slideToggle('500');
	});
	$("div#timeline").css({ 
		display: "none"
	});

}

function initMuijsForm(){
	// --------------------------------------------------------------------------------
	// default text in textarea
	// --------------------------------------------------------------------------------	
	$("#contactform textarea").focus(function(srcc) {
		if ($(this).val() == $(this)[0].title) {
			$(this).removeClass("default");
			$(this).val("");
		}
	});
	
	$("#contactform textarea").blur(function() {
		if ($(this).val() == "") {
			$(this).addClass("default");
			$(this).val($(this)[0].title);
		}
	});
	
	$("#contactform textarea").blur();
}


function initMuijsBlog(){

}

function initMuijsSlider(){	
	// --------------------------------------------------------------------------------
	// Slider
	// --------------------------------------------------------------------------------		
	$('#slides').slides({
		preload: true,
		preloadImage: '../img/gallery_loading.gif',
		pagination: false,
		generatePagination: false,
		play: 5000,
		pause: 2500,
		hoverPause: true
	});
}


