#include "std.mi"
#include "pldir.mi"

Function fn_MoveAlbmArtLayer(AlbumArtLayer a, int TargetX, int TargetY, Float SpeedX, int TargetA);

Global Group		grpMain;
Global Group		grpSingInfo;
Global AlbumArtLayer	lyrAlbArt;
Global AlbumArtLayer	lyrAlbArt2;
Global string 		strStatus;

System.onScriptLoaded() {

	grpMain 	= getScriptGroup();
	grpSingInfo	= grpMain.findObject("AlbumArt.Group");
	lyrAlbArt	= grpSingInfo.findObject("AlbArt");
	lyrAlbArt2	= grpSingInfo.findObject("AlbArt2");

	lyrAlbArt2.setXmlParam("source", PlEdit.getFileName(PlEdit.getCurrentIndex()));
//	fn_MoveAlbmArtLayer(lyrAlbArt, -48, 0, 0.1, 255);
	strStatus = "one";
}

System.onTitlechange(String newTitle) {

	if(strStatus == "one"){

		strStatus = "two";
		lyrAlbArt.setXmlParam("source", PlEdit.getFileName(PlEdit.getCurrentIndex()));
		fn_MoveAlbmArtLayer(lyrAlbArt, 7, 6, 1.0, 255);
	}
}

lyrAlbArt.ontargetreached(){

	if(strStatus == "two"){

		strStatus = "one";
		lyrAlbArt2.setXmlParam("source", PlEdit.getFileName(PlEdit.getCurrentIndex()));
		fn_MoveAlbmArtLayer(lyrAlbArt, 7, 6, 1.0, 0);
	}
/*
	else if(strStatus == "three"){

		strStatus = "one";
		fn_MoveAlbmArtLayer(lyrAlbArt, -48, 2, 0.1, 255);
	}
*/
}

fn_MoveAlbmArtLayer(AlbumArtLayer a, int TargetX, int TargetY, Float SpeedX, int TargetA) {

        a.setTargetX(TargetX);
        a.setTargetY(TargetY);
        a.setTargetSpeed(SpeedX);
        a.setTargetA(TargetA);
        a.gotoTarget();
}