function photoDialog_rotate(iIdentify) {
	this.inheritFrom = photoDialog;
	this.inheritFrom();
	
	this.dialogStuff = null;
	this.rotateImage = null;
	
	this.rotateAngle = 0;
	this.identify = iIdentify;
	
	// ------------- override --------------
	this.inicialize = function() {
		this.beforeState = "dialog_state1";
	
		this.dialogStuff = document.getElementById(this.identify + "dialog_stuff");
		this.rotateImage = document.getElementById(this.identify + "dialog_rotateImage");
	}
	
	this.execute = function() {
		this.commandName = "photo_rotate";
		this.additionalParams = (this.rotateAngle == 0) ? "0" : this.rotateAngle;
		var cmd = this.composeCommand();
		
		if (exec == null) alert("Chyba!");
		else this.execCmd(cmd);
	}
	
	this.finish = function(success) {
		if (this.finishFlag) {
			// update poznamek (globalni reference)
			if (noteHand != null) {
				noteHand.rebuild();
			}
			if (cropHand != null) {
                cropHand.rebuild();
            }
			// ----------------------------------

			if (this.dialogMod != "nouncheck") photos.uncheck();
			this.setState("dialog_state3");
			this.finishFlag = false;
		}
	}
	
	this.updateSelection = function(iRef) {
		if (dialogs.collection.length == 0) {
			this.setState("dialog_state1");
			this.rotateAngle = 0;
		} else {
			this.updatePicture();
			this.setState("dialog_state2");
			this.updateStuff();
		}
	}
	// -------------------------------------
	
	this.updatePicture = function() {
		this.rotateImage.src = "picture_output.php?ang=" + this.rotateAngle + "&phid=" + dialogs.collection[0].photo_ID + "&sf=X0I%3D&rnd=" + Math.round(Math.random() * 65535);
	}
	
	this.updateStuff = function() {
		var toPut = "";
		if (dialogs.collection.length == 1)	toPut = "Otočit fotku";
		else toPut = "Otočení " + dialogs.collection.length + " fotek";
		if (this.rotateAngle != 0) toPut += " o <strong>" + this.rotateAngle + " stupňů</strong>.";
		else toPut += "."
		this.dialogStuff.innerHTML = toPut;
	}
	
	this.rotateRight = function() {
		this.rotateAngle += -90;
		this.rotateAngle = this.rotateAngle % 360;
		if (this.rotateAngle < 0) this.rotateAngle = 360 + this.rotateAngle;
		this.updatePicture();
		this.updateStuff();
	}
	
	this.rotateLeft = function() {
		this.rotateAngle += 90;
		this.rotateAngle = this.rotateAngle % 360;
		this.updatePicture();
		this.updateStuff();
	}
	
	this.resetAngle = function() {
		this.rotateAngle = 0;
		this.updatePicture();
		this.updateStuff();
	}
	
	this.toStart = function() {
		this.rotateAngle = 0;
		this.updateStuff();
		this.setState(dialogs.collection.length == 0 ? "dialog_state1" : "dialog_state2");
	}
	
	this.toCancel = function() {
		this.resetAngle();
		if (this.dialogMod == "nouncheck" && this.hideFunction != null) this.hideFunction(this.identify);
	}
}

