/**
 * 
 */
function toggle_confezione(me)
{
	me.find('.testo_confezione').toggleClass('hover_confezione');
	me.find('.bottiglia_stilizzata').toggleClass('hover_confezione');
};

$('#button_partecipa').live('click',function()
{
	window.location.hash="/concorso/step/1";
	if (!flash)
	{
		$.get('concorso.php',{flash:true,step:1},function(page)
		{
			currentStep=1;
			replacePage(page);
		});
	}
});

$('.div_confezione').live({
							mouseenter: function()
							{
								toggle_confezione($(this));
							},
							mouseleave:function()
							{
								toggle_confezione($(this));
							}
						});
$('.div_confezione').live("click",function()
{
	var confezione=$(this).attr('id').substring(1);
	window.location.hash="/concorso/step/2/"+confezione;
	if (!flash)
	{
		$.get('concorso.php',{flash:true,step:2,'package':confezione},function(page)
		{
			currentStep=2;
			replacePage(page);
		});
	}
});
var firstClick=true;
$("#butt_gioca,#butt_premi,#butt_regolamento").live("click",function()
{
	var rel=$(this).attr("rel");
	var oldRel=$("#head_concorso .current").attr("rel");
	$("#"+oldRel).hide();
	$("#"+rel).show();
	$("#head_concorso .current").removeClass("current");
	$(this).addClass("current");

	if (rel=='regolamento' && firstClick) 
	{
		$('#regolamento_interno').jScrollPane();
		firstClick=false;
	}
});

function replacePage(page)
{
	$(".placeholder_concorso").remove();
	var div=cleanHtml(page);
	div=$(div).css("bottom","150px");
	$('#next_section').after(div);
}

$('#back_button_concorso').live("click",function()
{
	currentStep-=1;
	switch(currentStep)
	{
		case 0:
				
				if (!flash)
				{
					window.location.hash='';
					$.get('concorso.php',{flash:true},function(page)
					{
						replacePage(page);
					});
				}
				else
					window.location.hash="#/concorso";
				break;
		case 1:
				window.location.hash="#/concorso/step/1";
				if (!flash)
				{
					$.get('concorso.php',{flash:true,step:1},function(page)
					{
						replacePage(page);
					});
				}
				break;
	}
});
