$( function () {
	$nieuwsbrief = $("[name=nieuwsbrief]").find(":input");
	
	$("form input[type=text]").focus( function () {
		if( $(this).val() == $(this)[0].defaultValue) {
			$(this).css("color", "#000").val('');
			$(this).parent().find('input[type=submit]').css("color", "#000");
		}
	}).blur( function () {
		if( $(this).val() == '') {
			$(this).css("color", "#808080").val( $(this)[0].defaultValue );
			$(this).parent().find('input[type=submit]').css("color", "#808080");
		}
	});
	
	$("#rating").change( function () {
		$.ajax({
			url: "rating.php?mop=" + $(this).attr("title") + "&rating=" + $(this).val(),
			success: function(data) {
				$("#rating").attr("disabled", true);
				alert( data );
			}
		});
	});
	
    var $twitterUser = "kortmopje";
    var tweeturl = "http://twitter.com/status/user_timeline/" + $twitterUser + ".json?count=2&callback=?";
    $.getJSON(tweeturl, function(data){
        $.each(data, function(i, item) {
            $link = '<br /><a href="http://twitter.com/kortmopje/status/' + item.id + " target='_BLANK'>Directe link</a>";
            $('<p></p>').addClass(i%2 ? 'even' : 'odd').html(item.text + $link).appendTo('div#twitterBox');
	   });
       
       $("<a></a>").attr({
            href: "http://www.twitter.com/kortmopje",
            target: "_BLANK"
       })
       .text('Volg ons op Twitter')
       .appendTo('div#twitterBox');
    });
});
