$(document).ready(function(){
		function scrollElems(dir){
			if(is_running){
				return;
			}
			
			is_running = true;
			
			var next, index;
			var active = elems.filter('.active');
			if(dir == 'left'){
				if(active.is(':last-child')){
					index = 1;
					next = elems.eq(0);
				}
				else{
					index = - elems.index(active);
					next = active.next();
				}
			}
			else{
				if(active.is(':first-child')){
					index = - elems.length + 2;
					next = elems.eq(elems.length - 1); 
				}
				else{
					index = - elems.index(active) + 2;
					next = active.prev()
				}
			}
			
			makeInactive( active, dir );
			makeActive( next, dir );
			content.animate({'left' : index * (normal_width + margin)}, 500, function(){ is_running = false; });
		}
	
		function makeActive(elem, dir){
			var l = anim_width;
			if(dir == 'left'){
				if(elems.index(elem) != 0){
					l = 0;
				}
				elem.next().animate({'left' : '-='+anim_width+'px'});
			}
			elem.animate({	'left'	: '-=' + l + 'px',
							'width'	: active_width}
							, 500)
				.css('z-index', '1000')
				.addClass('active');
							
			elem.find('img').animate({	'width'	: active_width,
										'height': active_height,
										'margin-top' : 0}
							, 500);
			setTimeout( function(){ elem.find('p').fadeIn(300);}, 500);
		}
	
		function makeInactive(elem, dir){
			var l = anim_width;
			if(dir == 'right'){
				elem.next().animate({'left' : '+='+anim_width+'px'});
				if(elems.index(elem) == 0){
					elem.animate({'left' : '+='+anim_width+'px'});
				}
				l = 0;
			}
			elem.find('p').fadeOut(200);
			elem.animate({	'left'	: '+=' + l + 'px',
							'width'	: normal_width}
							, 500, function(){ elem.css('z-index', 'auto')})
				.css('z-index', '888')
				.removeClass('active');
	
			elem.find('img').animate({	'width'	: normal_width,
										'height': normal_img_height,
										'margin-top' : 35}
							, 500);
		}

	
//	if
	
//	if(isMSIE == false) {
		var active_width	= 276;
		var active_height	= 188;
		var margin			= 5;
		var anim_width		= 95;
	
		var content			=  $('#slider_content');
		var elems			= content.find('li');
		var normal_width	= elems.eq(0).width();
		var normal_img_height	= elems.eq(0).find('img').height();
		var is_running		= false;
	
	
		elems.each( function(){
			var left = elems.index($(this)) * (normal_width + margin);
			$(this).css({'position' : 'absolute', 'left' : left});
		});
	
		makeActive(elems.eq(1));
		elems.eq(2).animate({'left' : '-='+anim_width+'px'});
	
	
		$('#slider a.right').click( function(){
			scrollElems('left');
			return false;
		});
		$('#slider a.left').click( function(){
			scrollElems('right');
			return false;
		});
	
	
	}
//	else {
//		$("#slider").css("display", "none");
//	}
);

