// Profiles

function swapProfilePhoto( turnoff, turnon ) {
	new Effect.Fade('profile_' + turnoff,  { duration: 0.2, queue: 'end' });
	new Effect.Appear('profile_' + turnon, { duration: 0.2, queue: 'end' });
}


// Clients

function changeToggle( link, state ) {
	if( state == 1 ) {
		$(link).className = "toggle selected";
	} else {
		$(link).className = "toggle";
	}
}

function showClientBox( client ) {
	// highlight the active client link and un-highlight the previous link
	changeToggle('show_client_' + $('current_client').value , 0);
	changeToggle('show_client_' + client , 1);
	
	// un-highlight the last toggle clicked for the previous client
	changeToggle('show_sample_' + $('current_client').value + '_' + $('current_sample').value , 0);
	
	// set the client boxes to be closed and opened
	hideclientbox = 'client_box_' + $('current_client').value;
	showclientbox = 'client_box_' + client;
		
	// hide the current client 
	$(hideclientbox).style.display = "none";
	
	// set the sample on the selected client to be the first (in the background)
	showClientSample( client, 1 );
	
	// show the selected client
	$(showclientbox).style.display = "block";
	
	// lastly...
	// reset the 'current client' and 'current_sample' values
	$('current_client').value = client;
	$('current_sample').value = 1;
}

function showClientSample( client, sample ) {
	// highlight the active sample link and un-highlight the previous link
	changeToggle('show_sample_' + $('current_client').value + '_' + $('current_sample').value , 0);
	changeToggle('show_sample_' + client + '_' + sample , 1);
	
	// shift the sample image left by 1/4 of the full image's width
	clientimage = 'portfolio_image_' + client;
	shiftby = 468 * sample - 468;
	$(clientimage).style.background = "url(/public/images/portfolio/" + client + ".jpg) -" + shiftby + "px 0px no-repeat";
	
	// hide the current sample 
	$('portfolio_details_' + $('current_client').value + '_' + $('current_sample').value).style.display = "none";
	
	// show the selected sample
	$('portfolio_details_' + client + '_' + sample).style.display = "block";
	
	// lastly...
	// reset the 'current client' and 'current_sample' values
	$('current_client').value = client;
	$('current_sample').value = sample;
}
