$('document').ready(function(){
	/**
	 * Het tonen en verwijderen van tooltips bij formulieren
	 * @param {Object} this
	 */
	$('form li input, form li select, form li textarea').hover(function(){
		$(this).next('.hint').show('fast');
	}, function(){
		$(this).next('.hint').hide('fast');
	}).focus(function(){
		$(this).next('.hint').hide();
	});


	/**
	 * Het afstemmen van kolomhoogtes
	 */
	var rightHeight = $('#columnRight').height();
	var leftHeight = $('#columnLeft').height();
	var centerHeight = $('#columnCenter').height();
	var mx = determineHeights(rightHeight, leftHeight, centerHeight)
	$('#columnCenter').css('height',mx + 'px');
	var rightHeight1 = $('#columnRight-small').height();
	var leftHeight1 = $('#columnLeft-small').height();
	var centerHeight1 = $('#columnCenter-large').height();
	var mx1 = determineHeights(rightHeight1, leftHeight1, centerHeight1)
	$('#columnCenter-large').css('height',mx1 + 'px');
	var rightHeight2 = $('#columnArticle').height();
	var leftHeight2 = $('#columnWidget').height();
	var mx2 = determineHeights(rightHeight2, leftHeight2, 0)
	$('#columnArticle').css('height',mx2 + 'px');
	
	function determineHeights(r, l, c) {
		var mx = l;
		if (r >= l && r >= c) mx = r;
		if (c >= l && c >= r) mx = c;
		return mx;
	}
	
	
	/**
	 * Helper voor het weggooien van items
	 * @param {Object} 'Are you sure you want to delete this item?'
	 */
	$('.confirmDelete').click(function(){
		return confirm('Are you sure you want to delete this item?');
	});
	
	$('.mainnavigatie-item a').fadeTo(0,0.85);
	
	$('#search').focus(function(){
		$(this).val('').css({fontStyle:'normal',color:'#909090'});
	});
	
	/**
	 * Algemene hideandseek functie
	 * trigger heeft een id van show-xxx
	 * waarbij xxx de id is van het object dat getoond dient te worden.
	 * @param {Object} $(this
	 */
	$('.hideandseek').click(function(){
		var id = new String($(this).attr('id'));
		var idtoshow = id.substr(5,1000);
		$('#' + idtoshow).fadeIn('slow');
		return false;
	});
	
	/**
	 * Specifiek hideandseek voor de testimonial
	 */
	$('.showHideTstml').toggle(function(){
			var id = $(this).attr('rel');
			clearTimeout(timer);
			$('.testimonial-content').css('overflow','scroll').animate({fontSize:'1em',width:'640px',height:'400px'},500);
			$('.testimonial-content p').css('margin-bottom','.5em');
			$('#show-testimonial'+id).show();
			$(this).text('Hide testimonial');
			return false;
		},function(){
			$(this).text('Read more');
			var id = $(this).attr('rel');
			$('.testimonial-content').css('overflow','hidden').animate({fontSize:'.8em',width:'300px',height:'200px'},500);
			$('.testimonial-content p').css('margin-bottom','0');
			$('#show-testimonial'+id).hide();
			slideSwitch();
			return false;
	});
	
	/**
	 * Specifiek hideandseek voor de footer
	 */
	$('#showHideFooter').click(function(){
		$('.footermenu-item').show('slow');
	});
	

	
	/**
	 * Navigatie
	   
	$('.mainnavigatie-item').hover(
		function(){
			$('.subnavigatie-item').hide('fast');
			var current = $(this).attr('id');
			var itemToShowId = current + "-s";
			$('#'+itemToShowId + ">li").show('slow');
		},function(){
			var current = $(this).attr('id');
			var itemToShowId = current + "-s";
			setTimeout(hideIt,5000);
			function hideIt() {
				$('#' +itemToShowId + '>li').hide('slow');
			}
	});*/
	

  

	$('#tagemail').focus(function(){
		$(this).select();
	});
	
	
	/**
	 * Language picker
	 */
	$('.picklang').click(function(){
		var url = '/ajax/setlang';
		var data = {lang:$(this).attr('rel')};
		$.get(url,data,function(ok){
			location.reload();
		});		
		return false;
	});
	


});

