﻿// JavaScript-Datei

        // trim()-Methode zum String-Objekt hinzufügen
        String.prototype.trim = function() {
	        return this.replace(/^\s+|\s+$/g,"");
	    }
        

        /**********************************/
        /* Erweiterungen des Date-Objekts */
        /**********************************/

        // addDays
	    Date.prototype.addDays = function(days) {

	        var newDate = new Date();

	        newDate.setTime(this.getTime());
	        newDate.setDate(newDate.getDate() + days);

	        return newDate;
	    }

	    // addMonths
	    Date.prototype.addMonths = function(months) {

	        var newDate = new Date();

	        newDate.setTime(this.getTime());
	        newDate.setMonth(newDate.getMonth() + months);

	        return newDate;
	    }
	    
	    // addYears
	    Date.prototype.addYears = function(years) {

	        var newDate = new Date();

	        newDate.setTime(this.getTime());
	        newDate.setFullYear(newDate.getFullYear() + years);

	        return newDate;
	    }

	    // toShortDateString
	    // Datum im Format dd.MM.yyyy ausgeben (Beispiel: 01.05.2010)
	    Date.prototype.toShortDateString = function() {
	    
	        var day = this.getDate();
	        day = ((day < 10) ? "0" : "") + day;

	        var month = (this.getMonth() + 1);
	        month = ((month < 10) ? "0" : "") + month;

	        var year = this.getFullYear();

	        var date = day + '.' + month + '.' + year;

	        return date;
	    }	    
	    /*************************************************************************************/
        
        function getDateFromGermanDateString(s) {
            var a = s.split('.');
            a[1] = a[1].replace(/^[0]+/g, "");
            return new Date(a.reverse().join("/"));
        }

        /* Validators */
        function ValidatorEnableEKS(validator, enable, validateNow)
        {
            /*
             Diese Vorgehensweise verhindert gegenüber ValidatorEnable(), dass die Prüfung der Felder
             nicht sofort ausgeführt wird. D.h. es wird nicht gleich eine Meldung ausgegeben, falls ein
            */

            validator.enabled = enable;
            if(validateNow == true)
            {
                ValidatorValidate(validator);
            }  
            ValidatorUpdateDisplay(validator);
        }




        // Funktion: hideElement
        // Versteckt das übergebene Element
        // Parameter el: Das Element, das versteckt werden soll
        //           checkPageIsValid: Prüft vorab ob alle Validatoren gültig sind
        function hideElement(el, checkPageIsValid)
        {
            if(checkPageIsValid == false)
            {
                el.style.display = 'none';
            }
            else
            {
                if (typeof(Page_ClientValidate) == 'function')
                {
                    Page_ClientValidate();
                    
                    if(Page_IsValid == true)
                    {
                        el.style.display = 'none';
                    }
                }
            }
        }
        
        // Zeigt das versteckte Element wieder an
        function showElement(el)
        {
            el.style.display = 'block';
        }

        // Funktion: disableElement
        // Disabled das übergebene Element
        // Parameter el: Das Element, das disabled werden soll
        //           checkPageIsValid: Prüft vorab ob alle Validatoren gültig sind
        function disableElement(el, checkPageIsValid)
        {
            if(checkPageIsValid == false)
            {
                el.disabled = true;
            }
            else
            {
                if (typeof(Page_ClientValidate) == 'function')
                {
                    Page_ClientValidate();
                    
                    if(Page_IsValid == true)
                    {
                        el.disabled = true;
                    }
                }
            }
        }
        
        // Enabled das Element
        function enableElement(el)
        {
            el.disabled = false;
        }


