$(function()
{
	var gameMode = $('main').data("mode");
	var count = 0;
	
	if(gameMode == 3) {
		for(var i=1; i<=5; i++) {		
			$('.elements').append('<div style="margin-left: 60px;margin-top: 50px;" class="clickable element_'+i+'"></div>');
		}
	}
	
	if(gameMode > 1) {
		setTimeout( function () {
			$('#jplayer').jPlayer('setMedia', {mp3: './media/file'+gameMode+'.mp3'});	
		}, 500);
	}
	
	$('.clickable').click(function() { 
		var right = $(this).data('right');
		if(right == 1) {
			count++;
			$(this).css('border-width', '3px');
			if((gameMode == 3 && count == 2) || gameMode != 3) {
				$('#jplayer_well').jPlayer('play');
			}
		} else {
			$('#jplayer_wrong').jPlayer('play');			
		}
	});
});
