
var currentScore = 0
var rotateScoresLeft = function(){
	
	if(currentScore+9 < $('.scoreCell').length ){	
	
		currentScore++
		$('#scoresHorzContainer').css('marginLeft', -100*currentScore)
		
	}
		
}
var rotateScoresRight = function(){

	if(currentScore > 0){	
	
		currentScore--
		$('#scoresHorzContainer').css('marginLeft', -100*currentScore)
		
	}
}


var currentBanner = 0
var rotateBannersLeft = function(){
	
	currentBanner+1 < $('.banner').length ? currentBanner++ : currentBanner = 0
	$('#bannerHorzContainer').animate({marginLeft: -950*currentBanner}, 500, 'easeOutQuad')	
	
}

var rotateBannersRight = function(){
	
	if(currentBanner > 0){
		currentBanner--
		$('#bannerHorzContainer').animate({marginLeft: -950*currentBanner}, 500, 'easeOutQuad')
	}
}

var bannerTimer
var initiateBanners = function(){
	bannerTimer = setInterval('rotateBannersLeft()', 4500)
}

$(document).ready(function(){
	
	$('#bannerHorzContainer').width(950*$('.banner').length)	
	initiateBanners()
	
	$('#bannersBox')
		.mouseover(function(){clearInterval(bannerTimer)})
		.mouseout(function(){initiateBanners()})
		.pngFix()
		
	$('#bannerLeftArrow').click(function(){rotateBannersRight()})
	$('#bannerRightArrow').click(function(){rotateBannersLeft()})
	
	
	$('.scoreArrow')
		.mouseover(function(){this.id == 'scoresLeftArrow' ? $(this).css('backgroundPosition', 'left bottom') : $(this).css('backgroundPosition', 'right bottom')})
		.mouseout(function(){this.id == 'scoresLeftArrow' ? $(this).css('backgroundPosition', 'left top') : $(this).css('backgroundPosition', 'right top')})
		.click(function(){this.id == 'scoresLeftArrow' ? rotateScoresRight() : rotateScoresLeft()})
		
	$('.langSelectLink').click(function(){
		var targetlang = this.id.replace('lang_', '')
		if(location.href.indexOf('/kor/') < 0 && location.href.indexOf('/eng/') < 0) location.href = '/'+targetlang+'/'
		else targetlang == 'eng' ? location.href = location.href.replace('/kor/', '/eng/') : location.href = location.href.replace('/eng/', '/kor/')
	})
	
})
