function ClickPiece(src,eventdata,f1,hlastmove,hax)
% execute script for this image
%
% %%% code for ChessPiece, v1.1 2012, ZCD %%%
%
global userLockout
fs = filesep; % file separator
if ~userLockout && strcmp(get(gco,'type'),'image')
% what was the initial piece placement?
p0 = [get(gco,'XData');get(gco,'YData')];
% put this image on top of all others during movement
uistack(gco,'top')
% set the window's motion function
set(f1,'WindowButtonMotionFcn',{@DragPiece},...
'WindowButtonUpFcn',{@DropPiece,f1,p0,hlastmove})
end
% eliminate the previous move highlighting
set(hlastmove,'visible','off')
% also display the piece capability in peripheral image - the path to the
% rules image is stored in the image user data
set(f1,'CurrentAxes',hax(2)) % 2nd axis
rulesFile = get(gco,'UserData');
title(['- ' rulesFile(strfind(rulesFile,fs)+1:strfind(rulesFile,'Rules')-1) ' -'],...
'color','w','fontsize',16,'fontweight','bold')
[X, map, alpha] = imread(rulesFile);
image([0 1],[0 1],mirrorImage(X)); % plot new image
set(f1,'CurrentAxes',hax(1)) % return focus to main axes