$(function() {
    var $bodyTag = $('body');
    
    //$('body').prepend('Jquery loaded.. comment line in /js/main.js');
    $('.drawing-row, .simple')
    .mouseover(function(){
      $(this).addClass('mouseover').find('td > form[enctype="multipart/form-data"]').removeClass('opacity20');
    }).mouseout(function(){
      $(this).removeClass('mouseover').find('td > form[enctype="multipart/form-data"]').addClass('opacity20');
    });
    
    //hints
    $('.hint').before('<a class="showHint" href="#"><img src="/uzzime/images/q.png" alt="?"/></a>')
    .mouseout(function(){ $(this).hide();  }); //close on mouseout
    //$('.hint').show();
    var hintParents = 'h1, h2, h3, h4, h5, h6, div, p, center';
    $('.showHint').click(
        function(){
            $this = $(this);
            if($this.data('visible') != 'true')
            {
               $this.data('visible','true')
                  .parent(hintParents).find('.hint').slideDown('fast');
   //            $this.addClass('opacity40');
            }
            else {
               $this.data('visible','false')
                  .parent(hintParents).find('.hint').hide();
            }
            return false;
        }
    );
 
   $('#loggedbar')
    .mouseover(function(){
      $(this).removeClass('opacity60').addClass('opacity90');
    }).mouseout(function(){
      $(this).removeClass('opacity90').addClass('opacity60');
    });
   

   $('.bt_additional').toggle(
      function() {
         $(this).addClass('opened');
         $('#additional_options').show();
         scrollTo('#additional_options');

      },
      function() {
         $(this).removeClass('opened');
         $('#additional_options').hide();
      }
   );

    function scrollTo(selector) {
        var targetOffset = $(selector).offset().top;
        $('html,body').animate({scrollTop: targetOffset}, 500);
    }

    
    $('ul.tabs > li > a').click(function(){
        $('.tabs > li > a').removeClass('active'); //clear formatting
        
        $this = $(this).addClass('active');
        var showThisID = $this.attr('href');
        $('.tab').hide();
        $(showThisID).show();
        $(showThisID+' input:first').focus();
        
        return false;
    });
    
    $('input[name$=Date\]]').datepicker({
        //appendText: ' <a href="#">2 weeks</a> ',
        minDate: '+2d',
        dateFormat: 'yy-mm-dd',
        onSelect: function(dateText, inst) {
            $this = $(this);
            $now = new Date();
            $this.val($this.val() + ' ' + $now.getHours() + ':00:00');
        }

    })
    .addClass('datePicker'); //cla

});