$(function() { // character selection
	$('#charSelect ul li a').click(function() {
		$('.char').hide();
		var target = $(this).attr('id');
		$(this).parents('ul').find('li').removeClass('on');
		$(this).parent('li').addClass('on');
		$('.'+target).fadeIn(300);
	});
	
	//get parameter from URL and shows the selected character
	var charParameter = location.search.substring(5);
	$('#charSelect ul').find('li').eq(charParameter-1).find('a').click();


	$('#charSelect > a').click(function(e) {
			e.preventDefault();
			var theUl = $(this).parent().find('ul');
			var numOfList = theUl.find('li').length;
			var firstItem = theUl.find('li').eq(0);
			var lastItem = theUl.find('li').eq(numOfList-1);
			
			if(this.id == 'prev') {
				// prev
				
				//if(theUl.find('li').hasClass('on')) {
				/*if($('#charSelect ul li:nth-child(1)').hasClass('on')) {
					theUl.prepend(lastItem);	
					$('#charSelect ul li:nth-child(2)').removeClass('on').prev().find('a').click();
					
				} else {
				*/   
				theUl.prepend(lastItem);		
				  
			} else if(this.id == 'next') {
				// next
				theUl.append(firstItem);
				
			} else {
				return false;
			}
		});


});

function resizeMenu(a) {
			$('embed#mainmenu').attr('height', a);
			if($('#subBanners')) {
				$('#subBanners').css('margin-top', a-185-70);
			}
			if($('#banners')) {
				$('#banners').css('margin-top', a-185-230+15);
			}
}

function startLunia() 
{
	/**
	*	Description of startLauncher function
	*
	*	serviceID	 : Identity number of each game.
	*	redirectURL	 : After checking log-in, Will go to this url.
	*	pluginInstallURL : If It dosen't have Lanuncher, Will go to this url.
	*
	*/
	this.startLauncher
	(
		10, 
		window.location.href, 
		"http://lunia.ogplanet.eu/DOWNLOAD/CLIENT.html#ogplauncher"
	);

}