function SOLARBORSE_Class()

{

    this.cashUI       = {

                            devicesSelector : null,

                            devicesBox      : null,

                            total           :

                                {

                                    kHW         : null,

                                    kHWSave     : null,

                                    cHF         : null

                                },

                            totalPay        :

                                {

                                    Monthly     : null,

                                    Monthly2    : null,

                                    YearlyHalf  : null,

                                    Yearly      : null,

                                    Yearly2     : null

                                },

                            totalCalc       :

                                {

                                    kHW             : null,

                                    kHWSave         : null,

                                    cHF             : null,

                                    pay_Monthly     : null,

                                    pay_Monthly2    : null,

                                    pay_YearlyHalf  : null,

                                    pay_Yearly      : null,

                                    pay_Yearly2     : null

                                }

                        };

    this.addrPrefixDeliv    = 'AddrDelivery_';

    this.addrPrefixPay      = 'AddrPay_';

    this.devicesIndex_Templ = 1;

    this.devicesIndex_Start = 3;

}



SOLARBORSE_Class.prototype.init             = function()

{

    try

    {

        if (document.formSecond != null)

        {

            this.cashUI.total.kHW               = document.getElementById('total_KHW');

            this.cashUI.total.kHWSave           = document.getElementById('total_KHWSave');

            this.cashUI.total.cHF               = document.getElementById('total_CHF');



            this.cashUI.totalPay.Monthly        = document.getElementById('total_Pay_Monthly');

            this.cashUI.totalPay.Monthly2       = document.getElementById('total_Pay_Monthly2');

            this.cashUI.totalPay.YearlyHalf     = document.getElementById('total_Pay_YearlyHalf');

            this.cashUI.totalPay.Yearly         = document.getElementById('total_Pay_Yearly');

            this.cashUI.totalPay.Yearly2        = document.getElementById('total_Pay_Yearly2');



            this.cashUI.devicesSelector         = document.getElementById('devicesSelector');



            this.cashUI.devicesBox              = document.getElementById('toolsBox');



            for(var i = this.devicesIndex_Start; i < this.cashUI.devicesBox.rows.length; i = i + 2)

            {

                this.init_DeviceBox(this.cashUI.devicesBox.rows[i], this.cashUI.devicesBox.rows[i + 1]);

                this.device_Recalc(this.cashUI.devicesBox.rows[i]);

            }

            this.device_RecalcFull(null);

            this.init_Address();

            document.getElementById('AGB').onclick = function(){ 

                if (this.checked == true)

                {

                    document.getElementById('AGB_div').style.border = '';

                }

            };

        }

        else if (document.formFirst != null)

        {

            this.init_DeviceBox(document.formFirst);

            this.device_RecalcFull();

        }

    }

    catch(e)

    {

        alert('Error init : ' + e);

    }

}



SOLARBORSE_Class.prototype.init_DeviceBox = function(deviceRow1, deviceRow2)

{

    if (deviceRow2 == null) deviceRow2 = deviceRow1;

    deviceRow1.cash =

    {

        id              : deviceRow1.attributes.getNamedItem('sb:id'),

        consumption     : deviceRow1.attributes.getNamedItem('sb:consumption'),

        kwhselect       : deviceRow1.attributes.getNamedItem('sb:kwhselect'),

        hours           : this.getElementById('device_Hours',        deviceRow1),

        percents        : this.getElementById('device_Percents',     deviceRow1),

        kHW             : this.getElementById('device_KWH',          deviceRow2),

        cHF             : this.getElementById('device_CHF',          deviceRow2),

        calc            : null

    };

    if (deviceRow1.cash.kwhselect.value === '0')

    {

        deviceRow1.cash.hours.value = 168;

        deviceRow1.cash.hours.style.display = 'none';

    }

    else

    {

        this.dom_DropDownInit(deviceRow1.cash.hours);

    }

    

    deviceRow1.cash.hours.device    = deviceRow1;

    this.dom_DropDownInit(deviceRow1.cash.percents);

    deviceRow1.cash.percents.device = deviceRow1;

}



SOLARBORSE_Class.prototype.init_Address = function()

{

    this.cashUI.validateAddrFunc = function (validate, elem)

    {

    if (elem == null) elem = this;

        var valueDef = elem.attributes.getNamedItem('valueDef');

        if (validate != true)

        {

            if (valueDef != null && (elem.value == '' || elem.value == valueDef.value))

            {

                elem.style.color    = 'Gray';

                elem.value          = valueDef.value;

            }

            else elem.style.color = null;

        }

        else

        {

            var res = (valueDef != null && elem.value != '' && elem.value != valueDef.value);

            if (res == false)

            {

                elem.style.border = '1px solid Red';

            }

            else

            {

                elem.style.border = '1px solid #C6C5C4';

            }

            return res;

        }

    }

    this.cashUI.validateOnblur = function (elem)

    {

        var valueDef = this.attributes.getNamedItem('valueDef');

        if (this.value == valueDef || this.value == '')

        {

            this.value = valueDef.value;

        }

    }

    this.cashUI.validateOnfocus = function (elem)

    {

        var valueDef = this.attributes.getNamedItem('valueDef');

        if (this.value == valueDef.value)

        {

            this.value = '';

        }

    }

    this.cashUI.validateApplyEvents = function (elem)

    {

        if (elem == null) return;

        elem.onchange   = this.validateAddrFunc;

        elem.onblur     = this.validateOnblur;

        elem.onfocus    = this.validateOnfocus;

    }

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_Firma'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_Vorname'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_Name'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_Adresszusatz'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_PLZ'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_Ort'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_Telefon'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_Handy'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrDelivery_E_Mail'));

    //---------------------

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_Firma'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_Vorname'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_Name'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_Adresszusatz'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_PLZ'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_Ort'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_Telefon'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_Handy'));

    this.cashUI.validateApplyEvents(document.getElementById('AddrPay_E_Mail'));

}



SOLARBORSE_Class.prototype.device_Add             = function(devTag)

{

    if (devTag != null)

    {

        try

        {

            // Adding

            var deviceRow1 = this.cashUI.devicesBox.tBodies[0].rows[this.devicesIndex_Templ].cloneNode(true);

            var deviceRow2 = this.cashUI.devicesBox.tBodies[0].rows[this.devicesIndex_Templ + 1].cloneNode(true);

            deviceRow1.style.display = '';

            deviceRow2.style.display = '';

            this.cashUI.devicesBox.tBodies[0].appendChild(deviceRow1);

            this.cashUI.devicesBox.tBodies[0].appendChild(deviceRow2);

            // Prepare row 1

            deviceRow1.setAttribute('sb:id', devTag.id);

            deviceRow1.setAttribute('sb:consumption', devTag.getAttribute('sb:consumption'));

            deviceRow1.setAttribute('sb:kwhselect',   devTag.getAttribute('sb:kwhselect'));

            deviceRow1.cells[1].innerHTML = devTag.innerHTML;

            // Apply layout

            this.init_DeviceBox(deviceRow1, deviceRow2);

            this.device_RecalcFull(deviceRow1);            

        }

        catch(e)

        {

            alert('Error adding device : ' + e);

        }

    }

    this.cashUI.devicesSelector.style.display = 'none';

    return false;

}



SOLARBORSE_Class.prototype.device_Delete          = function(elem)

{

    try

    {

        var deviceRowIndex = elem.parentNode.parentNode.rowIndex;

        this.cashUI.devicesBox.deleteRow(deviceRowIndex);

        this.cashUI.devicesBox.deleteRow(deviceRowIndex);

        this.device_RecalcFull(null);

    }

    catch(e)

    {

        alert('Error deleting device');

    }

}

SOLARBORSE_Class.prototype.device_RecalcValidate  = function(device)

{

    if (device.cash.hours.value > 168) device.cash.hours.value = 168;

    if (device.cash.hours.value < 5)   device.cash.hours.value = 5;

    if (device.cash.percents.value.replace('%', '') > 100) device.cash.percents.value = '100%';

    if (device.cash.percents.value.replace('%', '') < 50)  device.cash.percents.value = '50%';

}



SOLARBORSE_Class.prototype.device_Recalc          = function(elem)

{

    try

    {

        var deviceTmp = elem;

        this.device_RecalcValidate(deviceTmp);

        deviceTmp.cash.calc = this.device_RecalcPrice(deviceTmp.cash.consumption.value, deviceTmp.cash.hours.value, deviceTmp.cash.percents.value.replace('%', ''));



        deviceTmp.cash.kHW.innerHTML = deviceTmp.cash.calc.kWH;

        deviceTmp.cash.cHF.innerHTML = deviceTmp.cash.calc.cHF;

    }

    catch(e)

    {

        alert('Error device_Recalc : ' + e);

    }

    return false;

}



SOLARBORSE_Class.prototype.device_RecalcFull      = function(elem)

{

    try

    {

        if (document.formSecond != null)

        {

            if (elem != null) this.device_Recalc((elem.device != null ? elem.device : elem));



            //----------------------------------

            this.cashUI.totalCalc.kHW       = 0;

            this.cashUI.totalCalc.kHWSave   = 0;

            this.cashUI.totalCalc.cHF       = 0;

            //----------------------------------

            this.cashUI.totalCalc.pay_Monthly       = 0;

            this.cashUI.totalCalc.pay_Monthly2      = 0;

            this.cashUI.totalCalc.pay_YearlyHalf    = 0;

            this.cashUI.totalCalc.pay_Yearly        = 0;

            this.cashUI.totalCalc.pay_Yearly2       = 0;

            //--------------------------------------

            for(var i = this.devicesIndex_Start; i < this.cashUI.devicesBox.rows.length; i = i + 2)

            {

                var toolBoxTmp                  = this.cashUI.devicesBox.rows[i];

                var total_KHWTmp                = (toolBoxTmp.cash.kHW.innerHTML)  * 1;

                this.cashUI.totalCalc.kHW       += total_KHWTmp;

                this.cashUI.totalCalc.kHWSave   += (total_KHWTmp * toolBoxTmp.cash.percents.value.replace('%', '') / 100);

                this.cashUI.totalCalc.cHF       += (toolBoxTmp.cash.cHF.innerHTML)  * 1;

            }

            this.cashUI.totalCalc.kHW           = this.cashUI.totalCalc.kHW.toFixed(2);

            this.cashUI.totalCalc.kHWSave       = this.cashUI.totalCalc.kHWSave.toFixed(2);

            this.cashUI.totalCalc.cHF           = this.roundFr(this.cashUI.totalCalc.cHF);

            //--------------------------------------

            this.cashUI.totalCalc.pay_Monthly     = this.roundFr((this.cashUI.totalCalc.cHF) * 1 + 2);

            this.cashUI.totalCalc.pay_Monthly2    = '24.00';

            this.cashUI.totalCalc.pay_YearlyHalf  = this.roundFr(this.cashUI.totalCalc.cHF * 6);

            this.cashUI.totalCalc.pay_Yearly      = this.roundFr(this.cashUI.totalCalc.cHF * 11);

            this.cashUI.totalCalc.pay_Yearly2     = this.roundFr(this.cashUI.totalCalc.cHF * 1);

            //--------------------------------------

            this.device_RecalcApply();

        }

        else if (document.formFirst != null)

        {

            this.device_RecalcValidate(document.formFirst);

            document.formFirst.cash.calc = this.device_RecalcPrice(document.formFirst.cash.consumption.value, document.formFirst.cash.hours.value, document.formFirst.cash.percents.value.replace('%', ''));

            this.device_RecalcApply();

        }

    }

    catch(e)

    {

        alert('Error device_RecalcFull : ' + e);

    }

}



SOLARBORSE_Class.prototype.device_RecalcApply      = function()

{

    if (document.formSecond != null)

    {

        this.cashUI.total.kHW.innerHTML             = this.cashUI.totalCalc.kHW;

        this.cashUI.total.kHWSave.innerHTML         = this.cashUI.totalCalc.kHWSave;

        this.cashUI.total.cHF.innerHTML             = this.cashUI.totalCalc.cHF;

        //----------------------------------------------------------------------

        var boxMonthly      = document.getElementById('boxMonthly');

        var boxYearlyHalf   = document.getElementById('boxYearlyHalf');

        var boxYearly       = document.getElementById('boxYearly');

        //----------------------------------------------------------------------

        if (this.cashUI.totalCalc.pay_Monthly < 30)

        {

            boxMonthly.style.display     = 'none';

            if (document.getElementById('Monthly').checked == true) document.getElementById('YearlyHalf').checked = true;

        }

        else boxMonthly.style.display     = 'table-row';

        this.cashUI.totalPay.Monthly.innerHTML                  = this.cashUI.totalCalc.pay_Monthly;

        this.cashUI.totalPay.Monthly2.innerHTML                 = this.cashUI.totalCalc.pay_Monthly2;

        //----------------------------------------------------------------------

        if (this.cashUI.totalCalc.pay_YearlyHalf < 30)

        {

            boxYearlyHalf.style.display     = 'none';

            if (document.getElementById('YearlyHalf').checked == true) document.getElementById('Yearly').checked = true;

        }

        else

        {

            boxYearlyHalf.style.display     = 'table-row';

        }

        this.cashUI.totalPay.YearlyHalf.innerHTML               = this.cashUI.totalCalc.pay_YearlyHalf;

        //----------------------------------------------------------------------

        this.cashUI.totalPay.Yearly.innerHTML                   = this.cashUI.totalCalc.pay_Yearly;

        this.cashUI.totalPay.Yearly2.innerHTML                  = this.cashUI.totalCalc.pay_Yearly2;

        //----------------------------------------------------------------------

    }

    else if (document.formFirst != null)

    {

        document.formFirst.cash.kHW.innerHTML = document.formFirst.cash.calc.kWH;

        document.formFirst.cash.cHF.innerHTML = document.formFirst.cash.calc.cHF;

    }

}



SOLARBORSE_Class.prototype.device_RecalcPrice = function(a_Consumption, a_Hours, a_Percent)

{

    var res     = {};

    a_Consumption   = a_Consumption * 1;

    a_Hours         = a_Hours * 1;

    a_Percent       = (a_Percent * 1) / 100;

    res.kWH         = (a_Consumption * a_Hours * 52 / 12).toFixed(2);

    res.cHF         = this.roundFr(res.kWH * a_Percent * 0.75);

    return res;

}



SOLARBORSE_Class.prototype.toJSON = function()

{

    var res     = {};

    //-----------------------

    res.devices = new Array();



    if (document.formSecond != null)

    {

        for(var i = this.devicesIndex_Start; i < this.cashUI.devicesBox.rows.length; i = i + 2)

        {

            res.devices.push

            ({

                id          : this.cashUI.devicesBox.rows[i].cash.id.value * 1,

                consumption : this.cashUI.devicesBox.rows[i].cash.consumption.value * 1,

                kwhselect   : this.cashUI.devicesBox.rows[i].cash.kwhselect.value * 1,

                hours       : this.cashUI.devicesBox.rows[i].cash.hours.value * 1,

                percents    : this.cashUI.devicesBox.rows[i].cash.percents.value.replace('%', '') * 1,

                calc        : this.cashUI.devicesBox.rows[i].cash.calc

            });

        }

        res.totalCalc               = this.cashUI.totalCalc;

        res.totalCalc.pay_Period    = null;

        if (document.getElementById('Monthly').checked)     res.totalCalc.pay_Period = document.getElementById('Monthly').value;

        if (document.getElementById('YearlyHalf').checked)  res.totalCalc.pay_Period = document.getElementById('YearlyHalf').value;

        if (document.getElementById('Yearly').checked)      res.totalCalc.pay_Period = document.getElementById('Yearly').value;

        //-----------------------

        var prefix = 'AddrPay_';



        var frauHerrTmp = null;

        if (document.getElementById(prefix + 'Frau').checked)  frauHerrTmp = document.getElementById(prefix + 'Frau').value;

        if (document.getElementById(prefix + 'Herr').checked)  frauHerrTmp = document.getElementById(prefix + 'Herr').value;



        res.addrPay =

        {

            Firma           : document.getElementById(prefix + 'Firma').value,

            FrauHerr        : frauHerrTmp * 1,

            Vorname         : document.getElementById(prefix + 'Vorname').value,

            Name            : document.getElementById(prefix + 'Name').value,

            Adresszusatz    : document.getElementById(prefix + 'Adresszusatz').value,

            PLZ             : document.getElementById(prefix + 'PLZ').value,

            Ort             : document.getElementById(prefix + 'Ort').value,

            Telefon         : document.getElementById(prefix + 'Telefon').value,

            Handy           : document.getElementById(prefix + 'Handy').value,

            E_Mail          : document.getElementById(prefix + 'E_Mail').value

        };



        if (document.getElementById('Lieferanschrift').checked == false)

        {

            prefix = 'AddrDelivery_';

            frauHerrTmp = null;

            if (document.getElementById(prefix + 'Frau').checked)  frauHerrTmp = document.getElementById(prefix + 'Frau').value;

            if (document.getElementById(prefix + 'Herr').checked)  frauHerrTmp = document.getElementById(prefix + 'Herr').value;

            res.addrDelivery =

            {

                Firma           : document.getElementById(prefix + 'Firma').value,

                FrauHerr        : frauHerrTmp * 1,

                Vorname         : document.getElementById(prefix + 'Vorname').value,

                Name            : document.getElementById(prefix + 'Name').value,

                Adresszusatz    : document.getElementById(prefix + 'Adresszusatz').value,

                PLZ             : document.getElementById(prefix + 'PLZ').value,

                Ort             : document.getElementById(prefix + 'Ort').value,

                Telefon         : document.getElementById(prefix + 'Telefon').value,

                Handy           : document.getElementById(prefix + 'Handy').value,

                E_Mail          : document.getElementById(prefix + 'E_Mail').value

            };

        }

        res.newsletter = document.getElementById('Newsletter').checked;

    }

    else if (document.formFirst != null)

    {

        res.devices.push

        ({

            id          : document.formFirst.cash.id.value * 1,

            consumption : document.formFirst.cash.consumption.value * 1,

            kwhselect   : document.formFirst.cash.kwhselect.value * 1,

            hours       : document.formFirst.cash.hours.value * 1,

            percents    : document.formFirst.cash.percents.value.replace('%', '') * 1,

            calc        : document.formFirst.cash.calc

        });

    }

    return JSON.stringify(res);

}



SOLARBORSE_Class.prototype.ui_addressHide         = function(elem)

{

    document.getElementById(this.addrPrefixDeliv + 'Firma').disabled        = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Frau').disabled         = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Herr').disabled         = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Vorname').disabled      = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Name').disabled         = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Adresszusatz').disabled = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'PLZ').disabled          = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Ort').disabled          = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Telefon').disabled      = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'Handy').disabled        = elem.checked;

    document.getElementById(this.addrPrefixDeliv + 'E_Mail').disabled       = elem.checked;



    if (elem.checked)

    {

        document.getElementById(this.addrPrefixDeliv + 'Firma').value           = document.getElementById(this.addrPrefixPay + 'Firma').value;

        document.getElementById(this.addrPrefixDeliv + 'Frau').checked          = document.getElementById(this.addrPrefixPay + 'Frau').checked;

        document.getElementById(this.addrPrefixDeliv + 'Herr').checked          = document.getElementById(this.addrPrefixPay + 'Herr').checked;

        document.getElementById(this.addrPrefixDeliv + 'Vorname').value         = document.getElementById(this.addrPrefixPay + 'Vorname').value;

        document.getElementById(this.addrPrefixDeliv + 'Name').value            = document.getElementById(this.addrPrefixPay + 'Name').value;

        document.getElementById(this.addrPrefixDeliv + 'Adresszusatz').value    = document.getElementById(this.addrPrefixPay + 'Adresszusatz').value;

        document.getElementById(this.addrPrefixDeliv + 'PLZ').value             = document.getElementById(this.addrPrefixPay + 'PLZ').value;

        document.getElementById(this.addrPrefixDeliv + 'Ort').value             = document.getElementById(this.addrPrefixPay + 'Ort').value;

        document.getElementById(this.addrPrefixDeliv + 'Telefon').value         = document.getElementById(this.addrPrefixPay + 'Telefon').value;

        document.getElementById(this.addrPrefixDeliv + 'Handy').value           = document.getElementById(this.addrPrefixPay + 'Handy').value;

        document.getElementById(this.addrPrefixDeliv + 'E_Mail').value          = document.getElementById(this.addrPrefixPay + 'E_Mail').value;

    }

}



SOLARBORSE_Class.prototype.ui_device_SelectShow   = function(elem)

{

    if (elem != null)

    {

        this.cashUI.devicesSelector.style.display = 'block';

    }

    else

    {

        this.cashUI.devicesSelector.style.display = 'none';

    }

}



SOLARBORSE_Class.prototype.ui_Submit   = function(elem)

{

    try

    {

        if (document.formSecond != null)

        {

            var email_regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;  // email address

           // var phone_regex = /^\d{3} \d{3} \d{2} \d{2}$/;  //071 280 09 77



            var formIsValid  = true;

            var formAlertStr = null;

            formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrPay_Vorname')) && formIsValid;

            formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrPay_Name'))    && formIsValid;

            formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrPay_PLZ'))     && formIsValid;

            formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrPay_Ort'))     && formIsValid;

/*

            var phone = document.getElementById('AddrPay_Telefon');

            var phone_valueDef = phone.attributes.getNamedItem('valueDef');

            if ((phone_valueDef != null && (phone.value == '' || phone.value == phone_valueDef.value)) == false && !phone.value.match(phone_regex))

            {

                formAlertStr = 'Bitte Telefonnummer in folgendem Format eingeben: 071 280 09 77';

                formIsValid = formIsValid && false;

                phone.style.border = '1px solid Red';

            }

            else

            {

                phone.style.border = '1px solid #C6C5C4';

            }
			*/

            var email = document.getElementById('AddrPay_E_Mail');

            if (this.cashUI.validateAddrFunc(true, email)  == false)

            {

                formIsValid = formIsValid && false;

            }

            else if (!email_regex.test(email.value))

            {

                formAlertStr = (formAlertStr == null ? 'E_Mail is invalid' : formAlertStr);

                formIsValid = formIsValid && false;

                email.style.border = '1px solid Red';

            }

            else

            {

                email.style.border = '1px solid #C6C5C4';

            }

            //------------------------------------------------------------------

            if (document.getElementById('Lieferanschrift').checked == false)

            {

                formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrDelivery_Vorname')) && formIsValid;

                formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrDelivery_Name'))    && formIsValid;

                formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrDelivery_PLZ'))     && formIsValid;

                formIsValid = this.cashUI.validateAddrFunc(true, document.getElementById('AddrDelivery_Ort'))     && formIsValid;


/*
                phone = document.getElementById('AddrDelivery_Telefon');

                phone_valueDef = phone.attributes.getNamedItem('valueDef');

                if ((phone_valueDef != null && (phone.value == '' || phone.value == phone_valueDef.value)) == false && !phone.value.match(phone_regex))

                {

                    formAlertStr = 'Bitte Telefonnummer in folgendem Format eingeben: 071 280 09 77';

                    formIsValid = formIsValid && false;

                    phone.style.border = '1px solid Red';

                }

                else

                {

                    phone.style.border = '1px solid #C6C5C4';

                }
*/
                email = document.getElementById('AddrDelivery_E_Mail');

                if (this.cashUI.validateAddrFunc(true, email)  == false)

                {

                    formIsValid = formIsValid && false;

                }

                else if (!email_regex.test(email.value))

                {

                    formAlertStr = (formAlertStr == null ? 'E_Mail is invalid' : formAlertStr);

                    formIsValid = formIsValid && false;

                    email.style.border = '1px solid Red';

                }

                else

                {

                    email.style.border = '1px solid #C6C5C4';

                }

            }

            //------------------------------------------------------------------

            if (document.getElementById('AGB').checked == false)

            {

                document.getElementById('AGB_div').style.border = '1px solid Red';

                formIsValid = formIsValid && false;

            }

            //------------------------------------------------------------------

            if (formAlertStr != null) alert(formAlertStr);

            if (formIsValid == false) return formIsValid;

        }

        document.getElementById('jsonField').value = this.toJSON();       

    }

    catch(e)

    {

        alert('Errror ui_Submit : ' + e);

    }

    if      (document.formSecond != null) document.formSecond.submit();

    else if (document.formFirst != null)  document.formFirst.submit();

    

    return false;

}



SOLARBORSE_Class.prototype.roundFr = function(X)

{

    return (Math.ceil(X / 0.05) * 0.05).toFixed(2);

}

SOLARBORSE_Class.prototype.getElementById = function(id, elem)

{

    var res = null;

    for(var i = 0; i < elem.childNodes.length; i++)

    {

        res = (elem.childNodes[i].id == id ? elem.childNodes[i] : this.getElementById(id, elem.childNodes[i]));

        if (res != null) break;

    }

    return res;

}



SOLARBORSE_Class.prototype.getElementsByClassName = function(id, elem, up, res)

{

    if (up == null) up = false;

    if (up)

    {

        var elemTmp = elem.parentNode;

        while (elemTmp != null)

        {

            if (elemTmp.className == id) return elemTmp;

            elemTmp = elemTmp.parentNode;

        }

    }

    else

    {

        if (res == null) res = [];

        for(var i = 0; i < elem.childNodes.length; i++)

        {

            if (elem.childNodes[i].className == id)

            {

                res.push(elem.childNodes[i]);

            }

            this.getElementsByClassName(id, elem.childNodes[i], up, res);

        }

        return res;

    }

    return null;

}



SOLARBORSE_Class.prototype.dom_DropDownInit = function(dest)

{

    

    var css_arrowImage          = (dest.getAttribute('selectBoxButton') != null ? dest.getAttribute('selectBoxButton') : 'img/select_arrow.gif');

    var css_arrowImageOver      = css_arrowImage;

    var css_class_dest          = 'selectBoxInput';

    var css_class_div           = 'selectBox';

    var css_class_img           = 'selectBoxArrow';

    var css_class_selBoxOptions = 'selectBoxOptionContainer';

    var css_class_anOption      = 'selectBoxAnOption';

    var zIndexBase              = 10;

    //================================================

    dest.className = (dest.className != '' ? dest.className + ' ' + css_class_dest : css_class_dest);

    //dest.className      = css_class_dest;

    //dest.classList.add(css_class_dest);

    //================================================

    dest.ext = {

        div_WrapTop     : document.createElement('DIV'),

        parent          : dest.parentNode,

        button          : document.createElement('IMG'),

        selectBox       : document.createElement('DIV'),

        selectBoxFrame  : (false ? (navigator.userAgent.indexOf('MSIE')>=0 ? document.createElement('<IFRAME src="about:blank" frameborder=0>') : null) : null),

        activeOption    : null

    };

    dest.ext.div_WrapTop.ext_dest   = dest;

    dest.ext.parent.ext_dest        = dest;

    dest.ext.button.ext_dest        = dest;

    dest.ext.selectBox.ext_dest     = dest;

    if (dest.ext.selectBoxFrame != null) dest.ext.selectBoxFrame.ext_dest    = dest;    

    //=======  WrapTop  ========================================================

    //dest.ext.div_WrapTop.style.width         = dest.offsetWidth + 14 + 'px';

    dest.ext.div_WrapTop.className           = css_class_div;

    //------------------------------------------------

    dest.ext.parent.insertBefore(dest.ext.div_WrapTop, dest);

    dest.ext.div_WrapTop.appendChild(dest);

    //=======  Button  =========================================================

    dest.ext.button.src         = css_arrowImage;

    dest.ext.button.className   = css_class_img;

    dest.ext.button.onmouseover = function ()

        {

            if(this.src.indexOf(css_arrowImage) >= 0) this.src = this.src.replace (css_arrowImage, css_arrowImageOver);

            else this.src = this.src.replace (css_arrowImageOver, css_arrowImage);

        };

    dest.ext.button.onmouseout  = dest.ext.button.onmouseover;

    dest.ext.button.onclick     = function (e)

        {

            if (this.ext_dest.ext.selectBox.style.display == 'block')

            {

                this.ext_dest.ext.selectBox.style.display   = 'none';

                if (this.ext_dest.ext.selectBoxFrame != null ) this.ext_dest.ext.selectBoxFrame.style.display='none';

            }

            else

            {

                var clRect = SOLARBORSE.dom_getClientRects(this.ext_dest.ext.div_WrapTop);

                this.ext_dest.ext.selectBox.style.left = clRect.left + 'px';

                //this.ext_dest.ext.selectBox.style.top  = clRect.top + this.ext_dest.ext.div_WrapTop.offsetHeight + 'px';

                this.ext_dest.ext.selectBox.style.top  = clRect.top + this.ext_dest.ext.div_WrapTop.offsetHeight - this.ext_dest.ext.div_WrapTop.offsetTop + 'px';



                this.ext_dest.ext.selectBox.style.display   = 'block';

                if (this.ext_dest.ext.selectBoxFrame != null ) this.ext_dest.ext.selectBoxFrame.style.display = 'none';

            }

        };

    dest.ext.div_WrapTop.appendChild(dest.ext.button);

    //=======  WrapTop  ========================================================

    dest.ext.div_WrapTop.style.width         = dest.offsetWidth + dest.ext.button.offsetWidth + 'px';

    //=======  SelectBox =======================================================

    dest.ext.selectBox.className        = css_class_selBoxOptions;

    //dest.ext.selectBox.style.width      = dest.ext.div_WrapTop.offsetWidth - 3 + 'px';

    dest.ext.selectBox.style.width      = dest.ext.div_WrapTop.offsetWidth - 0 + 'px';

    dest.ext.selectBox.style.zIndex     = zIndexBase

    dest.ext.div_WrapTop.appendChild(dest.ext.selectBox);

    //=======  SelectBoxFrame ==================================================

    if (dest.ext.selectBoxFrame != null) {

        dest.ext.selectBoxFrame.style.width      = dest.ext.selectBox.style.width;

        dest.ext.selectBoxFrame.style.height     = dest.ext.selectBox.offsetHeight + 'px';

        dest.ext.selectBoxFrame.style.display    = 'none';

        dest.ext.div_WrapTop.appendChild(dest.ext.selectBoxFrame);

    }

    //=======  SelectBox Options ===============================================

    var optHeight = null;

    var optionsTotalHeight  = 0;

    if (dest.getAttribute('selectBoxOptions'))

    {

        var options             = dest.getAttribute('selectBoxOptions').split(';');

        

        var optionArray         = new Array();

        for (var no = 0; no < options.length; no++)

        {

            var anOption            = document.createElement('DIV');

            anOption.ext_dest       = dest;

            anOption.innerHTML      = options[no];

            anOption.className      = css_class_anOption;

            anOption.onclick        = function ()

                {

                    this.ext_dest.value             = this.innerHTML;

                    this.parentNode.style.display   = 'none';

                    if (this.ext_dest.ext.selectBoxFrame != null) this.ext_dest.ext.selectBoxFrame.style.display = 'none';

                    if (this.ext_dest.onchange != null) this.ext_dest.onchange(this.ext_dest.value);

                };

            anOption.style.width    = dest.ext.div_WrapTop.offsetWidth + 'px';

            anOption.onmouseover    = function ()

                {

                    if (this.style.backgroundColor == '#316AC5'){

                        this.style.backgroundColor  = '';

                        this.style.color            = '';

                    }else{

                        this.style.backgroundColor  = '#316AC5';

                        this.style.color            = '#FFF';

                    }

                    if (this.ext_dest.activeOption) {

                        this.ext_dest.activeOption.style.backgroundColor = '';

                        this.ext_dest.activeOption.style.color           = '';

                    }

                    this.ext_dest.activeOption = this;

                };

            dest.ext.selectBox.appendChild(anOption);

            optionsTotalHeight      = optionsTotalHeight + anOption.offsetHeight;

            optionArray.push(anOption);

            optHeight = anOption.offsetHeight + 2;

        }

        if (optionsTotalHeight > dest.ext.selectBox.offsetHeight)

        {

            for (var no = 0; no < optionArray.length; no++) optionArray[no].style.width = dest.ext.selectBox.style.width.replace('px','') - 22 + 'px';

        }

        dest.ext.selectBox.style.display    = 'none';

        dest.ext.selectBox.style.visibility = 'visible';

    }

    //=======  SelectBox =======================================================

    if (optHeight != null && dest.getAttribute('selectBoxOptionsVisible') != null)

    {

        dest.ext.selectBox.style.height      = optHeight * dest.getAttribute('selectBoxOptionsVisible') + 'px';

    }

}

SOLARBORSE_Class.prototype.dom_getClientRects = function(elem)

{

    var isIE        = navigator.userAgent.indexOf('MSIE') >= 0;

    var resRect     = elem.getClientRects();

    resRect         = {top:resRect[0].top, right:resRect[0].right, bottom:resRect[0].bottom, left:resRect[0].left, scroll:SOLARBORSE.dom_getScrollXY()};

    resRect.top    += resRect.scroll.y;

    resRect.bottom += resRect.scroll.y;

    resRect.left   += resRect.scroll.x;

    resRect.right  += resRect.scroll.x;

    return resRect;

}

SOLARBORSE_Class.prototype.dom_getScrollXY = function()

{

    if( typeof( window.pageYOffset ) == 'number' ) //Netscape compliant

    {

        return {x:window.pageXOffset, y:window.pageYOffset};

    }

    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) //DOM compliant

    {



        return {x:document.body.scrollLeft, y:document.body.scrollTop};

    }

    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) //IE6 standards compliant mode

    {

        return {x:document.documentElement.scrollLeft, y:document.documentElement.scrollTop};

    }

    return {x:0, y:0};

}



SOLARBORSE = new SOLARBORSE_Class();

SOLARBORSE.init();
