/*
########################################
#
# Author:: Dmitry V. Sabanin <dmitry@sabanin.ru>
# Copyright:: Copyright (c) 2005 MuraveyLabs, Ltd
# URL:: http://muravey.net/opensource/
# Revision:: $Date: 2005/04/02 10:36:18 $ $Revision: 1.4 $
# License:: MIT
#
########################################
*/

selectedAngle = -1
function rotate(angle, id)  {
  img = document.getElementById('rotateExample')
  img.src = rotate_img(angle, id)
  selectedAngle = angle
}

function rotateSpecific(angle, id) {
  img = document.getElementById('rotateExample')
  answer = prompt("Enter angle to rotate image on, positive values rotate clock-wise, negative vice versa", '')
  if (answer !=null && answer != "") {
    img.src = rotate_img(answer, id)
    selectedAngle = answer
  }
}

function rotate_img(angle, id) {
  path = '/image/show/' + id + '?limit_size=260'
  if(angle == -1) {
    return path
  }
  return path + '&rotate=' + angle
}

function postResult(id) {
  if(selectedAngle == -1) {
    alert("No actions were made on the image")
  } else {
    url = '/image/rotate/' + id + '?angle=' + selectedAngle
    window.location = url
    /*
    if(browser == 'Internet Explorer')
	    window.open(url, '_search', 'width=250,height=250,toolbar=0,resizable=0')
    else
	    window.open(url, '_blank', 'width=250,height=250,toolbar=0,resizable=0') */
  } 
}
