$(document).ready(function(){
	if($.browser.msie){
		$('div').pngFix( );
	}
	
/*	currentImg = 0;
	maxImg = 4;
	
	for(i=1;i<maxImg+1;i++){
		$('#img_'+i).removeClass('hide');
		$('#img_'+i).css('opacity',0);
	}
	$('#leftscroll').click(function(){
		oldImg = currentImg;
		currentImg--;
		if(currentImg < 0){
			currentImg = maxImg;
		}
		$('#img_'+currentImg).stop().animate({opacity: 1}, 1000);
		$('#img_'+oldImg).stop().animate({opacity: 0}, 1000);
	})
	$('#rightscroll').click(function(){
		oldImg = currentImg;
		currentImg++;
		if(currentImg > maxImg){
			currentImg = 0;
		}
		$('#img_'+currentImg).stop().animate({opacity: 1}, 1000);
		$('#img_'+oldImg).stop().animate({opacity: 0}, 1000);
	})
	
	*/
	
	
	currentImg = 0;
	totalImg = 0;
	timer = 6;
	nextImg = 0;
	
	startTimer = timer;
	$('#head_img .head_image').each(function(){
		totalImg++;
		$(this).attr('id','img_'+totalImg);
		$(this).removeClass('hide');
		$(this).css('opacity',0);
	});
	
	fadeImg = function(v){
		oldImg = currentImg;
		if(currentImg == 0){
			oldImg = totalImg;
		}
		
		currentImg+=v;
		if(currentImg>totalImg){currentImg=1;}
		if(currentImg <= 0){currentImg = totalImg;}
		
		$('#img_'+currentImg).stop().animate({opacity: 1}, 1000);
		$('#img_'+oldImg).stop().animate({opacity: 0}, 1000);
			
		timer=startTimer;
	}
	fadeImg(1);
	
	timerImg = function(){
		window.setTimeout(function() {
			timer --;
			if(timer == 0){
				fadeImg(1);
			}
			timerImg();
		}, 1000);
	}
	timerImg();
	
	
	
	
	$('#leftscroll').click(function(){
		fadeImg(-1);
	})
	$('#rightscroll').click(function(){
		fadeImg(1);
	})
	
	
});





