//
// Function: load()
// Called by HTML body element's onload event when the web application is ready to start
//
function load()
{   
    orientHandler();
}

//
// Function: flipToFront(event)
// Flip to the front view to show the normal utility view
//
function flipToFront(event)
{
    var views = document.getElementById('views');
    var front = document.getElementById('temperatur');
    if (views && views.object && front) {
        views.object.setCurrentView(front, true);
    }
    window.scrollTo(0,0);
}

//
// Function: flipToSettings(event)
// Flip to the back view to present user customizable settings
//
function flipToSettings(event)
{
    var views = document.getElementById('views');
    var settings = document.getElementById('webcam');
    if (views && views.object && settings) {
        views.object.setCurrentView(settings);
    }
    //window.scrollTo(0,0);
}
function orientHandler()
{
   var imageSrc = getOrientationArray();
   document.getElementById("temperatureIphone").src = imageSrc['imagesSource'];
   document.getElementById("webcam_img").width = window.innerWidth > 480 ? 480 : window.innerWidth;
   document.title = imageSrc['titleText'];
   window.scrollTo(0,0);
   
}

function getOrientationArray()
{
   var orientationArray = new Array();
   orientationArray["imagesSource"] = "";
   orientationArray["titleText"] = "";

   switch(window.orientation)
   {
       case 0:
           orientationArray['imagesSource'] += "http://www.typo3-webagentur.com/uploads/tx_elvweather/today-iphone.png";
           orientationArray["titleText"] = "Temperatur Heute";
       break;

       case -90:
           orientationArray['imagesSource'] += "http://www.typo3-webagentur.com/uploads/tx_elvweather/last-five-days-iphone.png";
           orientationArray["titleText"] = "Temperatur letzten 5 Tage";
       break;

       case 90:
           orientationArray['imagesSource'] += "http://www.typo3-webagentur.com/uploads/tx_elvweather/last-five-days-iphone.png";
           orientationArray["titleText"] = "Temperatur letzten 5 Tage";
      break;

       case 180:
           orientationArray['imagesSource'] += "http://www.typo3-webagentur.com/fileadmin/temperatur_iphone_heute.png";
           orientationArray["titleText"] = "Temperatur Heute";
      break;
       
       default:
            orientationArray['imagesSource'] += "";
       break;

   }
   return orientationArray;
}

