setBatchMode(false);

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


//Print("Home Dir: "+homeDir);
//print("Macro Dir: "+macroDir);
//print("Startup Dir: "+getDirectory("startup"));
//print("Images Dir: "+getDirectory("image"));
//print("Plugins Dir: "+getDirectory("plugins"));

print("Script to study one supernova Ia in NGC691");
print("Load all the necessary image");

runMacro("Close_All_Windows.txt");
	

name="NGC691_07022005.fits";
openImage(name,macroDir,remoteDir);
setMinAndMax(94553.4531, 97741.5547);

name="NGC691_13111953.fits";
openImage(name,macroDir,remoteDir);
setMinAndMax(2858.4961, 10163.4434);
		
run("Séparer");
run("Tile");
run("Kachel");
run("Separar");
run("Disponi tutto");
run("Mosaico");
run("Sida vid sida");
run("Kaskada");


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);
}
