$(document).ready(function() {
	window.jcl = $("#gallery").jCarouselLite({
		visible: 1,
		speed: 1000,
		auto: 8000,
		fade: true,
		btnGo: controls,
		beforeStart: function(obj, to) {
			var from = obj.attr('rel');
//console.log(from + ' -> ' + to);
			$('#jcarousel-item-'+from).removeClass('current');
		},
		afterEnd: function(obj, from) {
			var to = obj.attr('rel');
//console.log(from + ' -> ' + to);
			$('#jcarousel-item-'+to).removeClass('almost').addClass('current');
//			if ( '1' == to ) {
//				window.jcl.jCarouselLiteOptions.auto = 0;
//				clearInterval(window.jcl.jCarouselLiteOptions.timer);
//				$('#gallery li[rel="1"]').show();
//			}
		}
	});
	$('#dienstenmenu a.l1').click(function(){
		var li = $(this.parentNode.parentNode);
		if ( li.hasClass('open') ) {
			li.removeClass('open');
		}
		else {
			li.parent().children().removeClass('open');
			li.addClass('open');
		}
		return false;
	});
	$("#bel-me-nu input[type=text]").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( '' == this.value ) {
			this.value = this.defaultValue;
		}
	});
	$("#bel-me-nu").submit(function() {
		if ( -1 != ['Mijn naam is:', ''].indexOf($("#field_1276865234209").val().trim()) || 3 > $("#field_1276865234209").val().trim().length ) {
		        $("#error").text("Ongeldige naam").show();
		        return false;
		}
		else if ( -1 != ['Mijn telefoonnummer is:', ''].indexOf($("#field_1276865251230").val().trim()) || 3 > $("#field_1276865234209").val().trim().length ) {
		        $("#error").text("Ongeldig telefoonnummer").show();
		        return false;
		}
	});
	$("#menu li").hover(function() {
		$(this).find('ul').css('left', '0');
	}, function(){
		$(this).find('ul').css('left', '-9999px');
	});
});
