﻿
// ----------- Browser detection ----------------

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

// ---------- Website location ----------

function GetRootPath()
{
    // URL: http://whatever.whatever.whatever/whatever/whatever.aspx
    // Development URL: http://localhost:1111/website/whatever/whatever.aspx
    var url = location.href.split('/');
    if (url.length > 2 && url[3].substring(7,0) == 'website')
        return "/website";
    
    return "";
}

// ---------- Debug window ------------

var jsDebug = false;
var debugWindowHandle = null;

if (jsDebug)
{
    if (debugWindowHandle == null)
    {
        debugWindowHandle = window.open('','myconsole','width=350,height=250,menubar=0,toolbar=1,status=0,scrollbars=1,resizable=1');
    }
}

function WriteToConsole(text)
{
    if (debugWindowHandle != null)
         debugWindowHandle.document.writeln(text + "<br>");
}

//function maxLength(field,maxChars)
// {
//       if(field.value.length >= maxChars) {
//          event.returnValue=false;
//          return false;
//       }
// }  

// function maxLengthPaste(field,maxChars)
// {
//       event.returnValue=false;
//       if((field.value.length +  window.clipboardData.getData("Text").length) > maxChars) {
//         return false;
//       }
//       event.returnValue=true;
// }


function SetActiveTab(tabControl, tabNumber)
{
    var ctrl = $find(tabControl);
    ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);
} 


function isDate(sDate)
{
    // Expects dd-mm-yyyy
    var re = /^\d{1,2}\-\d{1,2}\-\d{4}$/

    if (re.test(sDate))
    {
        var dArr = sDate.split("-");
        // Creates Date using mm/dd/yyyy
        var d = new Date(dArr[1] + '/' + dArr[0] + '/' + dArr[2]);
        return d.getMonth() + 1 == dArr[1] && d.getDate() == dArr[0] && d.getFullYear() == dArr[2];
    }
    else
        return false;
}

    // Functions to get browser window sizes


    var TopBottomHeight = 350;
    var BigPopupSize = 220;
    var TabOnWholeHeight = 250;
    var SpaceAndHeaderAndFooterSize = 220;

    function getHeight()
    {
        var theHeight;           
        if (window.innerHeight)
            theHeight=window.innerHeight;
        else if (document.documentElement && document.documentElement.clientHeight)
            theHeight=document.documentElement.clientHeight;
        else if (document.body)
            theHeight=document.body.clientHeight;

        return theHeight;    
    }
    
    function getWidth()
    {
        var theWidth;
        if (window.innerWidth)
            theWidth=window.innerWidth;
        else if (document.documentElement && document.documentElement.clientWidth)
            theWidth=document.documentElement.clientWidth;
        else if (document.body)
            theWidth=document.body.clientWidth;

        return theWidth;
    }

    // This function is used by RequiredEmail, and RequiredField and ... Use those instead of calling this one!
    function RequiredFieldOrEmailOrOther(controlType, element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg)
    {
        var PlaceHolder_OBSOLETE = "ctl00_MainContentPlaceHolder_";
        var value;
        var validateElement;
        var image;
        var error = false;
        
        if (controlType != "forceErrorArea")
        {
            validateElement = document.getElementById(element);
            if (validateElement == null)
                validateElement = document.getElementById(PlaceHolder + element);

            if (validateElement == null)
                return false;
        }
        
        if (!document.getElementById(fadeElement))
        {
            if (!document.getElementById(PlaceHolder + fadeElement))
                return false;
                
            fadeElement = PlaceHolder + fadeElement;
        }
        
        if (showIcon)
        {
            if (errorImg != null)
                image = document.getElementById(errorImg);
            else
            {
                image = document.getElementById(element + "ErrorImg");
                if (image == null)
                    image = document.getElementById(PlaceHolder + element + "ErrorImg");

                if (image == null)
                    return false;
            }
        }

        if (controlType == "email")
        {
            value = validateElement.value;
            if (value == null || value.trim() == '' || value.length == 0 || !isEmailAddress(value))
                error = true;
        }
        else if (controlType == "field")
        {
            value = validateElement.value;
            if (value == null || value.trim() == '' || value.length == 0)
                error = true;
        }
        
        else if (controlType == "date")
        {
            value = validateElement.value;
            if (value == null || value.trim() == '' || value.length == 0 || !isDate(value))
                error = true;
        }

        else if (controlType == "dropdown")
        {
            value = validateElement.selectedIndex;
            if (value == 0)
                error = true;
        }
        
        else if (controlType == "forceErrorField" || controlType == "forceErrorArea")
            error = true;
        
        if (error) {
        
            // fading requires, that the site calling this function includes fade.js!
            if (showIcon)
                image.style.display = "inline";

            if (DoFading == true)
                fade(fadeElement, type, origR, origG, origB, errR, errG, errB, 10, 25, 700, true);

            return false;
        }
        
        if (showIcon)
            image.style.display = "none";
            
        return true;
    }
    
    function RequiredEmail(element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg) {
        return RequiredFieldOrEmailOrOther("email", element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg);
    }

    function RequiredField(element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg)
    {
        return RequiredFieldOrEmailOrOther("field", element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg);
    }

    function RequiredDropDown(element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg)
    {
        return RequiredFieldOrEmailOrOther("dropdown", element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg);
    }
    
    function RequiredDate(element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg)
    {
        return RequiredFieldOrEmailOrOther("date", element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg);
    }
    
    function ErrorField(element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg)
    {
        return RequiredFieldOrEmailOrOther("forceErrorField", element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB, errorImg);
    }
    
    function ErrorArea(element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB)
    {
        return RequiredFieldOrEmailOrOther("forceErrorArea", element, showIcon, DoFading, fadeElement, type, origR, origG, origB, errR, errG, errB);
    }

        //document.onkeydown = KeyDownHandler;
        //document.onkeyup = KeyUpHandler;
       
        var CTRL = false;
        var SHIFT = false;
        var ALT = false;
        var CHAR_CODE = -1;
        var PlaceHolder = "ctl00_MainContentPlaceHolder_";

        function KeyDownHandler(e)
        {
            var x = '';

            if (document.all)
            {
                var evnt = window.event;
                x = evnt.keyCode;
            }
            else
            {
                x = e.keyCode;
            }
            DetectKeys(x, true);
            HandleShortcuts();
        }
       
        function KeyUpHandler(e)
        {
            var x = '';
            if (document.all)
            {
                var evnt = window.event;
                x = evnt.keyCode;
            }
            else
            {
                x = e.keyCode;
            }
            DetectKeys(x, false);
        }
     
        function DetectKeys(KeyCode, IsKeyDown)
        {           
            if (KeyCode == '16')
            {
               SHIFT = IsKeyDown;
            }
            else if (KeyCode == '17')
            {
                CTRL = IsKeyDown;
            }
            else if (KeyCode == '18')
            {
                ALT = IsKeyDown;
            }
            else
            {
                if(IsKeyDown)
                    CHAR_CODE = KeyCode;
                else
                    CHAR_CODE = -1;
            }
        }

        function ShowModal(whatModalWindowBhvr, setFocusOn)
        {
            var popup = parent.$find(whatModalWindowBhvr);
            
            if (popup != null)
            {
                popup.show();

                if ( setFocusOn != null )
                {
                    // maybe it's with PlaceHolder - maybe without?
                    if ( document.getElementById(PlaceHolder + setFocusOn) != null )
                        document.getElementById(PlaceHolder + setFocusOn).focus();
                    else if ( document.getElementById(setFocusOn) != null )
                        document.getElementById(setFocusOn).focus();
                }

                ClearKeys();
            }
        }

        function HideModal(whatModalWindowBhvr, setFocusOn, ClearControl)
        {
            var popup = parent.$find(whatModalWindowBhvr);
            
            if (popup != null)
            {
                // move focus, so that we can empty the value of the textbox
                if ( setFocusOn != null && ClearControl != null)
                {
                    document.getElementById(setFocusOn).focus();
                    document.getElementById(PlaceHolder + ClearControl).value = '';
                }

                popup.hide();

                ClearKeys();                
            }
        }
        
        function ClearKeys()
        {
            CTRL = ALT = SHIFT = false;
            CHAR_CODE = -1;
        }
        

        function IsTextEmpty(value)
        {
            if (value == null || value.trim() == '' || value.length == 0)
                return true;
        }
        
        function isEmailAddress(value)
        {
            // Complex email validation
            //var filter = ' - clever regex here - ';
            //var re = new RegExp(filter);

            //if (value.toLowerCase().match(re))
            //    return true;
            //else
            //    return false;

            // Simpel email validation
            value = value.toLowerCase();

            if (value.indexOf('@') == value.lastIndexOf('@')
                && value.indexOf('@') != -1
                && value.indexOf('æ') == -1
                && value.indexOf('ø') == -1
                && value.indexOf('å') == -1
                && value.indexOf('å') == -1)
                return true;

            else
                return false;
        }
        
        function PlaceScrollbar(table, rowIndex, dummyTextBox, panel, div)
        {
            var rowElement = document.getElementById(table + 'ClickRow' + rowIndex);

            var currentY = getY(rowElement, div, panel) + (rowElement.clientHeight / 2);
            
            var el = document.getElementById(PlaceHolder + panel);
            var h = el.scrollHeight; // height of div scroll
            var y = el.scrollTop; // vertical scroll offset from top (of scrollHeight)
            var c = el.clientHeight; // scroll bar height
            
            var newPosition = currentY - (c/2);
            
            if (newPosition < 0)
                newPosition = 0;

            document.getElementById(dummyTextBox).focus();
            el.scrollTop = newPosition;
            //alert( "newPosition: " + newPosition + ", currentY: " + currentY + ", scrollHeight: " + h + ", vertical scroll offset from top: " + y + ", clientheight: " + c);
        }

        function getY( oElement, div, panel )
        {
            // VERSION 2
            var element = document.getElementById(div);
            var positionObject = Position.get(oElement, element);
            return positionObject.top;

            // VERSION 1
            var iReturnValue = 0;
            var stopElement = document.getElementById(PlaceHolder + panel);
            while(oElement != null && oElement != stopElement)
            {
                iReturnValue += oElement.offsetTop;
                oElement = oElement.offsetParent;
            }

            return iReturnValue;
        
            // VERSION 3
            var iReturnValue = 0;
            while( oElement != null && oElement.id != PlaceHolder + 'CategoriesPanel' )
            {
                iReturnValue += oElement.offsetTop;
                alert( "iReturnValue er nu: " + iReturnValue + " (" + oElement.id + "). Next element er: " + (oElement.nodeParent).id);
                oElement = oElement.offsetParent;
            }
        
            return iReturnValue;
        }

        function moveZIndex_OBSOLETE(popup, newZIndex)
        {
            // popup must be the first part of the modulpopupextender window (excl. "popup" or "bhvr" etc)

            var currentZIndex;
            
            var prefix = '';
            var mprefix = '';
            
            // search for element
            if (document.getElementById(PlaceHolder + popup + 'Popup') != null)
                prefix = PlaceHolder;
            else if (document.getElementById('ctl00_' + popup + 'Popup') != null)
                prefix = 'ctl00_';
                
            if (prefix == '')
                return false;
            
            if (document.getElementById(popup + 'Bhvr_backgroundElement') != null)
                mprefix = '-';
            else if (document.getElementById('Modal' + popup + 'Bhvr_backgroundElement') != null)
                mprefix = 'Modal';
                
            if (mprefix == '')
                return false;
                
            if (mprefix == '-')
                mprefix = '';

            //currentZIndex = document.getElementById(prefix + popup + 'Popup').style.zIndex;
            document.getElementById(prefix + popup + 'Popup').style.zIndex = newZIndex;

            //currentZIndex = document.getElementById(popup + 'Bhvr_backgroundElement').style.zIndex;
            document.getElementById(mprefix + popup + 'Bhvr_backgroundElement').style.zIndex = newZIndex-1;
        }
        
        function SplitCSV_OBSOLETE(str)
        {
            // 360,'Her er,, en "forfærdlig" udgave'', af <br><br> _''et''_spørgsmål'
            var list = new Array();
            var work = '';
            var separator = ',';
            var textSeparator = "'";
            
            for (var i=0; i<str.length; i++)
            {
                var c = str.charAt(i);
                if (c == textSeparator)
                {
                    var p2;
                    while (true)
                    {
                        p2 = str.indexOf(textSeparator, i+1);
                        work += str.substring(i + 1, p2);
                        i = p2;

                        // If this is a double quote, keep going!
				        if (((p2 + 1) < str.length) && (str.charAt(p2+1) == textSeparator))
				        {
					        work += textSeparator;
					        i++;

				        // otherwise, this is a single quote, we're done
				        }
				        else
				        {
					        break;
				        }
    		    	}
		        }
		        else if (c == separator)
		        {
		            list[list.length] = work.toString();
		            work = '';
		        }
		        else
		        {
			        work += c;
		        }
            }

            list[list.length] = work.toString();

	        return list;
        }


        String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }


    /*function EndRequestHandler(sender, args)
    {
        //document.getElementById('ctl00_PleaseWaitImage').style.display = 'none';
        if (args.get_error() == undefined)
        {
            //CTRL = ALT = SHIFT = null;
            CHAR_CODE = -1;
            HandleMessages();
            UpdateRow();
        }
       else
           alert("There was an error" + args.get_error().message);
    }*/

//    window.onresize = function()
//    {
//        if (window["doResizeTabs"] != null)
//            doResizeTabs();

//        placeFooterText();
//    }

    /*window.onload = function()
    {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

        if (window["HandleMessages"] != null)
            HandleMessages();

        if (window["UpdateRow"] != null)
            UpdateRow();

        if (window["jQueryReady"] != null)
            jQueryReady();

        placeFooterText();
    }*/

    function placeFooterText()
    {
        var element = document.getElementById('FooterMiddleCell');
        
        if (element != null)
            element.style.width = (getWidth() - 50 - 120 - 120) + "px";
    }

    function KeyDownHandler(e)
    {
        var x = '';

        if (document.all)
        {
            var evnt = window.event;
            x = evnt.keyCode;
        }
        else
        {
            x = e.keyCode;
        }
        DetectKeys(x, true);
        
        if (window["HandleShortscuts"] != null)
            HandleShortcuts();
    }
   
    function KeyUpHandler(e)
    {
        var x = '';
        if (document.all)
        {
            var evnt = window.event;
            x = evnt.keyCode;
        }
        else
        {
            x = e.keyCode;
        }
        DetectKeys(x, false);
    }
 
    function DetectKeys(KeyCode, IsKeyDown)
    {           
        if (KeyCode == '16')
        {
           SHIFT = IsKeyDown;
        }
        else if (KeyCode == '17')
        {
            CTRL = IsKeyDown;
        }
        else if (KeyCode == '18')
        {
            ALT = IsKeyDown;
        }
        else
        {
            if(IsKeyDown)
                CHAR_CODE = KeyCode;
            else
                CHAR_CODE = -1;
        }
    }

function ShowYesNoBox_OBSOLETE(header, text, icon, yesaction, noaction)
{
    document.getElementById('YesNoBoxYESAction').value = '';
    document.getElementById('YesNoBoxNOAction').value = '';

    document.getElementById('YesNoHeaderSpan').innerHTML = header;
    document.getElementById('YesNoMessage').innerHTML = text;

    if (icon == "INFORMATION")
        document.getElementById('YesNoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/info.jpg\">";
    else if (icon == "ERROR")
        document.getElementById('YesNoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/error.jpg\">";
    else if (icon == "THANKYOU")
        document.getElementById('YesNoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/thankyou.jpg\">";
    else if (icon == "QUESTION")
        document.getElementById('YesNoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/questionmark.jpg\">";
    else
        document.getElementById('YesNoImage').innerHTML = icon;

    document.getElementById('YesNoBoxYESAction').value = yesaction;
    document.getElementById('YesNoBoxNOAction').value = noaction;

    ShowModal('ModalYesNoBhvr');
}

function YesChosen_OBSOLETE()
{
    var functionToCall = document.getElementById('YesNoBoxYESAction').value;
    if (functionToCall != '')
        window[functionToCall]();
}

function NoChosen_OBSOLETE()
{
    var functionToCall = document.getElementById('YesNoBoxNOAction').value;
    if (functionToCall != '')
        window[functionToCall]();
}


function ShowOKInfoBox_OBSOLETE(header, text, icon, action)
{
    var focusOnButton;
    
    document.getElementById('InfoHeaderSpan').innerHTML = header;
    document.getElementById('InfoMessage').innerHTML = text;

    if (icon == "INFORMATION")
        document.getElementById('InfoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/info.jpg\">";
    else if (icon == "ERROR")
        document.getElementById('InfoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/error.jpg\">";
    else if (icon == "THANKYOU")
        document.getElementById('InfoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/thankyou.jpg\">";
    else if (icon == "QUESTION")
        document.getElementById('InfoImage').innerHTML = "<img src=\"" + GetRootPath() + "/images/questionmark.jpg\">";
    else
        document.getElementById('InfoImage').innerHTML = icon;

    if (action == undefined || action == null)
    {
        document.getElementById('DefaultInfoPopupOKButton').style.display = "inline";
        document.getElementById('CustomInfoPopupOKButton').style.display = "none";
        focusOnButton = 'DefaultInfoPopupOKButton';
    }
    else
    {
        document.getElementById('DefaultInfoPopupOKButton').style.display = "none";
        document.getElementById('CustomInfoPopupOKButton').style.display = "inline";
        document.getElementById('InformationBoxAction').value = action;
        focusOnButton = 'CustomInfoPopupOKButton';
    }

    ShowModal('ModalInfoBhvr');
    document.getElementById(focusOnButton).focus();
}

function ClosingInformationBox_OBSOLETE()
{
    var functionToCall = document.getElementById('InformationBoxAction').value;
    window[functionToCall]();
}

function isDefined(variable)
{
    return (typeof(window[variable]) == "undefined") ? false : true;
    //return eval('(typeof('+variable+') != 'undefined');');
}

//        function ShowBeregningsgrundlag()
//        {
//            showPleaseWait();
//            document.getElementById('BigInformationPopupHeader').innerHTML = "Beregningsgrundlag for point";
//            BMTWebServices.ManualWebServices.GetBeregningsgrundlag(SucceededCallback_ShowTermsAndConditions);
//        }
//        
//        function SucceededCallback_ShowTermsAndConditions(result)
//        {
//            hidePleaseWait();
//            document.getElementById('TermsAndConditionsDiv').innerHTML = result;
//            var height = (getHeight() - BigPopupSize);
//            document.getElementById('TermsAndConditionsAllDiv').style.height = height + "px";
//            document.getElementById('TermsAndConditionsDiv').style.height = height - 80 + "px";
//            document.getElementById('ctl00_TermsAndConditionsPopup').style.width = (getWidth() * 0.7) + "px";
//            moveZIndex('TermsAndConditions', 5000);

//            ShowModal('ModalTermsAndConditionsBhvr');
//        }

//        function ShowTermsAndConditions()
//        {
//            showPleaseWait();
//            document.getElementById('BigInformationPopupHeader').innerHTML = "Vilkår";
//            BMTWebServices.ManualWebServices.getTermsAndConditions(SucceededCallback_ShowTermsAndConditions);
//        }

//        function SucceededCallback_ShowTermsAndConditions(result)
//        {
//            hidePleaseWait();
//            document.getElementById('TermsAndConditionsDiv').innerHTML = result;
//            var height = (getHeight() - BigPopupSize);
//            document.getElementById('TermsAndConditionsAllDiv').style.height = height + "px";
//            document.getElementById('TermsAndConditionsDiv').style.height = height - 80 + "px";
//            document.getElementById('ctl00_TermsAndConditionsPopup').style.width = (getWidth() * 0.7) + "px";
//            moveZIndex('TermsAndConditions', 5000);

//            ShowModal('ModalTermsAndConditionsBhvr');
//        }


        // MANUAL FUNCTIONS --------

//        function ShowIndexWindow()
//        {
//            var height = (getHeight() - BigPopupSize);
//            document.getElementById('ctl00_ManualPopup').style.width = (getWidth() * 0.8) + "px";

//            var innerWidth = (getWidth() * 0.8) - 10;
//            var innerHeight = height - 70;
//            document.getElementById('ManualIndexDiv').style.height = innerHeight + "px";
//            document.getElementById('ManualIndexDiv').style.width = innerWidth + "px";
//            
//            var popup = parent.$find('ModalManualBhvr');
//            popup.show();

//            moveZIndex('Manual', 2000);
//        }
//        
//        function ShowManualIndex(manual)
//        {
//            if (document.getElementById('ctl00_ManualPopup').style.display == 'none')
//                ShowIndexWindow();

//            if (document.getElementById('ctl00_ManualBodyPopup').style.display != 'none')
//                OkManualBodyButtonClicked();
//                
//            document.getElementById('HiddenCurrentManualIndex').value = manual;

//            showPleaseWait();
//            BMTWebServices.ManualWebServices.GetManualIndex(manual, SucceededCallback_GetManualIndex);
//        }

//        function SucceededCallback_GetManualIndex(result)
//        {
//            hidePleaseWait();

//            if (result == "null")
//            {
//                DefaultErrorFromDB();
//                return;
//            }

//            document.getElementById('ManualIndexDiv').innerHTML = result;
//        }

//        function ShowManualBodyWindow()
//        {
//            var height = (getHeight() - BigPopupSize) - 50;
//            document.getElementById('ctl00_ManualBodyPopup').style.width = (getWidth() * 0.7) + "px";

//            var innerWidth = (getWidth() * 0.7) - 20;
//            var innerHeight = height - 70;
//            document.getElementById('ManualBodyDiv').style.height = innerHeight + "px";
//            document.getElementById('ManualBodyDiv').style.width = innerWidth + "px";
//            
//            var popup = parent.$find('ModalManualBodyBhvr');
//            popup.show();

//            moveZIndex('ManualBody', 3000);
//        }

//        function GetManualParagraph(paragraph)
//        {
//            if (document.getElementById('ctl00_ManualBodyPopup').style.display == 'none')
//                ShowManualBodyWindow();

//            showPleaseWait();
//            BMTWebServices.ManualWebServices.GetManualParagraph(paragraph, SucceededCallback_GetManualParagraph);
//        }

//        function SucceededCallback_GetManualParagraph(result)
//        {
//            hidePleaseWait();

//            if (result == "null")
//            {
//                DefaultErrorFromDB();
//                return;
//            }

//            document.getElementById('ManualBodyDiv').innerHTML = result;
//        }

//        function OkManualButtonClicked()
//        {
//            document.getElementById('ManualIndexDiv').innerHTML = '';
//            var popup = parent.$find('ModalManualBhvr');
//            popup.hide();
//        }

//        function OkManualBodyButtonClicked()
//        {
//            document.getElementById('ManualBodyDiv').innerHTML = '';
//            var popup = parent.$find('ModalManualBodyBhvr');
//            popup.hide();
//        }
//        
//        function PrintManual()
//        {
//            var currentManual = document.getElementById('HiddenCurrentManualIndex').value;
//            
//            if (currentManual == 'questionnaire')
//                window.open( GetRootPath() + '/vejledning_til_fritidshjem_boernehavens_4_til_6.pdf','','');
//            else if (currentManual == 'benchmarker')
//                window.open( GetRootPath() + '/vejledning_til_benchmarking.pdf','','');
//            else if (currentManual == 'dagplejehjem')
//                window.open( GetRootPath() + '/vejledning_til_dagplejen.pdf','','');
//            else if (currentManual == 'mindstedt')
//                window.open( GetRootPath() + '/vejledning_til_vuggestue_og_boernehave.pdf','','');
//        }

        // --------------------
        
        
// -------- Support -------------------


//function SendSupport()
//{
//    document.getElementById('SupportNameTextBoxErrorImg').style.display = "none";
//    document.getElementById('SupportEmailTextBoxErrorImg').style.display = "none";

//    var errors = 0;
//    if (!RequiredField('SupportNameTextBox', true, true, 'SupportNameBorder', 'border', 255, 255, 255, 255, 0, 0))
//        errors++;
//        
//    if (!RequiredEmail('SupportEmailTextBox', true, true, 'SupportEmailBorder', 'border', 255, 255, 255, 255, 0, 0))
//        errors++;
//        
//    if (errors == 0)
//    {
//        var name = document.getElementById('SupportNameTextBox').value;
//        var email = document.getElementById('SupportEmailTextBox').value;
//        var institution = document.getElementById('SupportInstitutionTextBox').value;
//        var text = document.getElementById('SupportTextArea').value;
//        
//        showPleaseWait();
//        BMTWebServices.CommonWebServices.SendSupport(name, email, institution, text, SucceededCallback_SendSupport);
//    }
//}

//function SucceededCallback_SendSupport(result)
//{
//    hidePleaseWait();
//    
//    if (result == "null")
//    {
//        var header = "Fejl ved supportafsending";
//        var text = "Der opstod desværre en fejl, da din henvendelse skulle sendes til os.<br><br>";
//        text += "Du er velkommen til at kontakte os direkte på mail: <a href=\"mailto:bm-termometeret@dcum.dk\">bm-termometeret@dcum.dk</a>";
//        
//        ShowOKInfoBox(header, text, "ERROR");
//        
//        return;
//    }
//    
//    var header = "Tak for din henvendelse";
//    var text = "Din henvendelse er nu sendt til DCUM. Vi vil besvare din henvendelse så hurtigt som muligt.";
//    ShowOKInfoBox(header, text, "INFORMATION");

//    HideModal('ModalSupportBhvr');
//}


// -------- Feedback -------------------

//function ShowFeedback()
//{
//    document.getElementById('FeedbackNameTextBox').value = '';
//    document.getElementById('FeedbackEmailTextBox').value = '';
//    document.getElementById('FeedbackInstitutionTextBox').value = '';
//    document.getElementById('FeedbackTextArea').value = '';
//    document.getElementById('FeedbackNameTextBoxErrorImg').style.display = "none";
//    document.getElementById('FeedbackEmailTextBoxErrorImg').style.display = "none";
//    
//    moveZIndex('Feedback', 7000);
//    ShowModal('ModalFeedbackBhvr');
//}

//function SendFeedback()
//{
//    document.getElementById('FeedbackNameTextBoxErrorImg').style.display = "none";
//    document.getElementById('FeedbackEmailTextBoxErrorImg').style.display = "none";

//    var errors = 0;
//    if (!RequiredField('FeedbackNameTextBox', true, true, 'FeedbackNameBorder', 'border', 255, 255, 255, 255, 0, 0))
//        errors++;
//        
//    if (!RequiredEmail('FeedbackEmailTextBox', true, true, 'FeedbackEmailBorder', 'border', 255, 255, 255, 255, 0, 0))
//        errors++;
//        
//    if (errors == 0)
//    {
//        var name = document.getElementById('FeedbackNameTextBox').value;
//        var email = document.getElementById('FeedbackEmailTextBox').value;
//        var institution = document.getElementById('FeedbackInstitutionTextBox').value;
//        var text = document.getElementById('FeedbackTextArea').value;
//        
//        showPleaseWait();
//        BMTWebServices.CommonWebServices.SendFeedback(name, email, institution, text, SucceededCallback_SendFeedback);
//    }
//}

//function SucceededCallback_SendFeedback(result)
//{
//    hidePleaseWait();
//    
//    if (result == "null")
//    {
//        var header = "Fejl ved afsending af feedback";
//        var text = "Der opstod desværre en fejl, da din feedback skulle sendes til os.<br><br>";
//        text += "Du er velkommen til at kontakte os direkte på mail: <a href=\"mailto:bm-termometeret@dcum.dk\">bm-termometeret@dcum.dk</a>";
//        
//        ShowOKInfoBox(header, text, "ERROR");
//        
//        return;
//    }
//    
//    var header = "Tak for din feedback";
//    var text = "Din feedback er nu sendt til DCUM. Du vil ikke få svar fra os på din feedback, med mindre vi har brug for yderligere oplysninger fra dig.";
//    ShowOKInfoBox(header, text, "INFORMATION");

//    HideModal('ModalFeedbackBhvr');
//}


// -------------------------------------

