$(document).ready(function() {
  initSmallScript = function() {
    $('#scrollable').mousewheel(function(e, delta) {
      makeScroll(delta);
      return false;
   })

    makeScroll = function(delta) {
      if (!$('#scrollable_container:animated').length) {
        var top = parseInt($('#scrollable_container').css('top'));
        var height = $('#scrollable_container').height();
        var s_height = $('#scrollable').height();
        var new_top = top + (delta * 60);
        if ((-new_top < height - s_height) && new_top <= 0) {
          $('#scrollable_container').animate({top: new_top + 'px'})
        } else
        if ((s_height + new_top) <= 60 && delta == -1) {
          var new_top = -(height - s_height);
          $('#scrollable_container').animate({top: new_top + 'px'})
        } else
        if ((new_top) <= 60 && delta == 1) {
          var new_top = 0;
          $('#scrollable_container').animate({top: new_top + 'px'})
        }
      }
    }

    scrollLayerUp = function() {
      makeScroll(1);
    }

    scrollLayerDown = function() {
      makeScroll(-1);
    }

    $('.up').mousehold(scrollLayerUp);
    $('.down').mousehold(scrollLayerDown);

     $("#showShort").click(function(){
       showShort();
       return false;
     });
     $("#showShort_title").click(function(){
       showShort();
       return false;
     });


     $("#showLarge").click(function(){
       showLarge();
       return false;
     });
     $("#showLarge_title").click(function(){
       showLarge();
       return false;
     });


     $.fn.searchform = function(option) {

      sformFocus = function() {
        if ($(this).val() == option['fraze']) {
          $(this).val('');
        }
      }

      sformBlur = function() {
        if (!$(this).val()) {
          $(this).val(option['fraze']);
        }
      }

      $(this).focus(sformFocus);
      $(this).blur(sformBlur);
    }
  }
  initSmallScript();
});

function showShort() {
  $('#scrollable').hide();//.animate({     opacity: "hide" }, "fast");
  $('#showShort_body').show();//.animate({ opacity: "show" }, "fast");
  $('#scrollRules').hide();

  $('#showShort_title').addClass('font_color_attr_red');
  $('#showLarge_title').removeClass('font_color_attr_red');
  $('#showShort_title').removeClass('font_color_attr_lightgrey');
  $('#showLarge_title').addClass('font_color_attr_lightgrey');
	 
}

function showLarge() {
  $('#showShort_body').hide();//.animate({ opacity: "hide" }, "fast");
  $('#scrollable').show();//.animate({     opacity: "show" }, "fast");
  $('#scrollRules').show();

  $('#showShort_title').removeClass('font_color_attr_red');
  $('#showLarge_title').addClass('font_color_attr_red');
  $('#showShort_title').addClass('font_color_attr_lightgrey');
  $('#showLarge_title').removeClass('font_color_attr_lightgrey');
}
