setBatchMode(false);

homeDir  =getDirectory("home");
macroDir = getDirectory("SalsaJ")+"Data/images_craters/";
remoteDir="http://www.euhou.net/SalsaJ/Data/images_craters/";
//macroDir = getDirectory("SalsaJ");
//homeDir=getDirectory("home");

print("Script display 2 Solar Systems craters");
print("Load the two image files");

runMacro("Close_All_Windows.txt");


name="terrecrater.fts";
openImage(name,macroDir,remoteDir);
//setMinAndMax(59., 11133.);

name="marscrater.fts"; 
openImage(name,macroDir,remoteDir);
//setMinAndMax(59., 11133.);



run("Sparer");
run("Tile");
run("Kachel");
run("Separar");
run("Disponi tutto");
run("Mosaico");
run("Sida vid sida");
run("Kaskada");

//run("Image Calculator...", "image1=\bpic.fts operation=Subtract image2=\ref.fts create");

//run("Enhance Contrast", "saturated=0.5");
//setMinAndMax(-2.000000000, 13.000000000);


function openImage(name,localDir,remoteDir){
	//print("name="+name);
	//print("local="+localDir);
	//print("remote="+remoteDir);
	if(! File.exists(localDir+name)){
		path=remoteDir+name;
		open(path);
		if (isOpen(name)) saveAs("FITS",localDir+name);
		else print(""+path+" is not opened");
	}
	else open(localDir+name);
}
