// JavaScript Document
var gogo = false;

$('document').ready(function(){
	//we are in the begining
	$('a.scroll_prev').css('display','none');
	//set default width
	$totalDiv = $('div.scroll_container div.scroll_items div.scroll_item').size();
	
	$totalWidth = $totalDiv * 340;
	$endLeft = $totalWidth - 340;
	$endLeft2 = $endLeft - 340;
	if($totalWidth == 340){
		$('a.scroll_next').css('display','none');
	}
	$('div.scroll_container div.scroll_items').css('width',$totalWidth+'px');

	$('a.scroll_next').click(function(){
		//alert('aaaaa');
		$currentLeft = $('div.scroll_container div.scroll_items').css('left');
		//move
		//if left == end
		$enddLeft = parseInt('-'+$endLeft2);

		if($enddLeft+'px' == $currentLeft){
			//we are in the end
			$('a.scroll_next').css('display','none');
		}
		$finishedLeft = $totalWidth - 340;
		if($currentLeft != parseInt('-'+$finishedLeft)){
			$newLeft = parseInt($currentLeft) - 340;
			//stop any queued animation
			$('div.scroll_container div.scroll_items').stop(true,true);
		
			//do animation
			
			$('div.scroll_container div.scroll_items').animate({'left':$newLeft});
			
			
			$('div.scroll_container div.scroll_item').css('z-index',300);
			
			// we are no longer in the begin
			$('a.scroll_prev').css('display','block');					
			
		}
		return false;
		
	});
	
	$('a.scroll_prev').click(function(){
							   
		$currentLeft = $('div.scroll_container div.scroll_items').css('left');
		//move
		//if left == end

		if($currentLeft == '-340px'){
			//we are in the begin
			$('a.scroll_prev').css('display','none');
		}
		if($currentLeft != '0px'){
			$newLeft = parseInt($currentLeft) + 340;
			//stop any queued animation
			$('div.scroll_container div.scroll_items').stop(true,true);
		
			//do animation
			$('div.scroll_container div.scroll_items').animate({'left':$newLeft});
			
			$('div.scroll_container div.scroll_item').css('z-index',300);
			// we are no longer in the end
			$('a.scroll_next').css('display','block');
			
			
		}
		return false;
	
	});	
	
	
	var top;
	var fleft;
	
	$('div.scroll_container div.scroll_items div.scroll_item IMG.main').hover(function(){
		var top = ($(this).parent().offset().top + 30) + 'px';
		
		
		$left = $(this).parent().offset().left ;
		var fleft = ($left - 500) + 'px';
		$('#content #bigPhoto').css('top',top);
		$('#content #bigPhoto').css('left',fleft);
		
		$('#bigPhoto img').remove();
		$('#content #bigPhoto').append('<img src="'+$(this).parent().find('img.old').attr('src')+'"   />');
		$('#content #bigPhoto').css('display','block');
		
	},function(e){
			
			//$('#bigPhoto img').remove();
			$('#content #bigPhoto').css('display','none');
		
	});
	
	$('#bigPhoto').hover(function(){
		$('#content #bigPhoto').css('display','block');
	},function(){
		$('#content #bigPhoto').css('display','none');
	});
	
	

							 
});
