$(document).ready(function(){

    $('input.submit').val('');

    // Top Bax Boxen
    $('div#top_bar input#produktsuche').val('Suchbegriff oder Bestell-Nr.');
    $('div#top_bar input#username').val('Benutzername');
    
    //newPwField = $('div#top_bar input#password').clone();
    //newPwField.attr('type', 'text').val('Passwort');
    newPwField = $('<input type="text" value="Passwort" class="text" name="lgn_pwd"></input>');
    $('div#top_bar input#password').after(newPwField).remove();
    newPwField.attr('id', 'password');
    
    $('div#top_bar input.text').focus(function(){
        if(!$(this).hasClass('changed'))
        {
            if($(this).attr('id') == 'password')
            {
                //newPwField = $(this).clone();
                newPwField = $('<input type="password" value="" class="text changed" name="lgn_pwd"></input>');
                    
                $(this).after(newPwField).remove();   
                newPwField.attr('id', 'password');
                newPwField.focus();            
            }
            else{
                $(this).val('').addClass('changed');
            }
        }
    })
   
   
    if($('body#mein_konto').length > 0)
    {
        if($('form#orderform').length > 0)
        {
            $('form#orderform').submit(function(){
                if($('input#oxuser__over18').attr('checked') == false)
                {
                    alert('Sie müßen bestätigen dass Sie volljährig sind!');
                    return false;
                }
            })
        };
    }
    
    if($('body#partner').length > 0)
    {
        $('div.basket_details .col img').each(function(){
            if($(this).width() > $(this).parent('a').width())
            {
                $(this).width($(this).parent('a').width());
            }
        });
        
        var m_height = 0;
        
         $('div.basket_details .col p.title').each(function(){
            if($(this).height() > m_height)
            {
                m_height = $(this).height();
            }
         }).height(m_height);
    }
   
    // Boxen auf gleiche Höhe
    if($('div.box_halb').length > 1)
    {
        $('.box_halb:even').each(function(){
            if($(this).height() > $(this).next().height())
            {
                $(this).next().height($(this).height());
            }
            else if($(this).height() < $(this).next().height())
            {
                $(this).height($(this).next().height());
            }
        });
    }
    
    if($('div.box_drittel').length > 1)
    {
        var mheight = 0;
        
        $('div.box_drittel').each(function(){
            if($(this).height() > mheight)
            {
                mheight = $(this).height();
            }
        });
        
        $('div.box_drittel').height(mheight);
    }
    
    if($('body#empfehlung_des_monats').length > 0)
    {
        $('div.article:even').each(function(){
            if($(this).height() > $(this).next().height())
            {
                $(this).next().height($(this).height());
            }
            else if($(this).height() < $(this).next().height())
            {
                $(this).height($(this).next().height());
            }
        });    
    }
    
    $('select.input_artikel_pro_seite').change(function(e){
        window.location.href = e.target.value;
    });
    
    $('div.msg').delay(2500).fadeOut('slow', function(){$(this).remove()});
    
    $('input.input_basket.remove').click(function(){
        $(this).parents('td').find('input.amount').val('0');
    });

    $('#reset_filter').click(function() {
      $(this).parents("form").find("select").each(function() {
        $(this).children("option:first").attr("selected", true);
      });
      $(this).parents("form").submit();
      return false;
    });
});
