$(document).ready(function() {

            

     $(function() {

            $('#show img').each(function() {

                $(this).hover(

                    function() {

                        $(this).stop().animate({ opacity: 1.0 }, 800);

                    },

                   function() {

                       $(this).stop().animate({ opacity: 0.3 }, 800);

                   })

                });

        });

 }); 

     $(document).ready(function() {
    $('body').click(function() {$('.values:visible').hide() } );
    $(".customSelect").hide();
    $(".customSelect").next().css ('display','block');
    $(".select").each(function (){
    var a=$(this).prev();
    $(a).addClass('currentselect');
    $(this).html($('.currentselect :selected').text());
    $(a).removeClass('currentselect');
    
    });
    $(".customSelect").each(function (){
    var selectvalue=$(this).val();
    $(this).find("option").each(function () {var pointer=$(this).parent().next();pointer.next().append("<a href='#1' rel='"+$(this).attr('rel')+"' value="+$(this).val()+">"+$(this).text()+"</a>")
    });
    $(".values a").click(function () { $(this).parent().prev().html($(this).html());$(this).parent().hide();
    var a=$(this).parent().prev().prev();
    $(a).addClass('currentselect');
    var currentvalue=$(this).attr('value');
    if($(this).attr('rel') !='' && $(a).attr('id') == 'colorSelect') {
                rels = $(this).attr('rel').split(',');
                $('.productImage-'+rels[1]).attr('src',rels[0]);
                $('.productImageLink-'+rels[1]).attr('href',rels[0]);
                document.getElementById('catalog_num-'+rels[1]).value = rels[2];
                document.getElementById('product_name-'+rels[1]).value = rels[3];
                document.getElementById('number-'+rels[1]).innerHTML = rels[2];
                document.getElementById('title-'+rels[1]).innerHTML = rels[3];
    }
    if($(this).attr('rel') !='' && $(a).attr('id') == 'sizeSelect') {
                rels = $(this).attr('rel').split(',');
                document.getElementById('product_preice-'+rels[0]).innerHTML = rels[1]+'лв.';
                document.getElementById('product_preice_input-'+rels[0]).value = rels[1];
                
    }
    //$(".currentselect option[value='"+currentvalue+"']").attr('selected', 'selected');
    $(a).val(currentvalue);
    $(a).removeClass('currentselect');
    });
    $(".select").click(function(event){
    $(".values").hide();
    var position = $(this).position();
    $(this).next().css('left',position.left+3);
    $(this).next().css('top',position.top+$(this).height());
    $(this).next().show();
    event.stopPropagation();
    });
    });
    });








