﻿/**
 *  Common functions
 *
 */


function LaunchPopUp(url){
    return LaunchPopUpSized(url, 750, 350);
}

function LaunchPopUpBig(url){
    return LaunchPopUpSized(url, 850, 500);
}

function LaunchPopUpSized(url, width, height) {
    winName = 'popUp' + Math.floor(Math.random()*10000);
    window.open(url, winName, 'width=' + width + 'px,height=' + height + 'px,location=0,menubar=0,status=0,toolbar=0,resizable=yes,scrollbars=yes');
    return false;

}

function Refresh(){window.location.reload();}

function GetRef(id)
{
    if(typeof id == "string")
    {
        return document.getElementById(id);
    }
    else 
    {
        return id;
    }

}
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
    
    if(opacity == 0)
        GetRef('OkDiv').style.display = 'none';

}

function MyOpacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
    
function shiftOpacity(id, millisec) {
    MyOpacity(id, 90, 0, millisec);
} 

function ShowMessage()
{
    GetRef('OkDiv').style.display = 'block';
    MyOpacity('OkDiv', 1, 100, 1000);
    //  Show the message box 
    setTimeout("shiftOpacity('OkDiv', 2000)", 10000);
}


