$(document).ready(function() {
		
  	$('button[id=login]').click(function(){
  	$('div#loginForm').find('span#error').remove();
  	  	$('div#loginForm').fadeIn();
  	  	
  		});
  	 
  	$('a[title*=sluit]').click(function(){
  		$('div#loginForm').fadeOut();
  		});
  	
  	$('a[title*=sluitNewsletter]').click(function(){
  		$('div#newsletter').fadeOut();
  		});
  	
	$('input[type=text]').focus(function() {
		if($(this).val() == $(this).attr('rel')) {
			$(this).val("");
			}
		}).blur(function() {
			if($(this).val() == "") {
				$(this).val($(this).attr('rel'));
				}
		});
	
	
	$('#photos').galleryView({
			panel_width: 960,
			panel_height: 320,
			frame_width: 90,
			frame_height: 30,
			overlay_color: '#000',
			overlay_text_color: 'white',
			caption_text_color: '#222',
			background_color: '#FFF',
			border: 'none',
			nav_theme: 'light',
			easing: 'easeInOutQuad',
			pause_on_hover: true
		});
	
			
	$("#twitter").getTwitter({
			userName: "SparkNewMedia",
			numTweets: 3,
			loaderText: "Laden tweets...",
			slideIn: true,
			slideDuration: 750,
			showHeading: false,
			headingText: "Laatste Tweets",
			showProfileLink: false,
			showTimestamp: true
		});

	$('div#loginForm form').submit(function() {
		
		$('div#loginForm').find('span#error').remove();
				
		var username = $('input[name=username]').val();
		var password = $('input[name=password]').val();
	
		$.ajax({
			url: 'http://www.sparknewmedia.nl/application/inc/login.php',
			type: 'POST',
			data: 'username=' + username + '&password=' + password,
			success: function(result) {
				if (result == "Succes") {
					window.location = 'http://www.sparknewmedia.nl/client/';
					}
				else {
					var response = result;
					$('div#loginForm button').after('<span id="error" style="margin-left: 25px;">' + response + '</span>');
					}
				}
			});
		
		return false;
		});

});
