var isRunning = false;
var autoJumpToImage = false;

function prevTab(prjID) {
	var tabOBJ 	= $("#tabListID"+prjID+" li a.current").parent().prev().children();
	if($(tabOBJ).parent().html() == $("#tabListID"+prjID+" li:eq(1)").html())
		tabOBJ 	= $("#tabListID"+prjID+" li:last").prev().children();
	$(tabOBJ).click();
	return autoJumpToImage;
}

function nextTab(prjID) {
	var tabOBJ 	= $("#tabListID"+prjID+" li a.current").parent().next().children();
	if(tabOBJ.parent().html()  == $("#tabListID"+prjID+" li:last").html())
		tabOBJ 	= $("#tabListID"+prjID+" li:eq(1)").next().children();
	$(tabOBJ).click();
	return autoJumpToImage;
}

function tabClick(tabOBJ, prjID, picName, picCaptionID) {
	if (isRunning)
		return false;
	isRunning = true;
	// Loadnew picture
	swapTabImage(prjID, picName, picCaptionID);
	// set Active Tab
	$("#tabListID"+prjID+" li a").removeClass("current");
	$(tabOBJ).addClass("current");
	return autoJumpToImage;
}

function swapTabImage(prjID, picName, picCaptionID) {	
	$("#tabID"+prjID).fadeOut("slow", function () {
							 var img = new Image();
							 $(img).load(function () {
							 	$("#tabID"+prjID+" img").attr("src",picName);
							 	$("#tabID"+prjID).fadeIn("fast");
        					 }).error(function () {
        					 }).attr('src', picName);
      					});
	$("#picDesc"+prjID).fadeOut("slow", function () {
        					 $("#picDesc"+prjID).html($('#'+picCaptionID).html());
							 $("#picDesc"+prjID).fadeIn("fast");
							 isRunning=false;
						});
}

