/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
scroll_top_text = function(val) {
  elem = $('scrollContainer');
  elem_up = $('writtingContent');
  elem_height = elem.getHeight();
  value_to_up = elem_up.getHeight() - 120;
  current_top = parseInt(elem.getStyle('marginTop'));
  //alert(elem_up.getHeight())
  if(elem.getHeight() > elem_up.getHeight()-100){
      if(isNaN(current_top)) {
                    current_top = 0;
            }
            if(val == 0){
              new_margin = current_top - value_to_up;
            }else{
              new_margin = current_top - val;
            }

            max_margin = -(elem_height - value_to_up);

            if(new_margin < max_margin){
              new_margin = max_margin;
            }
            elem.morph({marginTop : new_margin + 'px'});
       if(new_margin == max_margin) {
          $('navBottom').addClassName('unActive');
			 $('navTop').removeClassName('unActive');
       }else{
          $('navBottom').removeClassName('unActive');
          $('navTop').removeClassName('unActive');
       }
  }
}

scroll_bottom_text = function(val) {
  elem = $('scrollContainer');
  elem_up = $('writtingContent');
  elem_height = elem.getHeight();
  value_to_up = elem_up.getHeight() - 120;
  current_top = parseInt(elem.getStyle('marginTop'));
  if(elem.getHeight() > elem_up.getHeight()-100){
      if(isNaN(current_top)) {
                    current_top = 0;
            }
            if(val == 0){
              new_margin = current_top + value_to_up;
            }else{
              new_margin = current_top + val;
            }

            if(new_margin > 0){
              new_margin = 0;
            }
            elem.morph({marginTop : new_margin + 'px'});
        if(new_margin == 0) {
          $('navTop').addClassName('unActive');
          $('navBottom').removeClassName('unActive');
       }else{
          $('navTop').removeClassName('unActive');
          $('navBottom').removeClassName('unActive');
       }
  }
}


scroll_facebook = function(elem) {
      current_left = parseInt(elem.getStyle('right'));
      if(current_left == 0){
          new Effect.Morph(elem, {
              style: 'right: -205px', // CSS Properties
              duration: 0.8 // Core Effect properties
          });
      }else{
          new Effect.Morph(elem, {
              style: 'right: 0px', // CSS Properties
              duration: 0.8 // Core Effect properties
          });
      }
}


init_button_to_slide = function() {
	elem = $('scrollContainer');
        elem_up = $('writtingContent');
	if(!elem)
		return;
	if(!elem_up)
		return;

	elem_height = elem.getHeight();
	elem_up_height = elem_up.getHeight();
	elem.setStyle({
	  width: elem_up.getWidth()+"px"
	});
	if(elem_height > elem_up_height){
            $('navBottom').style.dispaly = "bolck";
            $('navTop').style.dispaly = "bolck";
	}else{
            $('navBottom').style.dispaly = "none";
            $('navTop').style.dispaly = "none";
	}
}





Object.extend(Event, {
        wheel:function (event){
        var delta = 0;
        if (event.wheelDelta) {
			delta = event.wheelDelta/120;
			if (window.opera) delta = -delta;
        } else if (event.detail) {
            delta = -event.detail/3;
        }
		if(navigator.userAgent.indexOf('Mac') != -1) delta = -delta;
		  return Math.round(delta);
	  }
});


 wheelwheel = function(eve){
               if($('scrollContainer').getHeight() > 590){
                 delta = Event.wheel(eve);
                      if(delta>0){
                        scroll_bottom_text(300);
                      }else{
                        scroll_top_text(300);
                      }
               }
       }



