//---------------------------------------------------------------------
// ibrows.js - browser compatibility layer
//   version 0.10 (Nov. 21th, 2007)
//
// Copyright (c) 2007-2008 Satoshi Nakajima
//
// See ianime.js regarding the MIT License
//---------------------------------------------------------------------
var iBrowse = function() {
};

(function(){
    var ua = navigator.userAgent.toLowerCase();
    var env = {
        userAgent:  ua,
        webkit:     /webkit/.test(ua),
        opera:      /opera/.test(ua),
        compatible: /compatible/.test(ua),
        msie:       /msie/.test(ua),
        mozilla:    /mozilla/.test(ua)
    };
    env.msie = env.msie && !env.opera;
    env.mozilla  = env.mozilla && !(env.compatible || env.webkit);
    iBrowse.env = env;
})();

iBrowse.setOpacity = function(obj, a) {
    obj.style.opacity = a;
};

iBrowse.getWindowWidth = function() {
    return window.innerWidth;
};

iBrowse.getWindowHeight = function() {
    return window.innerHeight;
};

iBrowse.setText = function(obj, text) {
    obj.innerText = text;
};

//================================
// Compatibility layer for FireFox
//================================

iBrowse.setTextFF = function(obj, text) {
    obj.textContent = text;
};

(function(){
    if (iBrowse.env.mozilla) {
        iBrowse.setText = iBrowse.setTextFF;
    }
})();

//================================
// Compatibility layer for MSIE
//================================
iBrowse.setOpacityIE = function(obj, a) {
    obj.style.filter = 'alpha(opacity=' + a*100 + ')';
};

iBrowse.getWindowWidthIE = function() {
    return document.documentElement.clientWidth;
};

iBrowse.getWindowHeightIE = function() {
    return document.documentElement.clientHeight;
};

(function(){
    if (iBrowse.env.msie) {
        iBrowse.setOpacity = iBrowse.setOpacityIE;
        iBrowse.getWindowWidth = iBrowse.getWindowWidthIE;
        iBrowse.getWindowHeight = iBrowse.getWindowHeightIE;
    }
})();