var currentProcessGroup = 0;
var processGroupCount = 1;
var moving = false;
function showTip(obj){
	$(obj).append('<div class="jsTip"></div>');
	$(obj).children('.jsTip').html($(obj).attr('name'));
}
function hideTip(obj){
	$(obj).children('.jsTip').remove();
}
function advanceCurrentGroup(){
		currentProcessGroup += 1;
}
function reduceCurrentGroup(){
		currentProcessGroup -= 1;
}
function bringNextGroup(){
	var theNext = 'imageGroup'+eval(currentProcessGroup + 1);
	theNext = eval('"#'+theNext+'"');
	$(theNext).fadeIn(250, function(){moving = false;});
	if(currentProcessGroup < processGroupCount - 1){
			advanceCurrentGroup();
	} 
	if (currentProcessGroup == processGroupCount - 1){
		$('.processNext').fadeOut(250);	
	}
	if (currentProcessGroup == 1){
		$('.processPrev').fadeIn(250);	
	}
}
function bringPrevGroup(){
	var theNext = 'imageGroup'+eval(currentProcessGroup - 1);
	theNext = eval('"#'+theNext+'"');
	$(theNext).fadeIn(250, function(){moving = false;});
	if(currentProcessGroup > 0){
			reduceCurrentGroup();
	} 
	if (currentProcessGroup == 0){
		$('.processPrev').fadeOut(250);	
	}
	if(currentProcessGroup < processGroupCount - 1){
			$('.processNext').fadeIn(250);	
	} 
}
function processNext(){
	if(moving == false){
		moving = true;
		var theCurrent = 'imageGroup'+currentProcessGroup;
		theCurrent = eval('"#'+theCurrent+'"');
		$(theCurrent).fadeOut(250, function(){bringNextGroup();});
	}
}
function processPrev(){
	if(moving == false){
		moving = true;
		var theCurrent = 'imageGroup'+currentProcessGroup;
		theCurrent = eval('"#'+theCurrent+'"');
		$(theCurrent).fadeOut(250, function(){bringPrevGroup();});
	}
	
}
function doImageGroups(){
	var tempCount = $('.processImageStage').children('.imageGroup');	
	tempCount = tempCount.length;
	if(tempCount > 1){
		$('.processNext').fadeIn(250);
		processGroupCount = tempCount;
	}
}
function getProcessItem(obj){
	//alert(obj);
	$.get('process/processor.php', {processnum: obj}, function(data){$('.mainContainer').append(data);$('.processInfo').fadeIn(250, function(){doImageGroups();});});
}
//getProcessItem(1);
function initGroupNums(){
	currentProcessGroup = 0;
	processGroupCount = 1;	
}
function closeProcess(){
	$('.processInfo').fadeOut(250, function(){$('.processInfo').html('');$('.processInfo').remove();initGroupNums()});	
}
