var PAGE_NAME = location.href.substring(location.href.lastIndexOf('/')+1,location.href.length);
$(function(){
	/*$('li a').click(function(){
		$('#warning').html('Em construção.<br />Por favor, aguarde...');
		$('#warning').attr('title','Não disponíel');
		$('#warning').dialog({ width : 100 , height : 100 , show : 'slide' , hide : 'slide' , resizable : false});
		$('#warning').unbind('click');
		$('#warning').click(function(){
			$(this).dialog("close");
		});
		return false;
	});*/
	switch(PAGE_NAME){
		case "artes_visuais.html":
			$('.ad-gallery').adGallery({ width : 600 , height : 230,
			
			callbacks: {
				// Executes right after the internal init, can be used to choose which images
				// you want to preload
				init: function() {
				  // preloadAll uses recursion to preload each image right after one another
				  this.preloadAll();
					$('.ad-image img').unbind('click');
					$('.ad-image img').click(function(){
						showBiggerGallery($(this).attr('src'));
					});
				},
				afterImageVisible: function() {
					$('.ad-image img').unbind('click');
					$('.ad-image img').click(function(){
						showBiggerGallery($(this).attr('src'));
					});
				}
			  }
			 });

		break;
		case "galeria.html":
			$('.ad-gallery').adGallery({ width : 600 , height : 270,
			
			callbacks: {
				// Executes right after the internal init, can be used to choose which images
				// you want to preload
				init: function() {
				  // preloadAll uses recursion to preload each image right after one another
				  this.preloadAll();
					$('.ad-image img').unbind('click');
					$('.ad-image img').click(function(){
						showBiggerGallery($(this).attr('src'));
					});
				},
				afterImageVisible: function() {
					$('.ad-image img').unbind('click');
					$('.ad-image img').click(function(){
						showBiggerGallery($(this).attr('src'));
					});
				}
			  }
			 });

		break;
	
		case "videos.html":

			$('#left_arrow').click(function(){
				$('#videos').animate({ scrollLeft : $('#videos').scrollLeft() - 707});
			});
			$('#right_arrow').click(function(){
				$('#videos').animate({ scrollLeft : $('#videos').scrollLeft() + 707});
			});

		break;

		case "musica.html":

			$('#albums img').click(function(){
				$('img').removeClass('selectedAlbum');
				$(this).addClass('selectedAlbum');
			});

		break;

		case "livros_textos.html":

			$('.ad-gallery').adGallery({ width : 600 , height : 270,
			
				callbacks: {
					// Executes right after the internal init, can be used to choose which images
					// you want to preload
					init: function() {
					  // preloadAll uses recursion to preload each image right after one another
					  this.preloadAll();
						$('.ad-image img').unbind('click');
						$('.ad-image img').click(function(){
							showBiggerGallery($(this).attr('src'));
						});
					},
					afterImageVisible: function() {
						$('.ad-image img').unbind('click');
						$('.ad-image img').click(function(){
							showBiggerGallery($(this).attr('src'));
						});
					}
				  }
			 });

			break;

	}

});

function showBiggerGallery(src){
	$('body').remove('#gallery_image_big');
	$('body').prepend('<img id="gallery_image_big" src="' + src + '" alt="" class="gallery_image_big" />');
	$('#gallery_image_big').popup({ show : true , modal : true , draggable : true , closeOnClick : true });
}

