$('document').ready(function() { 
	maakflash();
	maakflash_modelnaam();

	//laat credits zien als je over de link heengaat
    $("a.credits-link").hover(
      function () {
        $('.credits').slideDown();
      }, 
      function () {  
       $('.credits').slideUp();
      }
    );


$('.about, .contact').click(function() {
	$(document).scrollTo('100%',500)
});

$('#featured-pic').cycle({ 
    fx:     'fade', 
    timeout: 5000, 
	random:1,
    after:   onAfter 
});



//sorteer artiesten
$('#sort p a').click(function() {
	$('#sort p a').removeClass('active');
	$(this).addClass('active');
	var specialty = $(this).attr('rel');
		$('#models .links').slideUp('fast', function() {
		$('#models .links').load('inc/artist_list.php?specialty='+ specialty, function() {$('#models .links').slideDown('fast');  } );
	});
	
	$(this).blur();
	return false;
});


//laat artiest zien
$('.showartist').live('click',function() {
		var artistid = $(this).attr('rel');
		$('.link .showartist').removeClass('active');
		$(this).addClass('active');
		$('#model').load('inc/show_artist.php?artistid='+ artistid, function() {$(document).scrollTo('#model',500); });	
	$(this).blur();
	return false;
});

//start 'zoom' view
$('#model-thumbs img').live('click',function() {
	var parameters = $(this).attr('parameters');
	//alert('inc/show_album.php'+parameters);
	//open juiste album
	$('#album').load('inc/show_album.php'+parameters);
	var filename = $(this).attr('src');
	
	var current = $(this).attr('id');
	if (current =="")	{ current = 1	}
	image_url = filename.replace("content_images/thumbs/","content_images/zoom/");
	$('#model-thumbs').fadeOut('fast',function() {
		changepic(image_url,current,'eerste')
	});

	return false;
	});

//start 'zoom' view vanaf link
$('#album-links a').live('click',function() {
	var parameters = $(this).attr('parameters');
	//alert('inc/show_album.php'+parameters);
	//open juiste album
	$('#album').load('inc/show_album.php'+parameters);
	var filename = $(this).attr('afbeelding');
	
	var current = $(this).attr('id');
	if (current =="")	{ current = 1	}
	image_url = filename.replace("content_images/thumbs/","content_images/zoom/");
	$('#model-thumbs').fadeOut('fast',function() {
		changepic(image_url,current,'eerste')
	});

	return false;
	});






//einde 'zoom' view
$('#zoom-close').live('click',function() {
	$('#model-zoom').hide();
	$('#model-thumbs').show();
	return false;
});


//volgende 'zoom' view
$('#zoom-next').live('click',function() {
	$('#model-zoom p.credit-zoom').hide();
	//get current pic
	var current = $('#album img.active').attr('id');
	//alert(current);
	var next_el = '#album #' + (parseInt(current) + 1);
	//alert(next_el);
	$('#album .active').removeClass('active');
	$(next_el).addClass('active');
	var next_pic = $(next_el).attr('src');
	next_pic = next_pic.replace("content_images/thumbs/","content_images/zoom/");
	changepic(next_pic,parseInt(current) + 1);
	return false;
});


//vorige 'zoom' view
$('#zoom-prev').live('click',function() {
	$('#model-zoom p.credit-zoom').hide();
	//get current pic
	var current = $('#album img.active').attr('id');
	var prev_el = '#album #' + (parseInt(current) - 1);
	$('#album .active').removeClass('active');
	$(prev_el).addClass('active');
	var prev_pic = $(prev_el).attr('src');
	prev_pic = prev_pic.replace("content_images/thumbs/","content_images/zoom/");
	changepic(prev_pic,parseInt(current) - 1);
	return false;
});



$('.totop').live('click',function() {
	$(document).scrollTo('0px',500);
	return false;
});

	

$('.more').live('click',function() {
	$(document).scrollTo('#model',500)
		var artistid = $(this).attr('rel');
		$('.link .showartist').removeClass('active');
		$(this).addClass('active');
		$('#model').load('inc/show_artist.php?artistid='+ artistid, function() { $(document).scrollTo('#model',500); });
		return false;
		});



$('.submit').live('click',function() {
		   var formnaam = $('input[name="formnaam"]').val();
		   var formemail = $('input[name="formemail"]').val();
		   var formmessage = $('textarea[name="formmessage"]').val();
		   if (formemail != "")
		   {
		   $('#about-form form').hide();
		   $('#about-form').load('inc/email.php?name='+formnaam+'&email='+formemail+'&message='+formmessage);
		   }
		   return false;	
});




});
//einde pageload


function maakflash() {
	$('#featured-info h1').each(function() {
		var detekst = $(this).text();
		 $(this).flash(
			{ 
			  src: 'swf/apexnew-book.swf',
			  width: 190,
			  height: 35,
			  wmode: 'transparent',
			  menu: false,
			  flashvars: { detekst: detekst, kleur: "4f0634" }
			}, { update: false }
		);
	});



$('#about h1').each(function() {
		var detekst = $(this).text();
		 $(this).flash(
			{ 
			  src: 'swf/apexserif-light.swf',
			  width: 820,
			  height: 40,
			  wmode: 'transparent',
			  menu: false,
			  flashvars: { detekst: detekst, kleur: "b1a982" }
			}, { update: false }
		);

	});


$('#about-info h2').each(function() {
		var detekst = $(this).text();
		 $(this).flash(
			{ 
			  src: 'swf/apexserif-medium.swf',
			  width: 420,
			  height: 18,
			  wmode: 'transparent',
			  menu: false,
			  flashvars: { detekst: detekst, kleur: "000000" }
			}, { update: false }
		);

	});

}

function maakflash_modelnaam() {
	
$('#model h1').each(function() {
		var detekst = $(this).text();
		 $(this).flash(
			{ 
			  src: 'swf/apexserif-light-model.swf',
			  width: 820,
			  height: 50,
			  wmode: 'transparent',
			  menu: false,
			  flashvars: { detekst: detekst, kleur: "b1a982" }
			}, { update: false }
		);
	});
$('#model h1,#about-info h2,#about h1,#featured-info h1').css({ 'visibility': 'visible' });
}


function changepic(image_url,current_id, eerste) {
		
		$('#zoom-prev').hide();
		$('#zoom-next').hide();
	 //alert(credits);
	  $('#model-zoom img').fadeOut("fast",function() { $('#model-zoom img').attr({src : image_url }); });
	  
	  $('#model-zoom img').load(function() {
			$('#model-zoom img').fadeIn("fast", function() { 
				$('#model-zoom').show();	
							var credits = $('#album img.active').next('div').html();
							$('#model-zoom p.credit-zoom').html(credits);
							setTimeout("$('#model-zoom p.credit-zoom').fadeIn()",500);
				});
		});
		

			volgende_vorige(current_id,eerste);
			show_album_status(current_id)
}

function volgende_vorige(current_id,eerste) {
		var max = $('#album #aantal').attr('rel');
		//alert(current_id);
		//alert(max);
		if (current_id != 1) { $('#zoom-prev').show(); } else { $('#zoom-prev').hide();}
		if (current_id == max) { $('#zoom-next').hide();} else { $('#zoom-next').show();}
		
		if (max == 1){ $('#zoom-next, #zoom-prev').hide();}
		if (eerste == 'eerste'){ $('#zoom-prev').hide();}
}


function show_album_status(current_id) {
		var max = $('#album #aantal').attr('rel');
		$('#album-status').text(current_id+' / '+max)
		//alert(max);
}



function onAfter() {
	var text = $(this).attr('rel');
	$('.credits').html('<p>' + text + '</p>');
	if (text =='')	{$('.credits-link').hide();	}
	else { $('.credits-link').show();	}
}
