//Current Scroll
var currentScroll = 0;
var currentGallery = 1;
var scrollOn = false;

//Scroll It
function scrollIt(moveDiv, moveVar) {
	//Getting Length
	var more_var = document.getElementById(moveDiv).offsetHeight;
	new_var = (0 - more_var) + 320;

	//Obj
	moveObj = $("#" + moveDiv);
	
	//Scrolling
	if (scrollOn) {
		currentScroll = currentScroll + moveVar;
	
		//Scroll Over
		if (currentScroll > 0) currentScroll = 0;
		if (currentScroll < new_var) currentScroll = new_var;
		
		//Scroll It
		moveObj.animate( { marginTop: + currentScroll + 'px'}, 80, function() {
			if (scrollOn) {
				scrollIt(moveDiv, moveVar);	
			}
		});
	} else {
		moveObj.stop();
	} 
}

//Img Animation
function img_animate(c) {
	//$('#viewport_img').animate( { left: '0px', top: '0px', width: '400px'}, 2000);
	
	$('#viewport_img').css( { left: '0px', top: '0px', width: '400px' } );
}

//Main Script
$(document).ready(
	function(){
		//Getting Overflow of Text
		if ($('#content_text_inner').length) {
			//Getting Length
			var more_var = document.getElementById("content_text_inner").offsetHeight;
			
			//Show Scroll or Not
			if (more_var > 360) {
				document.getElementById("arrow_box").style.display = "block";
			}		

		}
				
			
		//Scroll Right
		$('.gallery_next').mousedown(
			function() {
				var gallery_total = $('.gallery_block').size();
				
				galleryTotal = 465 * (gallery_total - 2);
				
				if (galleryTotal < 0) {
					gallertyTotal = 0;
				}
				
				$('#gallery_inner').stop().animate( {left:'-' + galleryTotal + 'px'} , 2000);
			}						 
		)
		
		$('.gallery_next').mouseup(
			function() { $('#gallery_inner').stop(); }						  
		)
		
		//Scroll Left
		$('.gallery_prev').mousedown(
			function() { $('#gallery_inner').stop().animate( {left: '0px'} , 2000); }						  
		)
		
		$('.gallery_prev').mouseup(
			function() { $('#gallery_inner').stop(); }						  
		)

		
		
		//Scroller
		$("#scroll_down").mousedown(
			function() {
				scrollOn = true;
				scrollIt("content_text_inner", -50)
			}
		).mouseup(
			function() {
				scrollOn = false;
			}
		)
		
		$("#scroll_up").mousedown(
			function() {
				scrollOn = true;
				scrollIt("content_text_inner", 50)
			}
		).mouseup(
			function() {
				scrollOn = false;
			}
		)
	}
);


/*

//Scroll Right
		$('.gallery_next').click(
			function() {
				var gallery_total = $('.gallery_block').size();
				
				currentGallery = currentGallery + 1;
				
				if (currentGallery >= (gallery_total - 1)) {
					currentGallery = gallery_total - 1;
				}	
				
				moveGallery = 0 - (465 * (currentGallery - 1));
				
				$('#gallery_inner').stop().animate( {left: moveGallery + 'px'} , 500);
			}						 
		)
		
		//Scroll Left
		$('.gallery_prev').click (
			function() {
				var gallery_total = $('.gallery_block').size();
				
				currentGallery = currentGallery - 1;
				
				if (currentGallery <= 0) {
					currentGallery = 1;
				}
				
				moveGallery = 0 - (465 * (currentGallery - 1));
				
				$('#gallery_inner').stop().animate( {left: moveGallery + 'px'} , 500);
			}						  
		)
		
*/


