var currentSystem = '';
var overviewFaded = false;
var systemDisplayStaging = '';
function rollImageOn(img){
	$(img).animate({opacity: '.5'}, 100);
	$(img).parent().append('<div class="imageTitleContainer">hooboy.</div>');
}
function rollImageOff(img){
	$(img).animate({opacity: '1'}, 100);
}
function loadFullImage(imgNum, img){
	$('.imageDisplayText').html('');
	$('.imageDisplay').attr('src', 'images/systemsDisplay/' + currentSystem + '/fullSize/' + imgNum + '.jpg');
	$('.imageDisplayText').html($(img).attr('alt'));
	
}
function closeImage(){
	$('.imageDisplayContainer').fadeOut(250, function(){$('.imageDisplay').attr('src', '');});
}
function openImage(){
	$('.imageDisplayContainer').fadeIn(250);
}
function showNewSystem(){
	$('.rightCopy').html(systemDisplayStaging);
	$('.rightCopy').fadeIn(250);
}
function setNewWidth(){
	 $('.rightCopyContainer').css({width: '665px', left: '0px'});
	 $('.rightCopy').css({width: '640px', paddingTop: '20px'});
	$('#rCopyUpButton').css({visibility: 'visible', right: '0px'});
	$('#rCopyDownButton').css({visibility: 'visible', right: '0px'});
}
function fadeOverview(){
	overviewFaded = true;
	if(currentSystem != 'finishes'){
		$('.rightSingleImage').fadeOut(250);
		$('.rightCopy').fadeOut(250, function(){$(this).html('');showNewSystem(); setNewWidth();});
	} else {
		showNewSystem();
		setNewWidth();
	}
	
}
function fadeSystem(){
	$('.rightCopy').fadeOut(250, function(){$(this).html('');$('.rightCopy').css('top', 0);showNewSystem();});
}
function processSystem(){
	if(overviewFaded == false ){
	//alert('debug');
		fadeOverview();
	} else {
		fadeSystem();
	}
}

function loadSystem(obj){
	$(obj).blur();
	$('.aSubNavBox').children('a').removeClass('systemOn');
	$(obj).addClass('systemOn');
	var theTerm = '';
	switch($(obj).html()){
		case 'FINISHES': theTerm = 'finishes';
		break;
		case 'PANELS': theTerm = 'panels';
		break;
		default: theTerm = $(obj).attr('title');
		break
	}
	closeImage();
	currentSystem = theTerm;
	systemDisplayStaging = '';
	$.get("includes/selectSystem.php",
 	 { systemid: theTerm},
  	function(data){
		systemDisplayStaging = data;
		processSystem();
  }
);
}