/*****************************************************************************
 Default browsercheck - Leave this one
 ******************************************************************************/
function lib_bwcheck() { //Browsercheck (needed)
    this.ver = navigator.appVersion;
    this.agent = navigator.userAgent
    this.dom = document.getElementById ? 1 : 0
    this.ie5 = ((this.ver != null ? this.ver.indexOf("MSIE 5") : -1) > -1 && this.dom) ? 1 : 0;
    this.ie6 = ((this.ver != null ? this.ver.indexOf("MSIE 6") : -1) > -1 && this.dom) ? 1 : 0;
    this.ie4 = (document.all && !this.dom) ? 1 : 0;
    this.ie = this.ie4 || this.ie5 || this.ie6
    this.mac = (this.agent != null ? this.agent.indexOf("Mac") > -1 : false)
    this.opera5 = (this.agent != null ? this.agent.indexOf("Opera 5") > -1 : false)
    this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
    this.ns4 = (document.layers && !this.dom) ? 1 : 0;
    this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.dom)
    return this
}
var bw = new lib_bwcheck() //Making browsercheck object

function getInternetExplorerVersion()
    // Returns the version of Internet Explorer or a -1
    // (indicating the use of another browser).
{
    var rv = -1;
    // Return value assumes failure
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

function MM_goToURL() { //v3.0
    var i, args = MM_goToURL.arguments;
    document.MM_returnValue = false;
    for (i = 0; i < (args.length - 1); i += 2) eval(args[i] + ".location='" + args[i + 1] + "'");
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n);
    return x;
}

function MM_callJS(jsStr) { //v2.0
    return eval(jsStr)
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}

function TARIFFopenBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
    return false;
}

/* Copy text from the object to the clipboard */
function copy2clip(object) {
    if (window.clipboardData) {
        var html = object.value;
        txtrng = object.createTextRange();
        txtrng.execCommand("Copy");
        return true;
    } else {
        return false;
    }
}

/* The following two functions manages the bubbling problem of the onMouseOut event */
function containsDOM(container, containee) {
    var isParent = false;
    do {
        if ((isParent = container == containee))
            break;
        containee = containee.parentNode;
    }
    while (containee != null);
    return isParent;
}

function checkMouseLeave(element, evt) {
    if (element.contains && evt.toElement) {
        return !element.contains(evt.toElement);
    }
    else if (evt.relatedTarget) {
        return !containsDOM(element, evt.relatedTarget);
    }
}

/*
 * ATVTRE-1613; requirement from Denmark
 * Hack to fix Internet Explorer drop downs with fixed width and long text options
 */
var AT_IE_Version = getInternetExplorerVersion();

function AT_SelectOneMenu_OnMouseDown(select) {
    if (AT_IE_Version > 6) {
        select.style.width = 'auto';
    }
}
function AT_SelectOneMenu_OnMouseOver(select) {
    if (AT_IE_Version == 6) {
        select.style.width = 'auto';
    }
}
function AT_SelectOneMenu_OnMouseOut(select, width) {
    if (AT_IE_Version == 6) {
        if (window.event.toElement) {
            AT_SelectOneMenu_Restore(select, width);
        }
    }
}
function AT_SelectOneMenu_Restore(select, width) {
    if (AT_IE_Version >= 6) {
        select.style.width = width;
        select.blur();
    }
}
function documentSelectionHandler(selectedValue, size) {
	var i,j,group,name;
	if (selectedValue == "EMPTY") {
		return;
	}
	for (i = 1; i <= size; i++) {
		name = "DocOptionsNodeGrp" + i;
		group = document.getElementsByName(name);
		for (j = 0; j < group.length; j++) {
			if (group[j].value == selectedValue) {
				group[j].checked = true;
			}
		}
	}
}