 Date.prototype.getDOY = function() {
   var onejan = new Date(this.getFullYear(),0,1);
   return Math.ceil((this - onejan) / 86400000);
 }

  Date.prototype.getDayOfYear = function() {
   var onejan = new Date(this.getFullYear(),0,1);
   return Math.floor((this - onejan) / 86400000);
 }

 function launchIntoFullscreen(element,caller) {
 if(state==0){
    if(element.requestFullscreen) {
      element.requestFullscreen();
    } else if(element.mozRequestFullScreen) {
      element.mozRequestFullScreen();
    } else if(element.webkitRequestFullscreen) {
      element.webkitRequestFullscreen();

    } else if(element.msRequestFullscreen) {
      element.msRequestFullscreen();
    }
    else{
      alert("Not Supported. Try pressing F11 to enter full screen mode");
    }
    state=1;
    $(caller).attr("title","Click to exit fullscreen mode");
  }
  else if(state==1){
    if(document.exitFullscreen) {
      document.exitFullscreen();
    } else if(document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if(document.webkitExitFullscreen) {
      document.webkitExitFullscreen();

    } else if(document.msExitFullscreen) {
      document.msExitFullscreen();
    }
   else{
      alert("Not Supported. Try pressing F11 to exit full screen mode");
    }
    state=0;
    $(caller).attr("title","Click to enter fullscreen mode");
  }

}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

var incrementColor = function(color, step){
    var colorToInt = parseInt(color.substr(1), 16),                     // Convert HEX color to integer
        nstep = parseInt(step);                                         // Convert step to integer
    if(!isNaN(colorToInt) && !isNaN(nstep)){                            // Make sure that color has been converted to integer
        colorToInt += nstep;                                            // Increment integer with step
        var ncolor = colorToInt.toString(16);                           // Convert back integer to HEX
        ncolor = '#' + (new Array(7-ncolor.length).join(0)) + ncolor;   // Left pad "0" to make HEX look like a color
        if(/^#[0-9a-f]{6}$/i.test(ncolor)){                             // Make sure that HEX is a valid color
            return ncolor;
        }
    }
    return color;
};