﻿var divChat;
var divBlock;
var divChatWindow;

function showChat() {
    //document.body.style.overflow = 'hidden';
    divChat = document.getElementById('divChat');
    divBlock = document.getElementById('divBlock');
    divChatWindow = document.getElementById('divChatWindow');
    divChat.style.display = 'block';
    window.onresize += posChat;
    posChat();    
    fadeBlockIn(10);
}

function hideChat() {
    divChat.style.display = 'none';
}

function posChat() {
    var h = viewPortHeight();
    var w = viewPortWidth()
    divChat.style.height = h + 'px';
    divChat.style.width = w + 'px';
    divChat.style.top = document.body.offsetTop;
    divChatWindow.style.top = ((h / 2) - (divChatWindow.offsetHeight / 2)) + 'px';
    divChatWindow.style.left = ((w / 2) - (divChatWindow.offsetWidth / 2)) + 'px';
}

function fadeBlockIn(opac) {
    divBlock.style.filter = 'alpha(opacity=' + opac.toString() + ')';
    divBlock.style.opacity = parseFloat(opac) / 100;
    if (opac < 80) {
        window.setTimeout('fadeBlockIn(' + (opac + 10).toString() + ')', 5);
    }
}

function viewPortHeight() {
    if (typeof window.innerWidth != 'undefined') {
        return window.innerHeight;
    }
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
        return document.documentElement.clientHeight;
    }
    else {
        return document.getElementsByTagName('body')[0].clientHeight;
    }
}

function viewPortWidth() {
    if (typeof window.innerWidth != 'undefined') {
        return window.innerWidth;
    }
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
        return document.documentElement.clientWidth;
    }
    else {
        return document.getElementsByTagName('body')[0].clientWidth;
    }
}
