/* Author:

*/


$(document).ready(function(){
	
	// Run Matt Kersley's jQuery Responsive menu plugin (see plugins.js)
	if ($.fn.mobileMenu) {
		$('ol#id').mobileMenu({
			switchWidth: 768,                   // width (in px to switch at)
			topOptionText: 'Choose a page',     // first option text
			indentString: '&nbsp;&nbsp;&nbsp;'  // string for indenting nested items
		});
	}

	// Run Mathias Bynens jQuery placeholder plugin (see plugins.js)
	if ($.fn.placeholder) {
		$('input, textarea').placeholder();		
	}
	
	// Behaviour site Grimm.nl - by Hans Grimm
	
	// Put quotes around the quote :)
	$('aside blockquote .quote').prepend('<span class="quotestart">&ldquo;</span>').append('<span class="quoteend">&rdquo;</span>');
	
	// Put linktext in img title
	$('.portfolio a').each(function(){
		var linkTxt = $(this).text();
		$(this).find('img').attr('title',linkTxt);
	});
	
	// Open partnerlinks in new window, warn user
	$('.partnerlist a, .techlist a, .clientlink').each(function(){
		$(this).attr({'target':'_blank','title':'Let op: link opent in nieuw venster'});
	});
	
	// Shrink header on portfolio by 10 px
	//$('.portfolio h2').each(function(){
		//origWidth = $(this).width();
		//newWidth = origWidth - 10;
		//$(this).css('width',''+ newWidth + '');
	//});
	
	// ### Contact form ###
	$('#contact form').prepend('<a href="javascript:;" class="closeForm" title="formulier sluiten">Sluiten</a>');
	// close contact form
	$('.closeForm').click(function(e){
		$('#contact').animate({
			left:'-380px'
		},1000, function() {
    		$('.toForm').show();
  		});
		e.preventDefault();
	});
	// open contact form
	$('.toForm, .toContact, a[href="#contact"]').click(function(e){
		$('#contact').animate({
			left:'20px'
		},1000, function() {
    		$('.toForm').hide();
  		});
		var linkTekst = $(this).text();
		var whichPage = document.location.href;
		_gaq.push(['_trackEvent','open contactformulier',linkTekst,whichPage]);
		e.preventDefault();
	});
	
	//$('.toForm').toggle(function(e){
		//$('#contact').animate({
			//left:'20px'
		//},1000);
		//e.preventDefault();
	//},function(e){
		//$('#contact').animate({
		//	left:'-380px'
		//},1000);
		//e.preventDefault();
	//});
	
	// Om te voorkomen dat ik helemaal kapotgespamd word, toch maar even een hindernisje opwerpen..
	$('#form1').submit(function(){
		var whichPage = document.location.href;
		if ($('#spam').val() != '3'){
			alert('Spamvraag niet of niet correct beantwoord');
			$('#spam').focus();
			return false;
		} else if ($('#naam').val() == '') {
			alert('Naam niet ingevuld');
			$('#naam').focus();
			return false;
		} else if ($('#email').val() == '') {
			alert('E-mail niet ingevuld');
			$('#email').focus();
			return false;
		} else if ($('#bericht').val() == '') {
			alert('Bericht niet ingevuld');
			$('#bericht').focus();
			return false;
		} else {
			return true;
			_gaq.push(['_trackEvent','verzend contactformulier',whichPage]);
		}
	});
	
});








