$(document).ready(function(){
	
	switch (section){
		case 'videoReplays' : $('#ipadMenu_'+language).css({'background':'url(images/texts_'+language+'/ipad01_videoreplays.jpg) top left no-repeat'});
		break;
		case 'gameInfo' : $('#ipadMenu_'+language).css({'background':'url(images/texts_'+language+'/ipad02_gameinfo.jpg) top left no-repeat'});
		break;
		case 'gallery' : $('#ipadMenu_'+language).css({'background':'url(images/texts_'+language+'/ipad03_gallery.jpg) top left no-repeat'});
		break;
		case 'rankings' : $('#ipadMenu_'+language).css({'background':'url(images/texts_'+language+'/ipad04_rankings.jpg) top left no-repeat'});
		break;
	}
	
	//FLAG HOVERS
	$('#flagsContainer ul li a').animate({opacity:0.5},1);
	
	$('#flagsContainer ul li a').hover(
		function(){ $(this).animate({opacity:1},1); },
		function(){ $(this).animate({opacity:0.5},1); }
	);
	
	// GAME INFO DEFAULTS
	$('#trailersList ul:first').show();
	$('#trailersList li div:first').show();
	$('#trailersList li label').animate({opacity:0.5},1);
	$('#trailersList li label:first').animate({opacity:1},1);
	$('#gameInfoSubmenu_a').css({'background-position':'top right'});
	
	// GAME INFO SCREENS CLICK FUNC
	$('.slideShow li label').click(function(){
		$('.slideShow li label').animate({opacity:0.5},100);
		$('.slideShow li div').hide();
		$(this).animate({opacity:1},100);
		$(this).parent('li').children('div').show();
	});
	
	// GALLERIES TOGGLER
	$('#gameInfoSubmenu_a').click(function(){
		$('#screensPager, #screensList').hide();
		$('#trailerPager, #trailersList').show();
		$('#trailersList li label').animate({opacity:0.5},1);
		$('#trailersList li label:first').animate({opacity:1},1);
		$('#trailersList li div:first').show();
		$('#gameInfoSubmenu_a').css({'background-position':'top right'});
		$('#gameInfoSubmenu_b').css({'background-position':'top left'});
		$('#trailersList ul').show();
	});
	
	$('#gameInfoSubmenu_b').click(function(){
		$('#trailerPager, #trailersList').hide();
		$('#screensPager, #screensList').show();
		$('#gameInfoSubmenu_b').css({'background-position':'top right'});
		$('#gameInfoSubmenu_a').css({'background-position':'top left'});
		$('#screensList_'+init).show();
		
		/*
		$('#screensList li label').animate({opacity:0.5},1);
		$('#screensList li label:first').animate({opacity:1},1);
		$('#screensList li div').hide();
		$('#screensList li div:first').show();
		*/
		$('#screensList_'+init+' li label').animate({opacity:0.5},1);
		$('#screensList_'+init+' li label:first').animate({opacity:1},1);
		$('#screensList_'+init+' li div').hide();
		$('#screensList_'+init+' li div:first').show();
	});
	
	//SCREENS PAGER
		
	var init = 0;
	var maximo = 1; // PAGER MAX VALUE
	
	$('#screensPrev').click(function(){
		if (init > 0)
		{
			$('#screensList_'+init+' li label').animate({opacity:0.5},0);
			$('#screensList_'+init+' li div').hide();
			
			$('#screensList_'+init).hide();
			init--;
			$('#screensList_'+init+' li label').animate({opacity:0.5},1);
			$('#screensList_'+init+' li label:first').animate({opacity:1},1);
			$('#screensList_'+init+' li div:first').show();
			$('#screensList_'+init).show();
		}
	});
	
	$('#screensNext').click(function(){
		if (init < maximo)
		{
			$('#screensList_'+init+' li label').animate({opacity:0.5},0);
			$('#screensList_'+init+' li div').hide();

			$('#screensList_'+init).hide();
			init++;
			$('#screensList_'+init+' li label').animate({opacity:0.5},1);
			$('#screensList_'+init+' li label:first').animate({opacity:1},1);
			$('#screensList_'+init+' li div:first').show();
			$('#screensList_'+init).show();
		}
	});
	
	//GALLERY DEFAULTS
	
	$('#galScreensList ul:first, #galScreensList li div:first').show();
	$('#galScreensList li label').animate({opacity:0.5},1);
	$('#galScreensList li label:first').animate({opacity:1},1);
	$('#subBtnsScreens').css({'background-position':'top right'});
	
	//GALLERY SCREENS CLICK FUNC
	$('.galSlideShow li label').click(function(){
		$('.galSlideShow li label').animate({opacity:0.5},100);
		$('.galSlideShow li div, .galSlideShow li dl').hide();
		$(this).animate({opacity:1},100);
		$(this).parent('li').children('div').show();
		$(this).parent('li').children('dl').show();
	});
	
	var clearQueue = true;
	var gotoEnd = true;
	$('.galSlideShow li dl dt a img').hover(
		function(){ $(this).animate({opacity:0.5},200); },
		function(){ 
			$(this).stop(clearQueue,gotoEnd);
			$(this).animate({opacity:1},200);
		}
	);
	
	//GALLERIES TOGGLERS
	$('#galSubMenu li a').click(function(){
		$('#galSubMenu li a').css({'background-position':'top left'});
		$(this).css({'background-position':'top right'});
	});
	$('#subBtnsScreens').click(function(){
		$('#galleryVideos, #galleryWallps').hide();
		$('#galleryScreens, #galScreensList ul:first, #galScreensList li div:first').show();
		$('#galScreensList li label').animate({opacity:0.5},1);
		$('#galScreensList li label:first').animate({opacity:1},1);
	});
	$('#subBtnsVideos').click(function(){
		$('#galleryScreens, #galleryWallps').hide();
		$('#galleryVideos, #galVidsList ul:first, #galVidsList li div:first').show();
		$('#galVidsList li label').animate({opacity:0.5},1);
		$('#galVidsList li label:first').animate({opacity:1},1);
	});
	$('#subBtnsWallpapers').click(function(){
		$('#galleryScreens, #galleryVideos').hide();
		$('#galleryWallps, #galWallpsList ul:first, #galWallpsList li div:first, #galWallpsList li dl:first').show();
		$('#galWallpsList li label').animate({opacity:0.5},1);
		$('#galWallpsList li label:first').animate({opacity:1},1);
	});

});