var currentPic = 1;
var maxPics = 0;

var ocontainer;
var ocontent;
var spaceToScroll;



$(document).ready(function(){
	maxPics = $(".projectimages").children("img").size();

	$(".projectdescription").jScrollPane();

	$(".project_list_item").mouseover(function(){
		$(this).children(".popup").css({"display": "block"});
		
		var thumbWidth = $(this).children(".popup").find("img").width();
		var thumbHeight = $(this).children(".popup").find("img").height();
		var newWidth = 150;
		
		var newHeight = thumbHeight*newWidth/thumbWidth;
		
		$(this).children(".popup").find("img").css({"height": newHeight+"px", "width": newWidth+"px"});	
	});
	
	$(".project_list_item").mousemove(function(e){
		
		if(e.pageY + 20 + $(this).children(".popup").height() >= $(window).height())
			$(this).children(".popup").css({"left": e.pageX+15+"px", "top": e.pageY-$(this).children(".popup").height()+0+"px"});
		else
			$(this).children(".popup").css({"left": e.pageX+15+"px", "top": e.pageY+0+"px"});
			
	});
	
	$(".project_list_item").mouseout(function(){
		$(this).children(".popup").css({"display": "none"});	
	});

});

function showImage(id)
{
	$(".projimg").hide();
	$(".projectimages a").css({color: "#bbbbbb"});
	$("#img_"+id).fadeIn("slow");
	$("#link_"+id).css({color: "#000000"});
	currentPic = id;
}

function showImageInc()
{
	if (currentPic < maxPics) {
  	currentPic++;
  	showImage(currentPic);
  }
}

function showImageDec()
{
	if (currentPic > 1) {
  	currentPic--;
  	showImage(currentPic);
  }
}

function getContainerHeight(o) 
{
   containerHeight = $(o).parent().height();
   containerHeight -= 20;
}

function getScrollContent(o) 
{
   sc = $(o).next();
   sch = sc.height();
}
