$(document).ready(function(){


    // pretty hover: http://fearlessflyer.com/2010/06/pretty-hover-effects-with-css-and-jquery/
    var thumbs = $("#caseslist li img");

    for (var i = 0, ii = thumbs.length; i < ii; i++){
        if (thumbs[i].alt && thumbs[i].alt.length > 0){
            var imgtitle = thumbs[i].alt;
            $(thumbs[i]).wrap('<div class="wrapper" />').
            after('<div class=\'caption\'>' + imgtitle + '</div>').
            removeAttr('title');
        }
    }

    $('.wrapper').hover(
        function(){
            //$(this).find('.caption').animate({top:"-98px"}, 300);
            $(this).find('.caption').css({top:"-98px"});
        },
        function(){
            //$(this).find('.caption').animate({top:"98px"}, 300);
            $(this).find('.caption').css({top:"98px"});
        }
    );

    // fancybox links inactive
    //console.log($("caselist").find("a[id^=manual_]"));
//    $("#caseslist").find("a[id^=manual_]").click(function(event) {
//        event.preventDefault();
//    });

    // fancybox

    //function myStartFunction() { alert('fancy box opened'); }

//    $("a[rel^=example_group]").fancybox({
//        'onStart': function(){alert('fancy box opened')},
//        'overlayColor'		: '#ff6666',
//        'overlayOpacity'	: 0.5,
//        'transitionIn'		: 'elastic',
//        'transitionOut'		: 'elastic',
//        'titlePosition' 	: 'inside',
//        'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
//                return '<span id="fancybox-title-over"><span class="fancybox_title_small">Afbeelding ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '</span>' + title : '') + '</span>';
//        }
//
//    });

    // form
    $('#message').hide();
        $('#contactform').submit(function(){

		var action = $(this).attr('action');

		$("#message").slideUp(200,function() {
//		$('#message').hide();
                //console.log($('#submit'));
 		$('#submit')
			.after('<img src="images/ajax-loader.gif" class="loader" />')
			.attr('disabled','disabled');

		$.post(action, {
			name: $('#name').val(),
			email: $('#email').val(),
			comments: $('#comments').val(),
			verify: $('#verify').val()
		},
			function(data){
				document.getElementById('message').innerHTML = data;
				$('#message').slideDown(200);
				$('#contactform img.loader').fadeOut(200,function(){$(this).remove()});
				$('#submit').removeAttr('disabled');
				if(data.match('success') != null) $('#contactform').slideUp(200);

			}
		);

		});

		return false;

	});
                        

});
