var W3CDOM = (document.createElement && document.getElementsByTagName);

$(document).ready(function ()
{
	var num_of_album = 1;
	var img_numbers = $('.album .img_numbers').attr('value');
	var num_of_album = $('.album .num_of_album').attr('value');
	for (var i=1; i<=img_numbers; i++)
	{
		$('<img src="images/album_photos_'+ num_of_album+'/_img'+i+'.jpg" alt="" style="display:none;" />').insertAfter('.album .glitter');
	}
	
	var img_curent = 2;
	$('.album .previous').addClass('disabled');
	$('.album .previous').click(function()
	{
		if (img_curent == img_numbers) if(img_numbers%2 != 0) {img_curent++;}
		if(img_curent > 2)
		{
			$('.album .next').removeClass('disabled');
			img_curent--;
			img_curent--;
			var photo_2 = 'images/album_photos_'+ num_of_album+'/_img'+img_curent+'.jpg';
			$('.album .photo_2').attr('src',photo_2);
			img_curent--;
			var photo_1 = 'images/album_photos_'+ num_of_album+'/_img'+img_curent+'.jpg';
			$('.album .photo_1').attr('src',photo_1);
			img_curent++;
		}else{img_curent = 2;}
		if(img_curent == 2)	$('.album .previous').addClass('disabled');
			
    });
	$('.album .next').click(function()
	{
		$('.album .previous').removeClass('disabled');
		if(!(img_curent > img_numbers-2))
		{
			img_curent++;
			var photo_1 = 'images/album_photos_'+ num_of_album+'/_img'+img_curent+'.jpg';
			$('.album .photo_1').attr('src',photo_1);
			img_curent++;
			var photo_2 = 'images/album_photos_'+ num_of_album+'/_img'+img_curent+'.jpg';
			$('.album .photo_2').attr('src',photo_2);
		}else{
			img_curent=img_numbers;
			var photo_1 = 'images/album_photos_'+ num_of_album+'/_img'+(img_curent-1)+'.jpg';
			$('.album .photo_1').attr('src',photo_1);
			var photo_2 = 'images/album_photos_'+ num_of_album+'/_img'+img_curent+'.jpg';
			$('.album .photo_2').attr('src',photo_2);
			$('.album .next').addClass('disabled');
		}
    });
})