$(document).ready(
  function() {
    $('.my-skinnable-select').each(
      function(i) {
        selectContainer = $(this);
        // Remove the class for non JS browsers
        selectContainer.removeClass('my-skinnable-select');
        // Add the class for JS Browers
        selectContainer.addClass('skinned-select');
        // Find the select box
        selectContainer.children("select").before('<div class="select-text">a</div>').each(
          function() {


           // $(this).prev().text(this.options[0].innerHTML)

            var currentSelected = $(this).find(':selected');
          
            $(this).prev().text(currentSelected.text());
          }
        );
        // Store the parent object
        var parentTextObj = selectContainer.children().prev();
        // As we click on the options

        selectContainer.children().click(function() {
          // Set the value of the html
          //parentTextObj.text(this.options[this.selectedIndex].text);

          var currentSelected = $(this).find(':selected');
          parentTextObj.text(currentSelected.text());
        });
        selectContainer.children().change(function() {
          // Set the value of the html
          //parentTextObj.text(this.options[this.selectedIndex].text);

          var currentSelected = $(this).find(':selected');
          parentTextObj.text(currentSelected.text());
        });
        
        
      }
    );

      



        


        $('.image_mini').click(function() {
          // select w boxie
          var rodzic = $(this).parent().attr('id');

          var toten = $('#'+rodzic+' .select_container .skinned-select select');

          //var test = $(toten).attr("selectedText");      //options[toten.selectedIndex];
         
          var currentSelected = $(toten).find(':selected').text();
    

          $('#'+rodzic+' .select-text').text(currentSelected);
        })







  }
);


