var version = 5
var submenu = false;
var doVersionCheck = true;

// constants indirectly defined in css
// used for resizing
var cssDimensions;

// updated whenever the tvguide is loaded
var tvguideHeight;

var urls = {
  "img": "http://ontv.dk/imgs/epg/logos/",
  "api": "http://ontv.dk/extern/api/generic/"
};

var user = {
  // will be set by log in-function
  "isPro": false,
  "showJustEnded": false,
  "pushEnabled": false,
  "authUrl": ""
};

function getDimensions(){
  // before resizing, we need to find some constants, defined indirectly in the css
  return {
    // minimum dimensions of widget
    minX: window.innerWidth,
    minY: 200,
    normalY: 332,
    maxY: 800,
    
    resizeHandleHeight: 12, // todo - get dynamically

    // height-difference between window and the content/submenu holder 
    contentWindowDiff: 111,
  
    // the height-difference between content/submenu holder and content holder
    holderDifference: $("#ontv_content_and_submenu_holder").height() - $("#ontv_content_holder").height()
  };
}


Date.prototype.defaultView=function(){
    var dd=this.getDate();
    if(dd<10) { 
      dd='0'+dd; 
    }
    var mm=this.getMonth()+1;
    if(mm<10) {
      mm='0'+mm;
    }
    var yyyy=this.getFullYear();
    return String(yyyy+"-"+mm+"-"+dd);
  };

// do stuff when DOM is ready
$(document).ready(function() {

  translateHtml();

  // try to log in - display tvguide no matter what
  logIn(loadPref('username'),loadPref('password'),tvguide,tvguide);

  addListeners();

  showPreloader();

  cssDimensions = getDimensions();
  
  // platform specific init
  initPlatform();
  
});


