// JavaScript Document
$(document).ready(function(){
	 var $new_right;
	 var $new_left;
	 $('#news_content')
		.animate({
			scrollTop:0
		});	
		
	$('.arrow_down_news').click(function(){
		$('#news_content')
			.animate({
				scrollTop:"+="+300
			},'slow');	
	});
	$('.arrow_up_news').click(function(){
		$('#news_content')
			.animate({
				scrollTop:"-="+300
			},'slow');	
	});
	
	
	
	//homepage slider
	slider = $('.slider_post');
	$('.slider_holder').width(slider.length*slider.width());
	var width_limit = (slider.length*slider.width()-slider.width());
	
	$('.slider_content').animate({
												scrollLeft:0
											},'slow',function(){
												if($('.slider_content').attr('id') != 'no_timer'){
												$new_right = setInterval(s_right,5000);
												}
											});
	$('.left_arrow_p').click(function(){
		$('.slider_content').animate({
													scrollLeft:"-="+500
												},'fast',function(){
												if($('.slider_content').attr('id') != 'no_timer'){
													clearInterval($new_right);
													$new_left = setInterval(s_right,5000);
												}
												});
	});
	
	$('.right_arrow_p').click(function(){									 
			if($('.slider_content').scrollLeft() >= width_limit){
			$('.slider_content').animate({
														scrollLeft:0
													},'fast',function(){if($('.slider_content').attr('id') != 'no_timer'){
													clearInterval($new_right);
													$new_right = setInterval(s_right,5000);
												}});
			}else{
		$('.slider_content').animate({
													scrollLeft:"+="+500
												},'fast',function(){
												if($('.slider_content').attr('id') != 'no_timer'){
													clearInterval($new_right);
													$new_right = setInterval(s_right,5000);
												}
												});
			}
			
	});
	
	
	function s_right(){
			if($('.slider_content').scrollLeft() >= width_limit){
			$('.slider_content').animate({
														scrollLeft:0
													});
			}else{
			$('.slider_content').animate({
														scrollLeft:"+="+500
													});
			}
	}
	
			$('#over_f').animate({
											scrollLeft:0
										});
	function s_left(){
			$('.slider_content').animate({
														scrollLeft:"-="+500
													});
	}
	
	$('.gallery_arrow_left').click(function(){
			$('#over_f').animate({
											scrollLeft:"-="+85
										});
	});
	$('.gallery_arrow_right').click(function(){
			$('#over_f').animate({
											scrollLeft:"+="+85
										});
	});
});
