jQuery(document).ready(function(){	
	jQuery('.scroll-actions').css('display','block');
	jQuery('.scroll-actions a').click(function(){
		
		var parent = jQuery(this).parent().prev();
		
		var parentContanier = parent.parent();
		
		var movable = jQuery(parent).children();
		
		var height_org = parseInt(jQuery(parent).height());
		var margin = parseInt(jQuery(movable[0]).css('marginTop'));
		var direction = '+';
		if( jQuery(this).hasClass('prevPage') && margin == 0  ){
			return false;
		} else if( jQuery(this).hasClass('prevPage')){
			height = height_org + margin;
			if( height >= 0 ){
				jQuery(this).addClass('disabled');
			} else {
				jQuery(this).removeClass('disabled');
			}
			
			//check the total height.
			if( jQuery(movable[0]).height() > ((height * -1) + height_org) ){
				jQuery(this).next().removeClass('disabled');
			}			
			
		} else {
			height = (height_org - margin)*-1;
			if( height < 0 ){
				jQuery(this).prev().removeClass('disabled');
			} else {
				jQuery(this).prev().addClass('disabled');
			}
			
			//check the total height.
			if( jQuery(movable[0]).height() <= ((height * -1) + height_org) ){
				jQuery(this).addClass('disabled');
			}
			
		}
		if( jQuery(parentContanier).hasClass('multi') ){
			if( jQuery(parentContanier).hasClass('style_game') ){
				var type = 'style_game';
			} else if( jQuery(parentContanier).hasClass('style_audio') ){
				var type = 'style_audio';
			} else if( jQuery(parentContanier).hasClass('style_video') ){
				var type = 'style_video';
			}
			var new_title_index = ((height * -1)/height_org);
			
			var title = window.eval(type+"_title_"+new_title_index);
			var link = window.eval(type+"_link_"+new_title_index);
			var parentContanier_id = jQuery(parentContanier).attr('id');
			
			jQuery('#'+parentContanier_id+' h2 a').html(title);
			jQuery('#'+parentContanier_id+' h2 a').attr('href',link);
		}
		jQuery(movable[0]).animate({marginTop: height},300);

	});
	
});
