/**
 **		/js/functions.js
 **		Utility functions for IvET
 **		Needs jquery.js and jquery.scrollto.js
 **
 **		Author: Taco Vader <taco.vader@crisp-e.com>
 **		Copyright Crisp-e Webdevelopment 2010
 **
 **/

function refreshQuote() {
	$.ajax({
		url: '/quotes/random.json',
		success: function (data) {
			$('#reactie q').fadeTo(1000,0.01,function() {
				$('#reactie q').text(data.quote).fadeTo(1000,1);
				$('#reactie em').text(data.person);
			});
			setTimeout( 'refreshQuote();', 10000 );
		}
	});
}

$(document).ready(function() {
	setTimeout( 'refreshQuote();', 10000 );
	$( document.location.hash ).addClass('in-focus');
	$("a[href^='#']").click( function( ) {
		$( '.in-focus' ).removeClass('in-focus');
		var href = $(this).attr('href');
		$( href ).addClass('in-focus');
		$.scrollTo( $(this).attr('href'), 800, {
			'duration': 1000,
			'onAfter': function () { location = href; }
		} );
		return false;
	} );
	$("#aanmeldenform select").change( function() {
		var nietsGekozen = $("#aanmeldenform select[value=0]").length;
		$("#geldsom").html( "&euro; " + 280*(3-nietsGekozen) + ",00" );
	} );
	$("#edit-page-form").slideUp( );
	$("#edit-page-toggle").click( function () {
		$("#edit-page-form").slideToggle( );
	});

	/*
	$("#periodes select").each( function() {
		periode = $(this).attr("name").replace(/periode\[(\d+)\]/g,"$1");
		if ( $(this).val()==0 ) {
			$("#txt"+periode).hide();
			$("input[name=gemiddelde["+periode+"]]").hide();
		}
		else {
			$("#txt"+periode).show();
			$("input[name=gemiddelde["+periode+"]]").show();
		}
	} );
	$("#periodes select").change( function() {
		periode = $(this).attr("name").replace(/periode\[(\d+)\]/g,"$1");
		if ( $(this).val()==0 ) {
			$("#txt"+periode).hide();
			$("input[name=gemiddelde["+periode+"]]").hide();
		}
		else {
			$("#txt"+periode).show();
			$("input[name=gemiddelde["+periode+"]]").show();
		}
	} );
	*/
});

