//-----------------------------------------------------
// RESOLUUTION VALINTA
//-----------------------------------------------------
var selectResolution = function(){
  var el = document.getElementById("resolution");
  var reso = el.options[el.selectedIndex].value;
  var demoEl = document.getElementById("demo");
  
  //Resoluutiot on tarkoituksella 10px pielessä, koska jostain
  //syystä joskus selain leikkaa pari pikseliä kuvasta, jos kuva on koko ruudun levyinen.
  switch(reso){
    case "fs":
      var succeeded = true;
  
      if(demoEl.requestFullscreen){
        demoEl.requestFullscreen();
      }
      else if(demoEl.mozRequestFullScreen){
        demoEl.mozRequestFullScreen();
      }
      else if (demoEl.webkitRequestFullscreen){
        demoEl.webkitRequestFullscreen();
      }
      else{
        succeeded = false;
      }
      
      if(succeeded){
        TDEMO.width = screen.width;
        TDEMO.height = screen.height;
      }
      else{
        TDEMO.width = 1280;
        TDEMO.height = 720;
      }
      break;
      
    case "p1080":
      TDEMO.width = 1910;
      TDEMO.height = 1070;
      break;
    
    case "p900":
      TDEMO.width = 1590;
      TDEMO.height = 890;
      break;
    
    case "p720":
      TDEMO.width = 1270;
      TDEMO.height = 710;
      break;
    
    case "pal":
      TDEMO.width = 1014;
      TDEMO.height = 566;
      break;
    
    case "test":
      TDEMO.width = 128;
      TDEMO.height = 128;
      
      break;
    default:
      TDEMO.width = 1270;
      TDEMO.height = 710;
      break;
  }
  
  demoEl.width = TDEMO.width;
  demoEl.height = TDEMO.height;

  demoEl.style.position = "absolute";
  demoEl.style.top = ((window.innerHeight-TDEMO.height)/2).toString() + "px";
  demoEl.style.left = ((window.innerWidth-TDEMO.width)/2).toString() + "px";
  start();
};