﻿function createRotator(container) {

   cleanUp();
   
    _originalwidth = $('editimg').width;  
  
      var title = document.createElement("h3");
    var titleText = document.createTextNode("Rotate");
    
    title.appendChild(titleText);
    
    $(container).appendChild(title);   
   
    var btnrotatecc = document.createElement("input");
    
      btnrotatecc.setAttribute("value","Left");
      
       btnrotatecc.setAttribute("type","button");
       
        btnrotatecc.className = 'button';       
    
    var btnrotatecw = document.createElement("input");
    
      btnrotatecw.setAttribute("value","Right");
      
       btnrotatecw.setAttribute("type","button"); 
       
       btnrotatecw.className = 'button';       
 

    
   $(container).appendChild(btnrotatecc);
    
   $(container).appendChild(btnrotatecw);
   
   
   Event.observe(btnrotatecw, 'click', function(e){ saveRotate('270');});
   
   Event.observe(btnrotatecc, 'click', function(e){ saveRotate('90');});
   

   

}

function cancelRotator() {

           
    cleanUp();
    

}

function saveRotate(direction) {

    PixerMain.RotateImage(direction, saveRotate_callback);
    

}


function saveRotate_callback(e) {
    
     reloadImage();       
     
     cleanUp();
     
     changesApplied();

}
