var soundOn = true;

$(document).ready(function() {
	
	
	$(".scroll_item").click(function(){
		scrollToDest($(this));
	});
	
	$(".nav_item_holder div, .button_item, .top_bg a").hover(function(){
		$(this).addClass("active");
	}, function() {
		$(this).removeClass("active");
	});
	
	 	$("#soundToggler").toggle(
		function(){
		   $(this).css({backgroundPosition: '0px -36px'});
		   	toggleSWFSound();
			}, 
		function () {
		   $(this).css({backgroundPosition: '0px 0px'});
		   	toggleSWFSound();
	 	 }
	 );	
	$(".howto").click(function(){
			_gaq.push(['_trackPageview','/memorygame/howtoplay']);
		   $("#howToDiv").show();
		   $("#shareThisDiv").hide();
		   $("#SquirtSimon").hide();
	  });
	$(".share").click(function(){
			_gaq.push(['_trackPageview','/memorygame/share']);
		   $("#shareThisDiv").show();
		   $("#howToDiv").hide();
		    $("#SquirtSimon").hide();
		  
		});	
	$("#shareThisDiv .closeButton").click(function(){
		   $("#shareThisDiv").hide();
		   $("#SquirtSimon").show();
		});
	$("#howToDiv .closeButton").click(function(){
		   $("#howToDiv").hide();
		    $("#SquirtSimon").show();
	});
	
	
	$("#thanksFrPlaying .closeButton,#closeReplay").click(function(){
		   $("#thanksFrPlaying").hide();
		    $("#SquirtSimon").show();
	});
	
	
		
	
	
	
	
});


$(function(){
	$('.item').scrollParallax({
		'speed': -0.2
		});

	$('.bubbles').scrollParallax({
		'speed': -0.3
	});

	$('.item1 .inner1').scrollParallax({
		'speed': -0.3
	});


		
	$('.item2 .inner1').scrollParallax({
		'speed': 0.2,
		'ystoppoint': 246,
		'ystoppoint_offset' : 200
	});
	
	$('.item2 .inner2').scrollParallax({
		'speed': -0.3,
		'ystoppoint': 246,
		'ystoppoint_offset' : 200
	});

	$('.item2 .inner3').scrollParallax({
		'speed': 0.4,
		'ystoppoint': 246,
		'ystoppoint_offset' : 200
	});
	
	$('.item2 .inner4').scrollParallax({
		'speed': -0.1,
		'ystoppoint': 246,
		'ystoppoint_offset' : 200
	});

});


function scrollToDest(element) {
	var scrollItemDest = $(element).data("scroll");
	var scrollOffset = $(element).data("offset");
	if($("#"  + scrollItemDest).parents("li").hasClass("hidden_section")){
		$(".hidden_section").show();
	} else {
		$(".hidden_section").hide();
	}
	_gaq.push(['_trackPageview', '/'+scrollItemDest+'/top']); 
	$.scrollTo(("#" + scrollItemDest), 1000, {offset: {top: scrollOffset, left:0} });	
}

function toggleSWFSound() {
	 soundOn = !soundOn;
	 document.getElementById("SquirtSimon").toggleSound();
	
}
function isSoundOn(){
	return soundOn;
}


function exitGame(lastLevel){
	 document.getElementById("SquirtSimon").style.display = "none";
	 document.getElementById('thanksFrPlaying').style.display = "block";
	 var levelReached = lastLevel;
	 $('#levelReached').html(levelReached);
	_gaq.push(['_trackPageview','/memorygame/thanks (level '+levelReached+')']);
}
