function open_flash(url,w,h,promo,aluID){
    block = true;
    var win = window.open('/flash_3d.php?dest=' + url + '&w=' + w + '&h=' + h + '&promo=' + promo + '&aluID=' + aluID,'3D_Felgen','scrollbars=no,resizable=yes,width=' + w + ',height=' + h);
    win.focus();
    return false;
}
function advanced(element) {
    if (jQuery(element).parent().nextAll('div').is(":hidden")) {
        jQuery(element).parent().nextAll('div').slideDown('fast');
        jQuery(element).addClass('more-options-shown');
        jQuery('input[name=\'showAdvSearch\']').val(1);
    } else {
        jQuery(element).parent().nextAll('div').slideUp('fast');
        jQuery(element).removeClass('more-options-shown');
        jQuery('input[name=\'showAdvSearch\']').val(0);
    }
}

function toggleCarInfo(element) {
    if (jQuery(element).parent().nextAll('div').is(":hidden")) {
        jQuery(element).parent().nextAll('div').slideDown('fast');
        jQuery(element).addClass('more-options-shown');
    } else {
        jQuery(element).parent().nextAll('div').slideUp('fast');
        jQuery(element).removeClass('more-options-shown');
    }
}

jQuery(document).ready(function(){
    jQuery('#wheelConnectProfi').change(function(){
        this.form.c.value = '1';
        this.form.rdm.selectedIndex = 0;
        this.form.rh.selectedIndex = 0;
        this.form.rt.selectedIndex = 0;
        this.form.submit();
        ShowWait(1);
    });
    jQuery('#diameterProfi').change(function(){
        this.form.c.value = '2';
        this.form.rh.selectedIndex = 0;
        this.form.rt.selectedIndex = 0;
        this.form.submit();
        ShowWait(1);
    });
    jQuery('#alloyCreatorProfi').change(function(){
        this.form.c.value = '3';
        this.form.rt.selectedIndex = 0;
        this.form.submit();
        ShowWait(1);
    });
    jQuery('#alloyTypeProfi').change(function(){
        this.form.submit();
        ShowWait(1);
    });

    jQuery('#diameter').change(function(){
        this.form.c.value = '2';
        this.form.rh.selectedIndex = 0;
        this.form.rt.selectedIndex = 0;
        this.form.submit();
        ShowWait(1);
    });
    jQuery('#alloyCreator').change(function(){
        this.form.c.value = '3';
        this.form.rt.selectedIndex = 0;
        this.form.submit();
        ShowWait(1);
    });
    jQuery('#alloyType').change(function(){
        this.form.submit();
        ShowWait(1);
    });
    jQuery('#expertAdvice').bind('click', function() {
        tb_show('', jQuery(this).attr('href')+'&popup=1');
        return false;
    });

    if (jQuery('a.details-button-info').length) {
        jQuery('a.details-button-info').bubble();
    }

    // bind events to input fields
    jQuery('#profi-search-input').children('input').bind('focus', function(e) {
        jQuery(this).addClass('input-focus');
    }).bind('blur', function(e) {
        jQuery(this).removeClass('input-focus');
    });

    // bind events to captcha input fields
    jQuery('#captcha-input').children('input').bind('focus', function(e) {
        jQuery(this).addClass('input-focus');
    }).bind('blur', function(e) {
        jQuery(this).removeClass('input-focus');
    });

    jQuery('#profi-search-input').children('input:eq(0)').focus();

    jQuery('#select-search-1').bind('change', function(e) {
        jQuery('#select-search-2').val(0);
        jQuery('#select-search-3').val(0);
        jQuery('#select-search-4').val(0);
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });
    jQuery('#select-search-2').bind('change', function(e){
        jQuery('#select-search-3').val(0);
        jQuery('#select-search-4').val(0);
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });
    jQuery('#select-search-3').bind('change', function(e) {
        jQuery('#select-search-4').val(0);
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });
    jQuery('#select-search-4').bind('change', function(e) {
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });

    jQuery('#select-search-5').bind('change', function(e) {
        jQuery('#select-search-6').val(0);
        jQuery('#select-search-7').val(0);
        jQuery('#select-search-8').val(0);
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });
    jQuery('#select-search-6').bind('change', function(e) {
        jQuery('#select-search-7').val(0);
        jQuery('#select-search-8').val(0);
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });
    jQuery('#select-search-7').bind('change', function(e) {
        jQuery('#select-search-8').val(0);
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });
    jQuery('#select-search-8').bind('change', function(e) {
        jQuery('body').css('cursor', 'wait');
        jQuery('#wait_block').css('display','block');
        jQuery('body').css('cursor', 'wait');
        jQuery('form').submit();
        showLoadingImage();
    });

    // search results mouseover and mouse click effects
    jQuery('.result-row').bind('mouseover', function(e) {
        jQuery(this).addClass('mouse-over');
    }).bind('mouseout', function(e) {
        jQuery(this).removeClass('mouse-over');
    }).bind('click', function(e) {
        jQuery('#TB_overlay').css('background', 'none');
        //tb_show('', jQuery(this).find('a').attr('href')+'&popup=1');
        window.location.href = jQuery(this).find('a').attr('href');
        //if i need a backgroundpic then set after the tb_show the background with opacity
        jQuery('#TB_overlay').css('background', 'url(/assets/images/stripe.png)');
        jQuery('#TB_overlay').fadeTo(50, 0.95);
        return false;
    }).find('a').bind('click', function(e) {
        //tb_show('', jQuery(this).attr('href')+'&offer=1&popup=1');
        window.location.href = jQuery(this).attr('href')+'&offer=1';
        jQuery('#TB_overlay').css('background', 'url(/assets/images/stripe.png)');
        jQuery('#TB_overlay').fadeTo(50, 0.95);
        return false;
    });

    // info overlib
    jQuery('.result-info').bubble();

    // availability overlib 
    jQuery('.result-text').bubble();
    
    jQuery('#useProfi').bind('click', function(){
        jQuery('#guiValue').val('old');
        jQuery('#search_new').hide();
        jQuery('#search_old').show();
        this.form.fh.selectedIndex = 0;
        this.form.ftt.selectedIndex = 0;
        return false;
    });
    jQuery('#useComfor').bind('click', function(){
        jQuery('#guiValue').val('new');
        jQuery('#search_old').hide();
        jQuery('#search_new').show();
        return false;
    });
});

