﻿// SWFObject.js
/**
* SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
*   legal reasons.
*/
if (typeof deconcept == "undefined") { var deconcept = new Object(); }
if (typeof deconcept.util == "undefined") { deconcept.util = new Object(); }
if (typeof deconcept.SWFObjectUtil == "undefined") { deconcept.SWFObjectUtil = new Object(); }
deconcept.SWFObject = function (_1, id, w, h, _5, c, _7, _8, _9, _a, _b) {
    if (!document.getElementById) { return; }
    this.DETECT_KEY = _b ? _b : "detectflash";
    this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();
    if (_1) { this.setAttribute("swf", _1); }
    if (id) { this.setAttribute("id", id); }
    if (w) { this.setAttribute("width", w); }
    if (h) { this.setAttribute("height", h); }
    if (_5) { this.setAttribute("version", new deconcept.PlayerVersion(_5.toString().split("."))); }
    this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
    if (c) { this.addParam("bgcolor", c); }
    var q = _8 ? _8 : "high";
    this.addParam("quality", q);
    this.setAttribute("useExpressInstall", _7);
    this.setAttribute("doExpressInstall", false);
    var _d = (_9) ? _9 : window.location;
    this.setAttribute("xiRedirectUrl", _d);
    this.setAttribute("redirectUrl", "");
    if (_a) { this.setAttribute("redirectUrl", _a); } 
};
deconcept.SWFObject.prototype = { setAttribute: function (_e, _f) {
    this.attributes[_e] = _f;
}, getAttribute: function (_10) {
    return this.attributes[_10];
}, addParam: function (_11, _12) {
    this.params[_11] = _12;
}, getParams: function () {
    return this.params;
}, addVariable: function (_13, _14) {
    this.variables[_13] = _14;
}, getVariable: function (_15) {
    return this.variables[_15];
}, getVariables: function () {
    return this.variables;
}, getVariablePairs: function () {
    var _16 = new Array();
    var key;
    var _18 = this.getVariables();
    for (key in _18) { _16.push(key + "=" + _18[key]); }
    return _16;
}, getSWFHTML: function () {
    var _19 = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
        if (this.getAttribute("doExpressInstall")) {
            this.addVariable("MMplayerType", "PlugIn");
        }
        _19 = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute("swf") + "\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\"";
        _19 += " id=\"" + this.getAttribute("id") + "\" name=\"" + this.getAttribute("id") + "\" ";
        var _1a = this.getParams();
        for (var key in _1a) { _19 += [key] + "=\"" + _1a[key] + "\" "; }
        var _1c = this.getVariablePairs().join("&");
        if (_1c.length > 0) { _19 += "flashvars=\"" + _1c + "\""; } _19 += "/>";
    } else {
        if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
        _19 = "<object id=\"" + this.getAttribute("id") + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\">";
        _19 += "<param name=\"movie\" value=\"" + this.getAttribute("swf") + "\" />";
        var _1d = this.getParams();
        for (var key in _1d) { _19 += "<param name=\"" + key + "\" value=\"" + _1d[key] + "\" />"; }
        var _1f = this.getVariablePairs().join("&");
        if (_1f.length > 0) { _19 += "<param name=\"flashvars\" value=\"" + _1f + "\" />"; } _19 += "</object>";
    }
    return _19;
}, write: function (_20) {
    if (this.getAttribute("useExpressInstall")) {
        var _21 = new deconcept.PlayerVersion([6, 0, 65]);
        if (this.installedVer.versionIsValid(_21) && !this.installedVer.versionIsValid(this.getAttribute("version"))) {
            this.setAttribute("doExpressInstall", true);
            this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl")));
            document.title = document.title.slice(0, 47) + " - Flash Player Installation";
            this.addVariable("MMdoctitle", document.title);
        } 
    }
    if (this.skipDetect || this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version"))) {
        var n = (typeof _20 == "string") ? document.getElementById(_20) : _20;
        n.innerHTML = this.getSWFHTML(); return true;
    } else { if (this.getAttribute("redirectUrl") != "") { document.location.replace(this.getAttribute("redirectUrl")); } }
    return false;
} 
};
deconcept.SWFObjectUtil.getPlayerVersion = function () {
    var _23 = new deconcept.PlayerVersion([0, 0, 0]);
    if (navigator.plugins && navigator.mimeTypes.length) {
        var x = navigator.plugins["Shockwave Flash"];
        if (x && x.description) { _23 = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); }
    } else {
        try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); }
        catch (e) {
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                _23 = new deconcept.PlayerVersion([6, 0, 21]); axo.AllowScriptAccess = "always";
            }
            catch (e) { if (_23.major == 6) { return _23; } } try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); }
            catch (e) { } 
        } if (axo != null) { _23 = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } 
    }
    return _23;
};
deconcept.PlayerVersion = function (_27) {
    this.major = _27[0] != null ? parseInt(_27[0]) : 0;
    this.minor = _27[1] != null ? parseInt(_27[1]) : 0;
    this.rev = _27[2] != null ? parseInt(_27[2]) : 0;
};
deconcept.PlayerVersion.prototype.versionIsValid = function (fv) {
    if (this.major < fv.major) { return false; }
    if (this.major > fv.major) { return true; }
    if (this.minor < fv.minor) { return false; }
    if (this.minor > fv.minor) { return true; }
    if (this.rev < fv.rev) {
        return false;
    } return true;
};
deconcept.util = { getRequestParameter: function (_29) {
    var q = document.location.search || document.location.hash;
    if (q) {
        var _2b = q.substring(1).split("&");
        for (var i = 0; i < _2b.length; i++) {
            if (_2b[i].substring(0, _2b[i].indexOf("=")) == _29) {
                return _2b[i].substring((_2b[i].indexOf("=") + 1));
            } 
        } 
    }
    return "";
} 
};
deconcept.SWFObjectUtil.cleanupSWFs = function () {
    if (window.opera || !document.all) { return; }
    var _2d = document.getElementsByTagName("OBJECT");
    for (var i = 0; i < _2d.length; i++) {
        _2d[i].style.display = "none"; for (var x in _2d[i]) {
            if (typeof _2d[i][x] == "function") { _2d[i][x] = function () { }; } 
        } 
    } 
};
deconcept.SWFObjectUtil.prepUnload = function () {
    __flash_unloadHandler = function () { };
    __flash_savedUnloadHandler = function () { };
    if (typeof window.onunload == "function") {
        var _30 = window.onunload;
        window.onunload = function () {
            deconcept.SWFObjectUtil.cleanupSWFs(); _30();
        };
    } else { window.onunload = deconcept.SWFObjectUtil.cleanupSWFs; } 
};
if (typeof window.onbeforeunload == "function") {
    var oldBeforeUnload = window.onbeforeunload;
    window.onbeforeunload = function () {
        deconcept.SWFObjectUtil.prepUnload();
        oldBeforeUnload();
    };
} else { window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload; }
if (Array.prototype.push == null) {
    Array.prototype.push = function (_31) {
        this[this.length] = _31;
        return this.length;
    };
}
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject;
var SWFObject = deconcept.SWFObject;




// main.js

// Globals
var gMenuTimer = null;

// ------------------------------------------------------------
// Changes the height of a number of div so they are the same
// height. The input param is an array with div-id:s.
// ------------------------------------------------------------
function adaptDivs(divNameArr, minHeight) {
    var height = minHeight;
    var divArr = Array();

    // Loop over all the divs to get the height if the highest
    for (i = 0; i < divNameArr.length; i++) {
        divArr[i] = document.getElementById(divNameArr[i]);

        if (divArr[i]) {
            // We set the height to auto to erase any previously hardcoded pixel
            // values which will otherwise prevent this function from running correctly
            // more than one time. It's useful to be able to call this function
            // again when dynamic content is displayed on the page.
            divArr[i].style.height = 'auto';

            if (divArr[i].clientHeight > height) {
                height = divArr[i].clientHeight;
            }
        }
    }

    // Set the height for all divs
    for (i = 0; i < divArr.length; i++) {
        if (divArr[i]) {
            divArr[i].style.height = height + 'px';
        }
    }
}

// ------------------------------------------------------------
// Shows the specified element
// ------------------------------------------------------------
function showElement(elemId) {
    var elem = document.getElementById(elemId);
    if (elem) {
        elem.style.display = 'block';
    }
}

// ------------------------------------------------------------
// Hides the specified element
// ------------------------------------------------------------
function hideElement(elemId) {
    var elem = document.getElementById(elemId);
    if (elem) {
        elem.style.display = 'none';
    }
}

// ---------------
// Toggles visibility of the specified element.
// ---------------
function toggleVisibility(elemId) {
    var elem = document.getElementById(elemId);

    if (elem) {
        if (elem.style.display == 'none') {
            elem.style.display = 'block';
        }
        else {
            elem.style.display = 'none';
        }
    }
}

// ------------------------------------------------------------
// Returns the x coordinate of the specified object
// ------------------------------------------------------------
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.clientLeft) {
        curleft += obj.clientLeft;
    }
    return curleft;
}

// ------------------------------------------------------------
// Returns the y coordinate of the specified object
// ------------------------------------------------------------
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.clientTop) {
        curtop += obj.clientTop;
    }
    return curtop;
}

// ------------------------------------------------------------
// This function will fire a click event on the specified control when the 
// enter key is pressed in a text field. Attach this function to the 
// onkeypress-event on the text field like this:
// <input type="text" onkeypress="return fireClickOnEnter(event, 'IdOfControlToFireClickOn');">
// ------------------------------------------------------------
function fireClickOnEnter(evt, controlId) {
    var control = document.getElementById(controlId);
    var keyCode = (typeof window.event == 'object') ? window.event.keyCode : evt.keyCode;

    // If enter is pressed -> fire click-event on the control
    if (control && (keyCode == 13)) {
        control.focus();
        control.click();
        return false;
    }
    else {
        return true;
    }
}

// ------------------------------------------------------------
// This function will fire a postbackon the specified control when the 
// enter key is pressed in a text field. Attach this function to the 
// onkeypress-event on the text field like this:
// <input type="text" onkeypress="return postbackOnEnter(event, 'IdOfControlToFirePostbackOn');">
// ------------------------------------------------------------
function postbackOnEnter(evt, controlId) {
    var keyCode = (typeof window.event == 'object') ? window.event.keyCode : evt.keyCode;

    // If enter is pressed -> do a postback
    if (keyCode == 13) {
        __doPostBack(controlId, '');
        return false;
    }
    else {
        return true;
    }
}

// ---------------
// Returns a parameter from the query string
// ---------------
function getUrlParam(strParamName) {
    var strReturn = '';
    var strHref = window.location.href;
    if (strHref.indexOf('?') > -1) {
        var strQueryString = strHref.substr(strHref.indexOf('?'));
        var aQueryString = strQueryString.split('&');
        for (var iParam = 0; iParam < aQueryString.length; iParam++) {
            if (aQueryString[iParam].indexOf(strParamName + '=') > -1) {
                var aParam = aQueryString[iParam].split('=');
                strReturn = aParam[1];
                break;
            }
        }
    }
    return strReturn;
}

// ------------------------------------------------------------
// Opens the specified link. Internal links will open in the
// same window. External links will open in a ne window.
// ------------------------------------------------------------
function openLink(url) {
    if (url && (url != '')) {
        if (url.charAt(0) == '/') // Internal
        {
            window.location.href = url;
        }
        else // External
        {
            window.open(url);
        }
    }
}

// ------------------------------------------------------------
// Called from the onload-event on the body-tag
// ------------------------------------------------------------
function adaptMainDivs() {
    return;
    var arrDivs = Array('leftareadiv', 'rightareadiv');
    adaptDivs(arrDivs, 300);

    arrDivs = Array('BreadCrumbLeftMenuFakeDiv', 'BreadCrumbDiv');
    adaptDivs(arrDivs, 0);
}

// ------------------------------------------------------------
// Opens the language pop-up menu.
// ------------------------------------------------------------
function openLanguageMenu() {
    var languageImg = document.getElementById('LanguageImage');
    var languageMenu = document.getElementById('LanguageMenuDiv');

    if (languageImg && languageMenu) {
        stopCloseMenuTimer();
        languageMenu.style.left = findPosX(languageImg) + 'px';
        languageMenu.style.top = (findPosY(languageImg) + 16) + 'px';
        languageMenu.style.display = 'block';
    }
}

// ------------------------------------------------------------
// Opens a sub-menu in the page top menu.
// ------------------------------------------------------------
function openPageTopSubMenu(pageId) {
    var menuItem = document.getElementById('PageTopMenuItem' + pageId);
    var subMenu = document.getElementById('PageTopSubMenu' + pageId);

    if (menuItem && subMenu) {
        stopCloseMenuTimer();
        subMenu.style.left = (findPosX(menuItem) - 2) + 'px';
        subMenu.style.top = (findPosY(menuItem) + 29) + 'px';
        subMenu.style.display = 'block';
    }
}

// ------------------------------------------------------------
// Starts a timer that will close the specified popup menu
// ------------------------------------------------------------
function closePopupMenu(menuId) {
    if (gMenuTimer == null) {
        gMenuTimer = window.setTimeout('hideElement(\'' + menuId + '\')', 200);
    }
}

// ------------------------------------------------------------
// Stops the closemenu-timer
// ------------------------------------------------------------
function stopCloseMenuTimer() {
    if (gMenuTimer != null) {
        window.clearTimeout(gMenuTimer);
        gMenuTimer = null;
    }
}

// ------------------------------------------------------------
// Fires search when search button is clicked.
// ------------------------------------------------------------
function fireQuickSearch(languageCode) {
    var searchField = document.getElementById('QuickSearchField');
    if (searchField && (searchField.value != '')) {
        url = "http://afconsult.siteseeker.se?q=" + escape(searchField.value) +
			((languageCode != 'SV') ? '&i=en' : '');

        window.location.href = url;
    }
}

// ------------------------------------------------------------
// Fires search when enter is pressed in search field
// ------------------------------------------------------------
function fireQuickSearchOnEnter(evt, languageCode) {
    var keyCode = (typeof window.event == 'object') ? window.event.keyCode : evt.keyCode;

    // If enter is pressed -> fire the search
    if (keyCode == 13) {
        fireQuickSearch(languageCode);
        return false;
    }
    else {
        return true;
    }
}

// ------------------------------------------------------------
// Builds an html-page for printing
// ------------------------------------------------------------
function printPage(pageTitle, pageFooter) {
    if (!window.print) {
        window.status = 'No print';
        return;
    }

    // Get the main content area and other stuff we need
    var contentdiv = document.getElementById('contentdiv');

    if (contentdiv) {
        var contentHtml = '<div style="width: 475px">' + contentdiv.innerHTML + '</div>';
        var footerHtml = '<div style="width: 475px"><br /><hr />' + pageFooter + '</div>';

        var beginHtml =
			  '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
		      '<html>' +
			  '<head>' +
			  '<link rel="stylesheet" type="text/css" href="' + gAppRoot + 'styles/structure.css">' +
			  '<link rel="stylesheet" type="text/css" href="' + gAppRoot + 'styles/main.css">' +
			  '<link rel="stylesheet" type="text/css" href="' + gAppRoot + 'styles/units.css">' +
			  '<style> .PrintExclude { visibility: hidden; position: absolute; top: 0px; height: 0px } </style>' +
			  '<title>' + pageTitle + '</title>' +
			  '</head>' +
			  '<body style="margin: 20px; background-color: #fff; background-image: none">';

        var endHtml = '</body></html>';

        var printWin = window.open('about:blank', '', 'width=700,height=600,scrollbars=yes,toolbar=yes');
        printWin.document.open();
        printWin.document.write(beginHtml +
		                        contentHtml +
		                        footerHtml +
		                        endHtml);
        printWin.document.close();

        printWin.print();
        printWin.close();
    }
}
//Writes flash to div.
function AddStaticFlash(flashSrc, width, height, targetElementId, flashVersion, clickUrl) {
    flashVersion = flashVersion || "7";
    clickUrl = clickUrl || "";
    var so = new SWFObject(flashSrc, "header", width, height, flashVersion, "#FFFFFF");
    so.addParam("quality", "high");

    if (clickUrl.length > 0)
        so.addVariable("linkUrl", escape(clickUrl));

    //Write to div.
    so.write(targetElementId)
}

var Url = {

    // public method for url encoding
    encode: function (string) {
        return escape(this._utf8_encode(string));
    },


    // private method for UTF-8 encoding
    _utf8_encode: function (string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    }
}


// rekrytera.js
/*
Rekrytera Javascript file.
Implemented 2006-10-19
*/

function displayPositionPopup(divid, refObj, pos) {
    var div = document.getElementById(divid);
    var top = 0;
    var left = 0;

    if (div && refObj) {
        div.style.zIndex = '2001';

        alert(document.documentElement.scrollTop);
        alert(refObj.id);
        alert('left=' + refObj.clientLeft);
        alert('top=' + refObj.clientTop);

        if (div.style.display == 'none') {
            //Create iframe and add it to div's parent childcollection.
            var frame = document.createElement("iframe");
            div.parentElement.appendChild(frame);

            //set style.
            frame.id = divid + "_Iframe";
            frame.style.border = "0";
            frame.style.position = "absolute";
            frame.style.frameBorder = 0;
            //--

            div.style.position = "absolute";
            div.style.display = 'block';
            frame.style.display = 'block';

            if (pos == 'over') {
                top = GetScrollTop() + (refObj.clientTop - div.clientHeight);
                left = GetScrollLeft() + (refObj.clientLeft - (div.clientWidth / 2));
            }
            else if (pos == 'under') {
                top = refObj.clientTop + refObj.clientHeight;
                left = refObj.clientLeft - (div.clientWidth / 2);
            }

            //reset if out of bounds.
            if (top < 0) top = 0;
            if (left < 0) left = 0;
            //--

            div.style.top = top + 'px';
            div.style.left = left + 'px';
            frame.style.top = top + 'px';
            frame.style.left = left + 'px';
            frame.style.width = div.clientWidth + 'px';
            frame.style.height = div.clientHeight + 'px';
            frame.style.zIndex = '' + (parseInt(div.style.zIndex) - 1);
        }
        else {
            var frame = document.getElementById(divid + "_Iframe");

            //remove iframe
            if (frame)
                frame.parentElement.removeChild(frame);

            //hide popup	
            div.style.display = 'none';
        }
    }
}

//Displays popup with and shadow iframe to hide htmlcontrols.
function displayPopup(divid, centerWindow, hidecontrols) {
    var div = document.getElementById(divid);

    if (div != null) {
        //set div settings.
        div.style.zIndex = '2001';

        //display containers.
        if (div.style.display == 'none') {
            //Create iframe and add it to div's parent childcollection.
            var frame = document.createElement("iframe");
            div.parentNode.appendChild(frame);

            //set style.
            frame.id = divid + "_Iframe";
            frame.style.border = "0";
            frame.style.position = "absolute";
            frame.style.frameBorder = 0;
            //--

            div.style.position = "absolute";
            div.style.display = 'block';
            frame.style.display = 'block';

            if (centerWindow) {
                div.style.top = ((GetScrollTop() + document.documentElement.clientHeight / 2) - div.clientHeight) + 'px';
                div.style.left = ((document.body.clientWidth / 2) - (div.clientWidth / 2)) + 'px';
            }

            //set frame settings.
            frame.style.width = div.clientWidth + 'px';
            frame.style.height = div.clientHeight + 'px';
            frame.style.zIndex = '2000';
            frame.style.top = div.style.top;
            frame.style.left = div.style.left;

            if (hidecontrols) {
                hideWindowedControls();
                unHideChildrenOf(divid);
            }
        }
        else {
            var frame = document.getElementById(divid + "_Iframe");

            //remove iframe
            if (frame)
                frame.parentNode.removeChild(frame);

            //hide popup	
            div.style.display = 'none';

            if (hidecontrols)
                unHideWindowedControls();
        }
    }
}
function GetScrollTop() {
    return document.documentElement ? document.documentElement.scrollTop : document.scrollTop;
}
function GetScrollLeft() {
    return document.documentElement ? document.documentElement.scrollLeft : document.scrollLeft;
}
var gHiddenControls = new Array();
// ---------------
// Hides all windowed controls in browsers that
// can't display layers on top of them.
// ---------------
function hideWindowedControls() {
    // Hides all listboxes
    for (var i = 0; i < document.getElementsByTagName('select').length; i++) {
        if (document.getElementsByTagName('select')[i].style.visibility != 'hidden') {
            document.getElementsByTagName('select')[i].style.visibility = 'hidden';
            gHiddenControls[gHiddenControls.length] = document.getElementsByTagName('select')[i];
        }
    }
}
function unHideWindowedControls() {
    for (var i = 0; i < gHiddenControls.length; i++)
        gHiddenControls[i].style.visibility = 'visible';

    gHiddenControls.length = 0;
}

//After we have hidden all controls we want to unhide thoose who are within a popup.
function unHideChildrenOf(id) {
    for (var i = 0; i < gHiddenControls.length; i++) {
        var ctrl = gHiddenControls[i];
        var found = false;

        while (ctrl != null) {
            if (ctrl.id == id) {
                found = true;
                break;
            }
            else
                ctrl = ctrl.parentNode;
        }

        //if a control was found we display it.
        if (found) {
            gHiddenControls[i].style.visibility = 'visible';
        }
    }
}

function DisplayAll(tableid, senderid) {
    var table = document.getElementById(tableid);
    var link = document.getElementById(senderid);

    var displayStatus = 'none';

    if (link.innerText == 'Lista alla') {
        displayStatus = '';
        link.innerText = 'Dölj';
    }
    else {
        link.innerText = 'Lista alla';
    }

    for (var i = 0; i < table.rows.length; i++) {
        if (table.rows[i].className == 'extra_list')
            table.rows[i].style.display = displayStatus;
    }
}


// MightyLittleDatepicker_core.js


function changeFrame(frameid) {
    var oIframe = self.frames[frameid];

    if (self.frames[frameid])
        oIframe = self.frames[frameid];
    else if (document.frames)
        oIframe = document.frames[frameid];

    if (oIframe != null)
        oIframe.document.write('You need to upgrade your browser to support ajax');

    return true;
}

function DatePicker_Showpopup(uniqueid) {
    var iframe = document.getElementById(uniqueid + '_Iframe');
    var panel = document.getElementById(uniqueid + '_Panel');

    if (panel.style.display != 'none') {
        DatePicker_Hidedropdowns(uniqueid);
        iframe.style.display = 'none';
        panel.style.display = 'none';
        DatePicker_EnableSelect();

    }
    else {
        iframe.style.display = 'block';
        panel.style.display = 'block';
        DatePicker_DisableSelect();
        changeFrame(uniqueid + '_Iframe');

        DatePicker_RenderPeriodMonths(uniqueid, '');
    }
}

function DatePicker_AdaptIframe(uniqueid) {
    var panel = document.getElementById(uniqueid + '_Panel');
    var iframe = document.getElementById(uniqueid + '_Iframe');

    iframe.style.height = (panel.clientHeight + 2) + 'px';
    iframe.style.width = panel.clientWidth + 'px';
}

function DatePicker_AdaptMonthIframe(uniqueid) {
    var monthddn = document.getElementById(uniqueid + '_Hiddenmonth');
    var monthiframe = document.getElementById(uniqueid + '_HiddenmonthIframe');

    monthiframe.style.height = monthddn.clientHeight + 'px';
    monthiframe.style.width = monthddn.clientWidth + 'px';
}

function DatePicker_Showmonths(uniqueid) {
    if (document.getElementById(uniqueid + '_Hiddenmonth').style.display != 'block') {
        DatePicker_Hidedropdowns(uniqueid);
        document.getElementById(uniqueid + '_Hiddenmonth').style.display = 'block';
        document.getElementById(uniqueid + '_HiddenmonthIframe').style.display = 'block';
        DatePicker_AdaptMonthIframe(uniqueid);
        DatePick_BubbleEvent = false;
        document.onclick = function () { DatePicker_DocumentClick(uniqueid); };
    }
    else {
        document.getElementById(uniqueid + '_Hiddenmonth').style.display = 'none';
    }
}

function DatePicker_Hidedropdowns(uniqueid) {
    document.getElementById(uniqueid + '_HiddenmonthIframe').style.display = 'none';
    document.getElementById(uniqueid + '_Fwdyear').style.display = 'none';
    document.getElementById(uniqueid + '_FwdyearIframe').style.display = 'none';
    document.getElementById(uniqueid + '_Rewyear').style.display = 'none';
    document.getElementById(uniqueid + '_RewyearIframe').style.display = 'none';
    document.getElementById(uniqueid + '_Hiddenmonth').style.display = 'none';
}

function DatePicker_DocumentClick(uniqueid) {
    if (DatePick_BubbleEvent == true) {
        DatePicker_Hidedropdowns(uniqueid);
        document.onclick = null;
        document.onmouseup = null;
        document.onmousedown = null;
    }

    DatePick_BubbleEvent = true;
}

function DatePicker_Showfwdyears(uniqueid) {
    var fwddiv = document.getElementById(uniqueid + '_Fwdyear');
    var fwdiframe = document.getElementById(uniqueid + '_FwdyearIframe');

    if (fwddiv.style.display != 'block') {
        DatePicker_Hidedropdowns(uniqueid);
        currdate_control = document.getElementById(uniqueid + '_CurrDate');
        var curryear = new Date(currdate_control.value).getFullYear();

        var dropdowndivs = '';
        for (i = 1; i < 10; i++) {
            dropdowndivs = dropdowndivs + '<div onmouseover="javascript:DatePicker_Mouseovercolorchange(this, 1);" onmouseout="javascript:DatePicker_Mouseoutcolorchange(this);" onclick="javascript:DatePicker_Callyears(\'' + uniqueid + '\', \'_Fwdyear\', ' + (curryear + i) + ');" class=\"DatePicker_yearitem DatePicker_Text\">' + (curryear + i) + '</div>';
        }

        fwddiv.innerHTML = dropdowndivs;
        fwddiv.style.display = 'block';
        fwdiframe.style.display = 'block';
        DatePicker_AdaptYearsIframe(fwddiv, fwdiframe);

        DatePick_BubbleEvent = false;
        document.onclick = function () { DatePicker_DocumentClick(uniqueid); };
    }
    else {
        DatePicker_Hidedropdowns(uniqueid);
    }
}

function DatePicker_Showrewyears(uniqueid) {
    var rewdiv = document.getElementById(uniqueid + '_Rewyear');
    var rewiframe = document.getElementById(uniqueid + '_RewyearIframe');

    if (rewdiv.style.display != 'block') {
        DatePicker_Hidedropdowns(uniqueid);

        currdate_control = document.getElementById(uniqueid + '_CurrDate');
        var curryear = new Date(currdate_control.value).getFullYear();

        var dropdowndivs = '';
        for (i = 1; i < 10; i++) {
            dropdowndivs = dropdowndivs + '<div onmouseover="javascript:DatePicker_Mouseovercolorchange(this, 1);" onmouseout="javascript:DatePicker_Mouseoutcolorchange(this);" onclick="javascript:DatePicker_Callyears(\'' + uniqueid + '\',\'_Rewyear\' ,' + (curryear - i) + ');" class=\"DatePicker_yearitem DatePicker_Text\">' + (curryear - i) + '</div>';
        }

        rewdiv.innerHTML = dropdowndivs;
        rewdiv.style.display = 'block';
        rewiframe.style.display = 'block';
        DatePicker_AdaptYearsIframe(rewdiv, rewiframe);


        DatePick_BubbleEvent = false;
        document.onclick = function () { DatePicker_DocumentClick(uniqueid); };
    }
    else {
        DatePicker_Hidedropdowns(uniqueid);
    }
}

function DatePicker_AdaptYearsIframe(yeardiv, iframe) {
    iframe.style.height = (yeardiv.clientHeight + 2) + 'px';
    iframe.style.width = (yeardiv.clientWidth + 2) + 'px';
}

function DatePicker_Callyears(uniqueid, controlid, year) {
    var yearfield = document.getElementById(uniqueid + controlid);
    var datefield = document.getElementById(uniqueid + '_CurrDate');
    var newdate = new Date(datefield.value);
    newdate.setYear(year);
    datefield.value = (newdate.getMonth() + 1) + '/1/' + newdate.getFullYear();

    yearfield.style.display = 'none';
    DatePicker_RenderPeriodMonths(uniqueid, 'year');
}

function DatePicker_Closeyears(uniqueid) {
    var yearfield = document.getElementById(uniqueid);
    yearfield.style.display = 'none';
}

function DatePicker_Callmonth(uniqueid, month) {
    var datefield = document.getElementById(uniqueid + '_CurrDate');
    var newdate = new Date(datefield.value);
    newdate.setMonth(month);

    datefield.value = (newdate.getMonth() + 1) + '/1/' + newdate.getFullYear();

    DatePicker_RenderPeriodMonths(uniqueid, 'year');
}


function DatePicker_GetCalendarHTML(res) {
    var uniqueid = res.value.Uniqueid;

    var Calendar = new Date(res.value.FromDate);
    var year = Calendar.getFullYear(); // Returns year
    var month = Calendar.getMonth();    // Returns month (0-11)
    var today = Calendar.getDate();    // Returns day (1-31)
    var weekday = Calendar.getDay();    // Returns day (1-31)

    var DAYS_OF_WEEK = 7;    // "constant" for number of days in a week
    var DAYS_OF_MONTH = 31;    // "constant" for number of days in a month
    var cal;    // Used for printing

    var Month_of_year = new Array();
    Month_of_year = eval('DatePicker_month_of_year_' + uniqueid).split(',');
    var Day_of_week = new Array();
    Day_of_week = eval('DatePicker_day_of_week_' + uniqueid).split(',');
    var toolTip = eval('DatePicker_tooltip_' + uniqueid);


    Calendar.setDate(1);
    Calendar.setMonth(month);

    // Render table
    cal = '<table class="DatePicker_drop_down_calendar DatePicker_Text" border="0" cellspacing="0" cellpadding="0">';
    cal += '<tr class="DatePicker_datepick_daynames DatePicker_Text">';
    cal += '<td class="DatePicker_datepick_wk DatePicker_Text">Wk</td>'

    // Print weekdays
    for (index = 0; index < DAYS_OF_WEEK; index++) {
        cal += '<td class="DatePicker_datepick_dayname DatePicker_Text">' + Day_of_week[index] + '</td>\r\n';
    }



    // If first day of the month isn't monday we need to take care of rendering the weeknr here
    // else it's handled in the loop below
    if (Calendar.getIsoDay() > 0) {
        cal += '</tr>\r\n';
        cal += '<tr>\r\n';
        cal += '<td class="DatePicker_datepick_wknr DatePicker_Text">' + Calendar.getWeekNumber() + '</td>\r\n'
    }

    // Fill gaps so the first date starts on the correct day    
    for (index = 0; index < Calendar.getIsoDay(); index++) {
        cal += '<td class=\"DatePicker_regular_date DatePicker_Text\"></td>\r\n';
    }

    for (index = 0; index < DAYS_OF_MONTH; index++) {
        if (Calendar.getDate() > index) {
            week_day = Calendar.getIsoDay();

            // New firstday = new row
            if (week_day == 0) {
                cal += '</tr>\r\n';
                cal += '<tr>\r\n';
                cal += '<td class="DatePicker_datepick_wknr DatePicker_Text">' + Calendar.getWeekNumber() + '</td>\r\n'
            }


            if (week_day != DAYS_OF_WEEK) {
                var day = Calendar.getDate();
                var now = new Date();

                // Set output to swedish dates.. this should be changed to a customizable setting

                var month_str = (month + 1);
                var day_str = day;

                if (month_str.toString().length == 1)
                    month_str = "0" + month_str;

                if (day_str.toString().length == 1)
                    day_str = "0" + day_str;


                var date_str = year + "-" + month_str + "-" + day_str

                // Higlight todays date
                if (month == now.getMonth() && day == now.getDate() && year == now.getFullYear()) {
                    cal += "<td class=\"DatePicker_regular_date DatePicker_todays_date DatePicker_Text " + DatePicker_TodayClassCSS + "\"><a class=\"DatePicker_clickable_date DatePicker_Text\" onmouseover=\"javascript:DatePicker_Showhelp('" + uniqueid + "','" + Day_of_week[week_day] + "," + Month_of_year[Calendar.getMonth()] + " " + day + "');\" onmouseout=\"javascript:DatePicker_Resethelp('" + uniqueid + "', '" + toolTip + "');\" onclick=\"DatePicker_SelectPeriod('" + uniqueid + "','" + date_str + "')\">" + day + "</a></td>\r\n";
                }
                else {
                    cal += "<td class=\"DatePicker_regular_date DatePicker_Text\" onmouseover=\"javascript:DatePicker_Mouseovercolorchange(this, 0); javascript:DatePicker_Showhelp('" + uniqueid + "','" + Day_of_week[week_day] + "," + Month_of_year[Calendar.getMonth()] + " " + day + "');\" onmouseout=\"javascript:DatePicker_Mouseoutcolorchange(this); javascript:DatePicker_Resethelp('" + uniqueid + "','" + toolTip + "');\" onclick=\"DatePicker_SelectPeriod('" + uniqueid + "','" + date_str + "')\">" + day + "</td>\r\n";
                }
            }
        }

        Calendar.setDate(Calendar.getDate() + 1);
    }

    if (week_day < DAYS_OF_WEEK) {
        for (i = 1; i < (DAYS_OF_WEEK - week_day); i++) {
            cal += '<td class=\"DatePicker_regular_date DatePicker_Text\"></td>\r\n';
        }

        cal += '</tr>\r\n';
    }
    cal += '</table>\r\n';

    return cal;
}


function disableselect(e) {
    var omitformtags = ["input", "textarea", "select"];
    omitformtags = omitformtags.join("|");

    if (e != null) {
        if (omitformtags.indexOf(e.target.tagName.toLowerCase()) == -1)
            return false
    }
}

function DatePicker_DisableSelect() {
    document.onmousedown = disableselect
    document.onmouseup = function () { false; };
    document.body.ondrag = function () { return false; };
    document.body.onselectstart = function () { return false; };
}

function DatePicker_EnableSelect() {
    document.body.ondrag = function () { return true; };
    document.body.onselectstart = function () { return true; };
    document.onmousedown = function () { return true; };
    document.onmouseup = function () { return true; };
}


function DatePicker_AlterContent(elementid, content) {
    //if IE 4+
    if (document.all) document.getElementById(elementid).innerHTML = content;

    //else if NS 6 (supports new DOM)
    else if (document.getElementById) {
        rng = document.createRange();
        el = document.getElementById(elementid);
        rng.setStartBefore(el);
        htmlFrag = rng.createContextualFragment(content);

        while (el.hasChildNodes()) el.removeChild(el.lastChild);
        el.appendChild(htmlFrag);
    }
}

function DatePicker_SelectPeriod(uniqueid, txtValue) {
    document.getElementById(uniqueid + '_DateBox').value = txtValue;
    document.getElementById(uniqueid + '_Panel').style.display = 'none';
    document.getElementById(uniqueid + '_Iframe').style.display = 'none';
}

function callback_RenderPeriodMonths(res) {
    var uniqueid = res.value.Uniqueid;
    var Month_of_year = new Array();
    Month_of_year = eval('DatePicker_month_of_year_' + uniqueid).split(',');

    currdate_control = document.getElementById(uniqueid + '_CurrDate');

    currdate_control.value = res.value.FromDate;

    var tmpDate = new Date(currdate_control.value);

    // set current month label
    document.getElementById(uniqueid + '_CurrMonth').innerHTML = Month_of_year[(tmpDate.getMonth())];

    // set current year label
    var currdate = new Date(res.value.FromDate);
    document.getElementById(uniqueid + '_CurrYear').innerHTML = currdate.getFullYear();

    DatePicker_AlterContent(uniqueid + '_Periods', DatePicker_GetCalendarHTML(res));
    DatePicker_AdaptIframe(uniqueid);
}


function DatePicker_RenderPeriodMonths(uniqueid, direction) {

    DatePicker_AlterContent(uniqueid + '_Periods', "<div style='text-align:center'>Loading</div><div class='DatePicker_loading_icon'>&nbsp;</div>");

    var test = uniqueid + '_CurrDate';
    currdate_control = document.getElementById(uniqueid + '_CurrDate');

    if (direction == 'next') {
        MightyLittle.DatePickerAjax.GetNextMonthPeriods(currdate_control.value, uniqueid, callback_RenderPeriodMonths);
    }
    else if (direction == 'prev') {
        MightyLittle.DatePickerAjax.GetPrevMonthPeriods(currdate_control.value, uniqueid, callback_RenderPeriodMonths);
    }
    else if (direction == 'month') {
        MightyLittle.DatePickerAjax.GetThisMonthPeriod(currdate_control.value, uniqueid, callback_RenderPeriodMonths);
    }
    else if (direction == 'year') {
        MightyLittle.DatePickerAjax.GetThisMonthPeriod(currdate_control.value, uniqueid, callback_RenderPeriodMonths);
    }
    else if (direction == 'prevyear') {
        var datevar = new Date(currdate_control.value);
        datevar.setYear((datevar.getFullYear() - 1));
        MightyLittle.DatePickerAjax.GetThisMonthPeriod((datevar.getMonth() + 1) + '/1/' + datevar.getFullYear(), uniqueid, callback_RenderPeriodMonths);
    }
    else if (direction == 'nextyear') {
        var datevar = new Date(currdate_control.value);
        datevar.setYear((datevar.getFullYear() + 1));
        MightyLittle.DatePickerAjax.GetThisMonthPeriod((datevar.getMonth() + 1) + '/1/' + datevar.getFullYear(), uniqueid, callback_RenderPeriodMonths);
    }
    else {
        MightyLittle.DatePickerAjax.GetThisMonthPeriod(currdate_control.value, uniqueid, callback_RenderPeriodMonths);
    }
}


/* Returns the number of the week in year, as defined in ISO 8601. */
Date.prototype.getWeekNumber = function () {
    var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
    var DoW = d.getDay();
    d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
    var ms = d.valueOf(); // GMT
    d.setMonth(0);
    d.setDate(4); // Thu in Week 1
    return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
};

Date.prototype.getIsoDay = function () {
    if (this.getDay() == 0)
        return 6;
    else
        return (this.getDay() - 1)
};


// MightyLittleDatepicker_functions.js


function DatePicker_Mouseovercolorchange(control, colorid) {
    control.style.background = DatePicker_Hovercolor[colorid];
}

function DatePicker_Mouseoutcolorchange(control) {
    control.style.background = 'White';
}

function DatePicker_Showhelp(uniqueid, helptext) {
    var helpdiv = document.getElementById(uniqueid + '_Helpdiv');
    helpdiv.innerHTML = helptext;
}

function DatePicker_Resethelp(uniqueid, text) {
    var helpdiv = document.getElementById(uniqueid + '_Helpdiv');
    helpdiv.innerHTML = text;
}


// MightyLittleDatepicker_settings.js

/*
0 = Calender hover color
1 = Month dropdown hover color
*/
var DatePicker_Hovercolor = new Array("#d8e4f8", "#7a96df");
var DatePicker_TodayClassCSS = "holiday_date";
var DatePicker_sunday_is_fist_weekday = false;
var DatePick_BubbleEvent = true;

