$("document").ready(function(){
    
    /*
    *
    * Select Box Handling for location switch
    *
    */
    $('.local').mouseover(function(){
        $(this).css('font-weight', 'bold');
    });
    $('.local').mouseout(function(){
        $(this).css('font-weight', 'normal');
    });
    
    //Text of select show as value on top of the select box
    $('.local').click(function(){
        $('.local_select_label').text($(this).text());
    });
    
    
    $('.local_select').mouseover(function(){
        //$('.local_select_submit').css('backgroundImage', 'url("/fileadmin/template/main_template/img/button/region_arrow_act.png")');
        $('.local_select_submit').addClass('open_box');
        $('.local_select_submit').removeClass('close_box');
    });
    
    $('.local_select').mouseout(function(){
        //$('.local_select_submit').css('backgroundImage', 'url("/fileadmin/template/main_template/img/button/region_arrow.png")');
        $('.local_select_submit').addClass('close_box');
        $('.local_select_submit').removeClass('open_box');
    });
    //$('.local_select_submit').css('backgroundImage', 'url("/fileadmin/template/main_template/img/button/region_arrow.png")');
    $('.local_select_submit').addClass('close_box');
    
    
    /*****************
    *                *
    *  NOT LOCATION  *
    *                *
    ******************/
    /*
    *
    * Searchform in header
    *
    */
    $('#nav_top .tx-indexedsearch-searchbox-button').mouseover(function(){
        $(this).css('backgroundImage', 'url("/fileadmin/template/main_template/img/button/search_button_act.png")');
    });
    $('#nav_top .tx-indexedsearch-searchbox-button').mouseout(function(){
        $(this).css('backgroundImage', 'url("/fileadmin/template/main_template/img/button/search_button.png")');
    });
    
    $('.tx-indexedsearch-searchbox p:last').hide();
    
    
    /**************/
    /**  ECARDS  **/
    /**************
    $('#tx_srsendcard_pi1_card_title').keyup(function(){
      value = $(this).val();
      len = value.length;
      
      if(len >30){
        alert('too much');
      }
    });
   */ 
    
    $('#tx_srsendcard_pi1_card_title').keyup(function(){
        var max = parseInt($(this).attr('maxlength'));
        if($(this).val().length > max){
            $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
        }
    });
    $('#tx_srsendcard_pi1_card_message').keyup(function(){
        var max = parseInt($(this).attr('maxlength'));
        if($(this).val().length > max){
            $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
        }
    });
    $('#tx_srsendcard_pi1_card_signature').keyup(function(){
        var max = parseInt($(this).attr('maxlength'));
        if($(this).val().length > max){
            $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
        }
    });
    
    
   //indexed search - hide label
   $('.tx-indexedsearch-searchbox table tbody tr td:first-child').hide();
    
});




//Shows the Select Box with locations
function showList() {
  $(".local_box").css("display", "block");
  $(".local_select").css({
                      backgroundColor: 'white',
                      borderLeft: '1px solid #CCCCCC',
                      borderRight: '1px solid #CCCCCC',
                      borderTop: '1px solid #CCCCCC',
                      borderBottom: 'none'
                    });
  $(".local_select_label").css({
                      color: '#999999'
                    });
}

//Hide the Select Box with locations
function hideList() {
  $(".local_box").css("display", "none"); //none
  $(".local_select").css({
                      backgroundColor: 'white',
                      border: '1px solid #CCCCCC'
                    });
  $(".local_select_label").css({
                      color: '#4D4D4D'
                    });
}





