$(document).ready(function()
{
	var pageLoaded = 1;

	//functions
	function buttonAnimation(buttonName)
	{
		over = 0;
		var animating = 0;
		$(buttonName).mouseenter(function()
		{
			if (over == 0 && animating == 0)
			{
				over = 1;
				animating = 1;
				$(buttonName + 'Text').hide('slide', {direction: 'right'}, 250, function()
				{
					$(buttonName + 'Text').show(0, function() {
						$(buttonName + 'Text').show('slide', {direction: 'left'}, 250, function()
						{
							animating = 0;
						});
					});				
				});
			}
		});

		$(buttonName).mouseleave(function()
		{
			over = 0;
		});
	}

	
	
	$('#buttonDownloadshop').click(function(){
		window.open("http://system.aim4music.com/shops/djumbo/index.aspx");
	});
	
	function buttonClick(buttonName)
	{
		$(buttonName).click(function()
		{
			if (pageLoaded == 1)
			{
				pageLoaded = 0;		
				var pageID = buttonName.slice(1,-6);
				var dynamicLink = 'includes/navigationContent/' + pageID + '.inc.php';
				$.ajax({
					type: 'POST',
					url: dynamicLink,
					//data: data,
					success: function(data)
					{
						$('.centerContainer').html(data);
						$('.topPicture').html('<div class="' + pageID + 'HeaderCont"></div>');	
						pageLoaded = 1;
					}
				});
			}
		});
	}
	
	function profileButton(buttonName)
	{
		$('.' + buttonName + 'Thumb').click(function()
		{
			var data = "profileid=" + buttonName;
			$.ajax({
				type: 'POST',
				url: 'includes/navigationContent/profile.inc.php',
				data: data,
				success: function(data)
				{					
					$('.centerContainer').html(data);
					$('.topPicture').html("<div class='profilePicContainer'></div>");
					$('.profilePicContainer').css('background-image', 'url(images/profile/' + buttonName + 'Picture.png)');
				}
			});		
		});
	}
	
	//initialiseer knoppen
	buttonArray = ['#clipButton','#videoButton','#newsButton','#musicButton','#agendaButton','#shopButton','#priceButton','#wallpaperButton','#guestbookButton','#gamesButton','#bookingButton','#contactButton','#furtherInfoButton'];
	animationArray = ['#clipButton','#videoButton','#newsButton','#musicButton','#agendaButton','#shopButton','#priceButton','#wallpaperButton','#guestbookButton','#gamesButton','#buttonDownloadshop'];
	for (var i in buttonArray)	
	{
		buttonClick(buttonArray[i]);
		buttonAnimation(animationArray[i]);
	}

	profileButton('lindsy');
	profileButton('svenja');
	profileButton('lotte');

	$('#newsLetterInput').live('click', function() {
		dominput_color = $('#newsLetterInput').css("color");
		if ($('#newsLetterInput').val() != "" && (dominput_color == "#424143" || dominput_color == "rgb(164, 164, 164)" || dominput_color == "#ff0000" || dominput_color == "rgb(255, 0, 0)"))
		{
			$('#newsLetterInput').val("");
			$('#newsLetterInput').css("color","black");
		}
	});

	$('.pagingLink').live('click', function() {
		var dynamicLink = 'includes/navigationContent/' + globalPageID + '.inc.php';
		var idtjah = (this.id).slice(4);
		var data = 'page=' + idtjah;
		$.ajax({
			type: 'POST',
			url: dynamicLink,
			data: data,
			success: function(data) {
				$('.centerContainer').html(data);
			}
		});
	});
	
	$('#submitNewsLetter').live('click', function() {
		var newsLetterVal = $('#newsLetterInput').val();
		var data = 'newsLetterInput=' + newsLetterVal;
		var dynamicLink = 'ajax/newsletter.php';
		$.ajax({
			type: 'POST',
			url: dynamicLink,
			data: data,
			success: function(data) {
				$('#processDiv').html(data);
			}
		});
	});	
});
