/**
 * Preisverwalung für Inputfelder
 *
 * @copyright  Copyright (c) 2009 M&M Online Service - www.melster-melster.de
 */

jQuery.fn.extend({

    MMOS: {
        option_nummer_breite: function(){ return 44; },
        option_nummer_farbe: function(){ return 45; },
        option_nummer_hoehe: function(){ return 46; },
        option_nummer_antriebsart: function(){ return 60; },
        option_nummer_antriebsseite: function(){ return 59; },
        option_nummer_montageart: function(){ return 58; },
        option_nummer_gestellfarbe: function(){ return 61; },
        option_nummer_ral: function(){ return 95; },
        option_nummer_volanttyp: function(){ return 57; },
        option_nummer_volantmass: function(){ return 96; },
        option_nummer_beleuchtung: function(){ return 97; },

        option_nummer_standard_antriebsart_kurbel: function(){ return 82; },
        option_nummer_standard_antriebsseite_links: function(){ return 2; },
        option_nummer_standard_gestellfarbe_ral: function(){ return 5; },
        option_nummer_standard_gestellfarbe_ral_value: function(){ return 134; },
        option_nummer_standard_montageart_wand: function(){ return 77; },
        option_nummer_standard_volanttyp_ohne: function(){ return 2; },
        option_nummer_standard_volanttyp_ohne_value: function(){ return 72; },
        option_nummer_standard_volanttyp_m1: function(){ return 3; },
        option_nummer_standard_volanttyp_m2: function(){ return 4; },
        option_nummer_standard_volantmass_preise: function(){ return 4; },
        option_nummer_standard_volantmass_150: function(){ return 2; },
        option_nummer_standard_volantmass_200: function(){ return 3; },
        option_nummer_standard_beleuchtung_ja: function(){ return 3; },
        option_nummer_standard_beleuchtung_ja_value: function(){ return 137; },
        option_nummer_standard_beleuchtung_nein: function(){ return 2; },
        option_nummer_standard_beleuchtung_preise: function(){ return 4; },

        maxbreiteVolant: function() { return 600; },

        ausfall: function() { return (new Function( "return( " + jQuery('#mmos_ausfallmasse').val() + " );" ))(); },

        minbreite: function(){
            var tmp = jQuery().MMOS.ausfall();
            if(jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val() == '' || tmp[jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val()]['minbreite'] == 'undefined') {
                return 0;
            }
            return tmp[jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val()]['minbreite'];
        },
        maxbreite: function(){
            var tmp = jQuery().MMOS.ausfall();
            if(jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val() == '' || tmp[jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val()]['maxbreite'] == 'undefined') {
                return 0;
            }
            return tmp[jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val()]['maxbreite'];
        },
        getAusfall: function(){
            var tmp = jQuery().MMOS.ausfall();
            if(jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val() == '' || tmp[jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val()]['cm'] == 'undefined') {
                return 0;
            }
            return tmp[jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val()]['cm']
        },
        getBeleuchtungspreis: function(breite){
            var preise = (new Function( "return( " + jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_preise()).next('span').children('label').html() + " );" ))();
            return preise[breite];
        },
        getVolantmass: function(){
            if(jQuery('#options_'+jQuery().MMOS.option_nummer_volantmass()+'_'+jQuery().MMOS.option_nummer_standard_volantmass_150()).is(':checked') == true){
                return 150;
            } else if(jQuery('#options_'+jQuery().MMOS.option_nummer_volantmass()+'_'+jQuery().MMOS.option_nummer_standard_volantmass_200()).is(':checked') == true){
                return 200;
            } else {
                return 0;
            }
        },
        getBeleuchtungspreis: function(breite){
            var preise = (new Function( "return( " + jQuery('#mmos_beleuchtungspreise').val() + " );" ))();
            var index_breite = 0;
            if(jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_ja()).is(':checked')) {
                for (var key in preise) {
                    if(key >= breite){ return preise[key]; }
                }
            }
            return 0;
        },
        getVolantpreis: function(breite, volant){

            var preise = (new Function( "return( " + jQuery('#mmos_volantpreise').val() + " );" ))();
            var index_breite = 0;

            for (var key in preise[volant]) { if(new Number(key) >= breite){ return new Number(preise[volant][key]); } }
            return 0;
        },
        loadPreisFromMasse: function(){
            var date = new Date();
            jQuery('#mmos_produktpreis').load(jQuery('#mmos_preis_url').val(), { p: jQuery('#mmos_product_id').val(), x: jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val(), y: jQuery().MMOS.getAusfall(), t: date.getTime() }, function(responseText){
                jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_volantmass(), jQuery().MMOS.getVolantpreis(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val(), jQuery().MMOS.getVolantmass()), jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list li input:checked').val());
                jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_beleuchtung(), jQuery().MMOS.getBeleuchtungspreis(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val()), jQuery('#options-'+jQuery().MMOS.option_nummer_beleuchtung()+'-list li input:checked').val());
                jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_breite(), responseText, null);
            });

            jQuery('#mmos_preis').val(jQuery('#mmos_produktpreis').text());
        },
        setPreis:function(element_id, price, element_id2){
            if(element_id2 != null){
                opConfig.config[element_id][element_id2] = new Number(price);
            } else {
                opConfig.config[element_id] = new Number(price);
            }
            opConfig.reloadPrice();
        }
    }

});

jQuery(document).ready(function(){

    var check_hoehe = false;
    var check_breite = false;

    jQuery(".product-custom-option").each(function() {

        if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_hoehe()+']' /* Hoehe/Ausfall Markise */) {

            jQuery(this).blur(function(){

                var date = new Date();

                if(jQuery(this).val().length == 0) {
                    //jQuery.noticeAdd({ text: jQuery().MMOS_LANG.hoehe_erforderlich(), stay: false, stayTime: 6000, type: 'error' });
                    check_hoehe = false;
                } else {
                    if(/^[0-9]+$/.test(jQuery().MMOS.getAusfall()) == false) {
                        //jQuery.noticeAdd({ text: jQuery().MMOS_LANG.angabe_nicht_korrekt(), stay: false, stayTime: 6000, type: 'error' });
                        check_hoehe = false;
                    } else {

                        if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() > 0) {
                            if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() >= jQuery().MMOS.minbreite() && jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() <= jQuery().MMOS.maxbreite()) {
                                check_hoehe = true;
                            } else {
                                jQuery.noticeAdd({ text: jQuery().MMOS_LANG.breite_min1()+jQuery().MMOS.minbreite()+jQuery().MMOS_LANG.breite_min2()+jQuery().MMOS.maxbreite()+jQuery().MMOS_LANG.breite_min3(), stay: false, stayTime: 4000, type: 'error' });
                                jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').parent('dd').prev().click();
                                check_hoehe = false
                            }
                        } else {
                            check_hoehe = false;
                        }

                        if(check_hoehe == true) {
                            jQuery().MMOS.loadPreisFromMasse();
                        }
                    }
                }

                return false;
            });

        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_breite()+']' /* Breite Markise */) {

            jQuery(this).before('<input type="text" id="mmos_preis" style="display: none;" name="mmos_preis" value="" />');
            jQuery(this).before('<div id="mmos_produktpreis"></div>');
            jQuery('#mmos_produktpreis').css({'position':'absolute', 'left':-1000});

            jQuery(this).blur(function(){
                var date = new Date();
                if(jQuery(this).val().length == 0) {
                    check_breite = false;
                } else {
                    if(/^[0-9]+$/.test(jQuery(this).val()) == false) {
                        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.angabe_nicht_korrekt(), stay: false, stayTime: 6000, type: 'error' });
                        check_breite = false;
                    } else {

                        if(jQuery().MMOS.getAusfall() > 0) {
                            if(jQuery(this).val() >= jQuery().MMOS.minbreite() && jQuery(this).val() <= jQuery().MMOS.maxbreite()) {
                                check_breite = true;
                            } else {
                                jQuery.noticeAdd({ text: jQuery().MMOS_LANG.breite_min1()+jQuery().MMOS.minbreite()+jQuery().MMOS_LANG.breite_min2()+jQuery().MMOS.maxbreite()+jQuery().MMOS_LANG.breite_min3(), stay: false, stayTime: 4000, type: 'error' });
                                check_breite = false
                            }
                        } else {
                            check_breite = false;
                            jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_volantmass(), jQuery().MMOS.getVolantpreis(jQuery(this).val(), jQuery().MMOS.getVolantmass()), jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list li input:checked').val());
                            jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_beleuchtung(), jQuery().MMOS.getBeleuchtungspreis(jQuery(this).val()), jQuery('#options-'+jQuery().MMOS.option_nummer_beleuchtung()+'-list li input:checked').val());
                        }

                        if(check_breite == true) {
                            jQuery().MMOS.loadPreisFromMasse();
                        }

                        if(jQuery(this).val() > jQuery().MMOS.maxbreiteVolant()){
                            if(jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_ja()).is(':checked') == true || jQuery().MMOS.getVolantmass() > 0){
                                jQuery('#options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_ohne()).click();
                                jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_nein()).click();
                                jQuery.noticeAdd({ text: jQuery().MMOS_LANG.max_breite_volant_beleuchtung1()+jQuery().MMOS.maxbreiteVolant()+jQuery().MMOS_LANG.max_breite_volant_beleuchtung2(), stay: false, stayTime: 4000, type: 'error' });
                            }
                        }
                    }
                }

                return false;
            });

        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_farbe()+']' /* Stoffe und Farben */) {

            var date = new Date()
            var inputid = jQuery(this).attr('id');

            jQuery(this).before('<input type="button" name="stoff_btn" class="buttonstyle" id="stoff_btn" value="'+jQuery().MMOS_LANG.farbe_waehlen()+'"/>');
            jQuery(this).css({'position':'absolute', 'left':-1000});
            jQuery(this).after('<img src="/media/spacer.gif" class="stoffbilder" id="stoff_thumb" align="center" width="150" height="56" alt=" " border="0" />');
            jQuery('#stoff_thumb').css({'margin-top': '15px'});

            jQuery('#stoff_btn').click(function(){
                jQuery('#mmos_farben_stoff').overlay({

                    // some expose tweaks suitable for modal dialogs
                    expose: {
                        color: '#fff',
                        loadSpeed: 200,
                        opacity: 0.8
                    },

                    closeOnClick: false,
                    api: true
                }).load();

                var buttons = jQuery("img.stoffbilder").click(function(e) {
                    var pfad = jQuery(this).attr('src').split('/');
                    var name = pfad[pfad.length-1];
                    var ral = name.split('.');

                    jQuery('#options_'+jQuery().MMOS.option_nummer_farbe()+'_text').val(ral[0]);
                    jQuery('#stoff_thumb_txt').remove();
                    jQuery('#stoff_thumb').after('<span id="stoff_thumb_txt">'+ral[0]+'</span>');
                    jQuery('#stoff_thumb').attr('src', jQuery(this).attr('src'));
                    jQuery('#stoff_thumb').attr('alt', jQuery(this).attr('alt'));
                    jQuery(this).qtip('hide');
                    jQuery('#mmos_farben_stoff').overlay().close();
                });

                jQuery('div.stoffe_farben_tabs_content div').hide();

                jQuery(".stoffe_farben_tabs li").live('click', function(){
                    jQuery('div.stoffe_farben_tabs_content div').hide();
                    jQuery(".stoffe_farben_tabs li").removeClass('activ_tab');
                    jQuery(this).addClass('activ_tab');
                    jQuery('#'+jQuery(this).attr('id')+'_content').show();
                });

                jQuery('.stoffe_farben_tabs li:first').click();

            });

        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_antriebsart()+']' /* Antriebsart */) {

            jQuery(this).children('option').each(function(i){
                if(jQuery(this).val() == jQuery().MMOS.option_nummer_standard_antriebsart_kurbel()) {
                    jQuery(this).attr("selected", "selected");
                }
            });

        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_ral()+']' /* Eigene Gestellfarbe RAL */) {

            var dd = jQuery(this).parent('dd');
            var dt = jQuery(dd).prev();

            var ral_html = jQuery(dd).html();
            var ral_ueberschrift_html = jQuery(dt).html();

            jQuery(dd).remove();
            jQuery(dt).qtip('disable').remove();

            jQuery('#options-'+jQuery().MMOS.option_nummer_gestellfarbe()+'-list').append('<li>'+ral_html+'</li>');
            jQuery('#options_'+jQuery().MMOS.option_nummer_gestellfarbe()+'_'+jQuery().MMOS.option_nummer_standard_gestellfarbe_ral()).change(function(){
                jQuery('#options_'+jQuery().MMOS.option_nummer_ral()+'_text').focus();
            });

        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_antriebsseite()+']' /* Antriebsseite */) {
                jQuery('#options_'+jQuery().MMOS.option_nummer_antriebsseite()+'_'+jQuery().MMOS.option_nummer_standard_antriebsseite_links()).attr("checked", "checked");
        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_montageart()+']' /* Montageart */) {

            jQuery(this).children('option').each(function(i){
                if(jQuery(this).val() == jQuery().MMOS.option_nummer_standard_montageart_wand()) {
                    jQuery(this).attr("selected", "selected");
                }
            });

        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_volanttyp()+']' /* Volanttyp */) {

            if(jQuery(this).attr('id') == 'options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_m1()){
                jQuery(this).next('span.label').children('label').append('&nbsp;<img src="/media/m1.jpg" alt="" />')
            } else if(jQuery(this).attr('id') == 'options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_m2()){
                jQuery(this).next('span.label').children('label').append('&nbsp;<img src="/media/m2.jpg" alt="" />')
            }

            jQuery(this).click(function(){
                if(jQuery(this).val() != jQuery().MMOS.option_nummer_standard_volanttyp_ohne_value()){
                    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list').show();
                    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list li input').click(function(){
                        if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() > 0){
                            var preis = jQuery().MMOS.getVolantpreis(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val(), jQuery().MMOS.getVolantmass());
                            jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_volantmass(), preis, jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list li input:checked').val());
                        }
                    });
                } else {
                    jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_volantmass(), 0, jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list li input:checked').val());
                    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list li input:checked').removeAttr('checked');
                    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list').hide();
                }
            });

        } else if(jQuery(this).attr('name') == 'options['+jQuery().MMOS.option_nummer_beleuchtung()+']' /* Beleuchtung */) {
            jQuery(this).click(function(){
                if(jQuery(this).val() == jQuery().MMOS.option_nummer_standard_beleuchtung_ja_value()){
                    if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() <= jQuery().MMOS.maxbreiteVolant()) {
                        jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_beleuchtung(), jQuery().MMOS.getBeleuchtungspreis(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val()), jQuery().MMOS.option_nummer_standard_beleuchtung_ja_value());
                    } else {
                        jQuery('#options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_ohne()).click();
                        jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_nein()).click();
                        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.max_breite_volant_beleuchtung1()+jQuery().MMOS.maxbreiteVolant()+jQuery().MMOS_LANG.max_breite_volant_beleuchtung2(), stay: false, stayTime: 4000, type: 'error' });
                    }
                } else {
                    jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_beleuchtung(), 0, jQuery().MMOS.option_nummer_standard_beleuchtung_ja_value());
                }
            });
        }
    });

    var mass = jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list').parent('dd').html();
    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list').parent('dd').prev('dt').qtip('disable').remove();
    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list').parent('dd').remove();
    jQuery('#options-'+jQuery().MMOS.option_nummer_volanttyp()+'-list').after(mass);

    jQuery('#options-'+jQuery().MMOS.option_nummer_volanttyp()+'-list').parent('dd').css({'width': '94%', 'float': 'left'});
    jQuery('#options-'+jQuery().MMOS.option_nummer_volanttyp()+'-list').css({'width': '60%', 'float': 'left'});
    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list').css({'width': '35%', 'float': 'left', 'height': jQuery('#options-'+jQuery().MMOS.option_nummer_volanttyp()+'-list').css('height')});
    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-container').css({'width': '100%'});

    jQuery('#options-'+jQuery().MMOS.option_nummer_volantmass()+'-list li input').click(function(){
        if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() <= jQuery().MMOS.maxbreiteVolant()) {
            if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() > 0 && jQuery().MMOS.getVolantmass() > 0){
                var preis = jQuery().MMOS.getVolantpreis(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val(), jQuery().MMOS.getVolantmass());
                jQuery().MMOS.setPreis(jQuery().MMOS.option_nummer_volantmass(), preis, jQuery(this).val());
            }
        } else {
            jQuery('#options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_ohne()).click();
            jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_nein()).click();
            jQuery.noticeAdd({ text: jQuery().MMOS_LANG.max_breite_volant_beleuchtung1()+jQuery().MMOS.maxbreiteVolant()+jQuery().MMOS_LANG.max_breite_volant_beleuchtung2(), stay: false, stayTime: 4000, type: 'error' });
        }
    });

    jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_nein()).click();
    jQuery('#options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_ohne()).click();
    jQuery('#options_'+jQuery().MMOS.option_nummer_volantmass()).parent('li').hide();

});

//Pruefen der angaben vor dem senden
function MMOS_validate(){

    //Hoehe pruefen
    if(jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).val() < 1) {
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.hoehe_erforderlich(), stay: false, stayTime: 4000, type: 'error' });
        jQuery('#select_'+jQuery().MMOS.option_nummer_hoehe()).parent('dd').prev().click();
        return false;
    }

    //Breite pruefen
    if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val().length == 0) {
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.breite_angeben(), stay: false, stayTime: 4000, type: 'error' });
        jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').parent('dd').prev().click();
        return false;
    }
    if(/^[0-9]+$/.test(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val()) == false) {
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.angabe_nicht_korrekt(), stay: false, stayTime: 4000, type: 'error' });
        jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').parent('dd').prev().click();
        return false;
    }
    if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() < jQuery().MMOS.minbreite() || jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() > jQuery().MMOS.maxbreite()) {
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.breite_min1() + jQuery().MMOS.minbreite() + jQuery().MMOS_LANG.breite_min2() + jQuery().MMOS.maxbreite() + jQuery().MMOS_LANG.breite_min3(), stay: false, stayTime: 6000, type: 'error' });
        jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').parent('dd').prev().click();
        return false;
    }

    if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() > 400 && jQuery('#options_'+jQuery().MMOS.option_nummer_hoehe()+'_text').val() > 400) {
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.keine_fertigung(), stay: false, stayTime: 6000, type: 'error' });
        jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').parent('dd').prev().click();
        return false;
    }
    if(jQuery('#options_'+jQuery().MMOS.option_nummer_breite()+'_text').val() > jQuery().MMOS.maxbreiteVolant()){
        if(jQuery('#options_'+jQuery().MMOS.option_nummer_beleuchtung()+'_'+jQuery().MMOS.option_nummer_standard_beleuchtung_ja()).is(':checked') == true || jQuery().MMOS.getVolantmass() > 0 || jQuery('#options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_ohne()).is(':checked') == false){
            jQuery.noticeAdd({ text: jQuery().MMOS_LANG.max_breite_volant_beleuchtung1()+jQuery().MMOS.maxbreiteVolant()+jQuery().MMOS_LANG.max_breite_volant_beleuchtung2(), stay: false, stayTime: 4000, type: 'error' });
            return false;
        }
    }

    //Antriebsart pruefen
    if(jQuery('#select_'+jQuery().MMOS.option_nummer_antriebsart()).val() < 1){
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.angabe_nicht_korrekt(), stay: false, stayTime: 4000, type: 'error' });
        jQuery('#select_'+jQuery().MMOS.option_nummer_antriebsart()).parent('dd').prev().click();
        return false;
    }

    //Farbe und Muster pruefen
    if(jQuery('#options_'+jQuery().MMOS.option_nummer_farbe()+'_text').val().length == 0){
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.farbe_erforderlich(), stay: false, stayTime: 4000, type: 'error' });
        jQuery('#options-'+jQuery().MMOS.option_nummer_farbe()+'-list').parent('dd').prev().click();
        return false;
    }

    //Gestellfarbe pruefen
    if(jQuery('#options-'+jQuery().MMOS.option_nummer_gestellfarbe()+'-list li input:radio:checked').size() == 0){
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.angabe_erforderlich(), stay: false, stayTime: 4000, type: 'error' });
        jQuery('#options-'+jQuery().MMOS.option_nummer_gestellfarbe()+'-list').parent('dd').prev().click();
        return false;
    }

    if(jQuery('#options-'+jQuery().MMOS.option_nummer_gestellfarbe()+'-list li input:radio:checked').val() == jQuery().MMOS.option_nummer_standard_gestellfarbe_ral_value() && jQuery('#options_'+jQuery().MMOS.option_nummer_ral()+'_text').val() == '') {
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.angabe_ral_erforderlich(), stay: false, stayTime: 4000, type: 'error' });
        jQuery('#options_'+jQuery().MMOS.option_nummer_ral()+'_text').parent('dd').prev().click();
        return false;
    }
    if(jQuery('#options_'+jQuery().MMOS.option_nummer_volanttyp()+'_'+jQuery().MMOS.option_nummer_standard_volanttyp_ohne()).is(':checked') == false && jQuery().MMOS.getVolantmass() == 0){
        jQuery.noticeAdd({ text: jQuery().MMOS_LANG.volantmass_angeben(), stay: false, stayTime: 4000, type: 'error' });
        return false;
    }

    jQuery('#mmos_preis').val(jQuery('#mmos_produktpreis').text());

    return true;
}
