﻿///////////////////////////////////////////////////////////////////////////////
//
//  todae.scalr.js   			version 1.0.0.0
//
//  This file is UCAYA by Microsoft as a helper file for websites ad pages
//  incorporate in Todae Radio.
//  Only for IE in WindowsMediaCenter.
// 
//  Copyright (c) UCAYA. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////

if (!window.Todae)
    window.Todae = {};

if (!Todae.Scalr)
    Todae.Scalr = {};

function $get(id) {
    return document.getElementById(id);
}

Todae.Scalr.BaseWidth = 1024;
Todae.Scalr.BaseHeight = 768;
Todae.Scalr.ElementID = "";

Todae.Scalr.zoom = function() {
    var w = Todae.Scalr.BaseWidth;
    var h = Todae.Scalr.BaseHeight;

    var y = document.body.clientHeight;
    var x = document.body.clientWidth;

    var factor = (((x / w) < (y / h)) ? x / w : y / h);

    var element = document.body;
    if (Todae.Scalr.ElementID != "")
        element = $get(Todae.Scalr.ElementID);

    return element.style.zoom = factor;
};

Todae.Scalr.__onresize = function(e) {
    Todae.Scalr.zoom();

    return true;
};

Todae.Scalr.__startup = function() 
{
    if (window.attachEvent) {
        window.attachEvent('onresize', Todae.Scalr.__onresize);
    }
    
    Todae.Scalr.zoom();

    if (!Todae.Scalr.disableAutoStartup) {
        if (window.attachEvent) {
            window.detachEvent('onload', Todae.Scalr.__startup);
        }
    }
};

if (!Todae.Scalr.disableAutoStartup) 
{
    if (window.attachEvent) {
        window.attachEvent('onload', Todae.Scalr.__startup);
    }
}