// JavaScript Document

// execute your scripts when the DOM is ready. this is a good habit
$(function() {

	// initialize scrollable
	$("div.scrollable").scrollable();

});
$(function() {

	// initialize scrollable
	$("div.slideshow").scrollable();

});


$(function() {


$(".items img").click(function() {

	// calclulate large image's URL based on the thumbnail URL (flickr specific)
	var url = $(this).attr("alt");
	var name = $(this).attr("title");

	// get handle to element that wraps the image and make it semitransparent
	var wrap = $("#image_wrap").fadeTo("slow", 0.5);
	var title = $("#image_title").fadeTo("slow", 0.5);

	// the large image from flickr
	var img = new Image();

	// call this function after it's loaded
	img.onload = function() {

		// make wrapper fully visible
		wrap.fadeTo("slow", 1);
		title.fadeTo("slow", 1);

		// change the image
		wrap.find("img").attr("src", url);
		title.html(name);
			
		var imgWidth = parseInt(img.width);	
		if(imgWidth > 770){
		    imgWidth = 770;
		}
				
		$("#imageViewCell").css('width', imgWidth + 10 +'px');
		$("#imageView").css('width', imgWidth +'px');

	};

	// begin loading the image from flickr
	img.src = url;

// when page loads simulate a "click" on the first image
}).filter(":first").click();
});

$(document).ready(function() {
$(".prev").click(function() {
    $(".scrollable .items img[alt=" + $("#image_wrap img").attr("src") + "]").prev().click();
  });
$(".next").click(function() {
    $(".scrollable .items img[alt=" + $("#image_wrap img").attr("src") + "]").next().click();
    
  });
  
//var left = 0;  
//$(".prevGallery").click(function() {
//if(left != 0){
//left = left + 816;
//}
//$(".items").css("left", left +"px");
//  });
//$(".nextGallery").click(function() {
//var aux = left + 816;
//if(aux > parseInt($(".items").css("width"),10)){
//left = left - 816;
//}
//$(".items").css("left", left +"px");
    
  //});
 });
