/**
 * opens a popup window
 */
var popUps = new Array();
var DEF_POPUP_ATTR = "width=440,height=550,left=20,top=20,scrollbars=yes,resizable=no,status=no";
var DEF_POPUP_NAME = "emb_popup";
function openChild(source, name, attributes){
    if (!source) {
        return;
    }
    attributes = attributes || DEF_POPUP_ATTR;
    name = name || DEF_POPUP_NAME;
    if (!popUps[name] || popUps[name].closed == true) {
        window.open(source, name, attributes);
    }
    else {
        popUps[name].close();
        popUps[name] = window.open(source, name, attributes);
    }
}
/**
 some common helper functions
 */
function getLayer(strID){
    if (document.all && !window.opera) 
        return document.all[strID];
    else 
        return document.getElementById(strID);
}

function setClass(element, className){
    if (element == null || className == null) {
        return;
    }
    
    if (document.all && !window.opera) {
        element.className = className;
    }
    else {
        element.setAttribute("class", className);
    }
}

function removeClass(element){
    if (element == null) {
        return;
    }
    
    if (document.all && !window.opera) {
        element.className = "";
    }
    else {
        element.removeAttribute("class");
    }
}

function getClassName(element){
    if (element == null) {
        return "";
    }
    var className = document.all && !window.opera ? element.className : element.getAttribute("class");
    return className == null ? "" : className;
}

/**
 * set events, w3c-compatible and ie
 */
function addEvent(obj, eventType, func, useCaption){
    if (!obj || !eventType || !func) {
        return false;
    }
    else 
        if (obj.addEventListener) {
            obj.addEventListener(eventType, func, useCaption);
            return true;
        }
        else 
            if (obj.attachEvent) {
                var retVal = obj.attachEvent("on" + eventType, func);
                return retVal;
            }
            else {
                return false;
            }
}
