$(document).ready(function() {
	
	$('.view_more_jer').click(function() {
		location.href = site_url + '/?page=work';
	});

	$('.scroll_content').each(function() {
		var top_arrow = "<div class='top_arrow' style='opacity:0.6;display:none' state='hidden'><img src='"+site_url+"/images/top.gif' /></div>";
		var bottom_arrow = "<div class='bottom_arrow' style='opacity:0.6;display:block' state='hidden'><img src='"+site_url+"/images/down.gif' /></div>";
		html = "<div class='text' onfocus='blur()'>" + $(this).html() + "</div>";
		$(this).html(top_arrow + html + bottom_arrow);
		$(this).attr('top', 0);
		$(this).attr('height', $(this).height());

		$(this).parent().mousemove(function(event) {
			var current_pos = event.pageY-$(this).offset().top;
			var midpoint = Math.round(115/2);
			if (current_pos && midpoint) {
				if (current_pos >= midpoint) {
					var next_top = parseInt($(this).parent().find('.text').css('top')) - 115;	
					var next_height = 115 - $(this).parent().find('.text').height();
					if (next_top > next_height) {
						var arrow = $(this).find('.bottom_arrow');
						$(this).find('.top_arrow').attr('state', 'hidden');
						$(this).find('.top_arrow').hide();
						if ($(arrow).attr('state') == 'hidden')	{
							$(arrow).attr('state', 'visible');
							$(arrow).fadeIn('fast');		
						}
					}
				}
				else {
					var next_top = parseInt($(this).parent().find('.text').css('top')) + 115;	
					if (next_top < 0) {
						var arrow = $(this).find('.top_arrow');
						$(this).find('.bottom_arrow').hide();
						$(this).find('.bottom_arrow').attr('state', 'hidden');
						if ($(arrow).attr('state') == 'hidden')	{
							$(arrow).attr('state', 'visible');
							$(arrow).fadeIn('fast');
						}
					}
				}
			}

		});
		$(this).find('.top_arrow').mouseover(function() {
				$(this).attr('opacity', $(this).css('opacity'));
				$(this).animate({opacity:0.8}, 500);

				if ($(this).parent().attr('top') < 0) {
					$(this).parent().css('margin-top', '-10');
				}
		});
		$(this).find('.top_arrow').mouseout(function() {
			var op =$(this).attr('opacity');
			$(this).animate({opacity:op}, 500);
		});
		$(this).find('.bottom_arrow').mouseover(function() {
				$(this).attr('opacity', $(this).css('opacity'));
				$(this).animate({opacity:0.8}, 500);

		});
		$(this).find('.bottom_arrow').mouseout(function() {
			var op =$(this).attr('opacity');
			$(this).animate({opacity:op}, 500);
		});

		$(this).find('.bottom_arrow').click(function() {
			var next_top = parseInt($(this).parent().find('.text').css('top')) - 115;
			var next_height = 115 - $(this).parent().find('.text').height();
			if (next_top > next_height) {
				$(this).parent().find('.text').animate({'top': next_top}, 400);
			}
			else {
				$(this).parent().find('.text').animate({'top': next_height}, 400);
				$(this).hide();
				$(this).parent().find('.top_arrow').fadeIn();
			}

		});
		
		$(this).find('.top_arrow').click(function() {
				var next_top = parseInt($(this).parent().find('.text').css('top')) + 115;

				if (next_top < 0) {
					$(this).parent().find('.text').animate({'top': next_top}, 400);
				}
				else {
					$(this).parent().find('.text').animate({'top': 0}, 400);
					$(this).hide();
					$(this).parent().find('.bottom_arrow').fadeIn();
				}
		});

	});

	
	
	
});
