

var is_panel_open = 0;

function bonus_move()
{
	$('order_button').className = 'Bot BotG5 GoG'; 
	$('gift_detail_order').innerHTML = 'caricamento in corso...'; 
	
}

function show_tracking_frame()
{
	Effect.BlindDown('tracking_pane', 	{duration: 0.6	});
	return false;
}

function bonus_open ()
{
	if (is_panel_open == 0)
	{
		$('gift_detail_order').innerHTML = 'Clicca per confermare la tua richiesta';
		is_panel_open = 1;
		return false;
	}
	else if (is_panel_open == 1)
	{
		setTimeout (bonus_move, 1000);
		$('gift_detail_form').submit();
		is_panel_open = 2;
		return false;
	}
	return false;
}


function ship_open ()
{
	if ($('ship_panel').style.display == 'none')
	{
		$('gift_detail_order').innerHTML = 'Clicca per confermare la tua richiesta';
		Effect.SlideDown ('ship_panel', 	{duration: 0.6	});
		return false;
	}
	else
	{
		setTimeout (bonus_move, 1000);
		$('gift_detail_form').submit();
		return false;
	}
	return false;
}

function order_confirm ()
{
	$('gift_detail_form').submit();
	return false;
}


function show_all_gift ()
{
	Effect.BlindDown ('gift_more', 	{duration: 0.6	});
	Effect.SlideUp ('gift_more_link', 	{duration: 0.6, queue:'end'	});
	return false;
}



function ship_view ()
{
	if ($('ship_panel').style.display == 'none')
	{
		Effect.SlideDown ('ship_panel', 	{duration: 0.6	});
	}
	else
	{
		Effect.SlideUp ('ship_panel', 	{duration: 0.6	});
	}
	return false;
}

	function vip_calc (points)
	{
		if (points < 800)  return 1;
		if (points < 4000)  return 2;
		if (points < 15000)  return 3;
		if (points < 40000)  return 4;
		if (points < 80000)  return 5;
		return 6;
	}


function vip_start ()
{
  Event.observe( window, 'load',
	  function() 
	  {
		var zoom_slider = $('zoom_slider');
		var	pts_field = $('pts_field');
		var	test_value = 20000 +  parseInt (pts_field.value, 10);
		var	max_value = (test_value > 100000) ? test_value : 100000;
	
	
	  	slider =  new Control.Slider(zoom_slider.down('.handle'), zoom_slider,
	  	{
		  range: $R(0, max_value),
		  increment: 10,
		  sliderValue: pts_field.value,
		  onSlide: function(value) 
		  {
			pts_field.value = Math.round(value);
			vip_level = vip_calc (pts_field.value);
			for (vip_index = 1; vip_index < 7; vip_index++)
			{
				$('bar_vip_' + vip_index).className = (vip_index == vip_level) ? '' : 'off';
			}
		  },
		  onChange: function(value)
		  { 
			pts_field.value = Math.round(value);
			vip_level = vip_calc (pts_field.value);
			for (vip_index = 1; vip_index < 7; vip_index++)
			{
				$('bar_vip_' + vip_index).className = (vip_index == vip_level) ? '' : 'off';
			}
		  }
		});
		
		slider.setValue ($('pts_field').value);
	
 	 }
 	);
 }



function vip_key_up ()
{
	var	pts_field = $('pts_field');
	slider.setValue ($('pts_field').value);
}



function user_login_move()
{
	$('login_button').className = 'Bot BotG5 GoG'; 
	$('login_text').innerHTML = 'caricamento in corso...'; 
}

function get_cookie ( cookie_name )
{
	var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
  return (results ?  unescape ( results[1] ) : null );
}

function user_login()
{
	localhost = window.location.host;
	
	document.cookie =  "test_host=" +  localhost  + ";path=/;domain=sisalpokerrewards.it";
	if ($('login_remember_me') && $('login_remember_me').checked)
	{
		document.cookie =  "spr_remember_me=" + $('login_remember_me').value + ";path=/;domain=sisalpokerrewards.it";
	}
	else
	{
		document.cookie =  "spr_remember_me=;path=/;domain=sisalpokerrewards.it";
	}
	
	setTimeout (user_login_move, 1000);
	$('user_login_form').submit();
	return false;

}

function daily_race_token_detail ()
{
	location = 'token-Token-Daily-Race-Free-Roll-00054.xhtml';
	return false;
}

function daily_race_bonus_detail ()
{
	location = 'bonus-Bonus-Daily-Race-00055.xhtml';
	return false;
}

function daily_race_2_bonus_detail ()
{
	location = 'bonus-Bonus-Daily-Race-00057.xhtml';
	return false;
}



function super_daily_race_bonus_detail ()
{
	location = 'bonus-Bonus-Super-Daily-Race-00059.xhtml';
	return false;
}

function super_daily_race_token_detail ()
{
	location = 'token-Super-Token-Daily-Race-Free-Roll-00058.xhtml';
	return false;
}


function friend_bonus_detail ()
{
	location = 'bonus-Bonus-Invita-un-Amico-00060.xhtml';
	return false;
}

function double_pts_detail ()
{
	location = 'bonus-Doppi-Punti-00061.xhtml';
	return false;
}

function summer_race_multiplier_detail ()
{
	location = 'bonus-Moltiplicatore-Upgrade-00065.xhtml';
	return false;
}

function summer_race_bonus_detail ()
{
	location = 'bonus-Summer-Extra-Bonus-00064.xhtml';
	return false;
}







function follow_update()
{
	dom_ajax_get ('user_follow.xhtml', follow_update_html);
}

function follow_update_html(ajax_req, text_doc, knd)
{
	dom_xml_islands_update (ajax_req);
	try	{	document.recalc();}		catch (exc)	{}		//IE7 lib
	
	if ($('reload_after_follow_update') && $('reload_after_follow_update').value == '1')
		location.reload();
}



function mediaworld_category( detail_id)
{
	$('mw_content').innerHTML = '';
	$('mw_content').addClassName ('loading');

	dom_ajax_get ('mediaworld_category.xhtml?sub=' + detail_id, mediaworld_category_update_html);
}

function mediaworld_category_update_html (ajax_req, text_doc)
{
	dom_xml_islands_update (ajax_req);
	try	{	document.recalc();}		catch (exc)	{}		//IE7 lib
}

function mediaworld_detail( detail_id)
{
	$('mw_content').innerHTML = '';
	$('mw_content').addClassName ('loading');

	dom_ajax_get ('mediaworld_detail.xhtml?prod=' + detail_id, mediaworld_detail_update_html);
}

function mediaworld_detail_update_html (ajax_req, text_doc)
{
	dom_xml_islands_update (ajax_req);
	try	{	document.recalc();}		catch (exc)	{}		//IE7 lib
}


function mediaworld_tab(id)
{
	var tabs 			= $$('a.mw_tabs');
	var tabs_content 	= $$('div.mw_tabs_content');
	
	for (var index = 0; index < tabs.length; ++index)
	{
  		var item = tabs[index];
  		if (item.getAttribute('tab_id') == id)
  			item.addClassName ('on');
  		else
  			item.removeClassName ('on');
  	}

	for (var index = 0; index < tabs_content.length; ++index)
	{
  		var item = tabs_content[index];
  		
  		if (item.getAttribute('tab_id') == id)
  			item.addClassName ('on');
  		else
  			item.removeClassName ('on');
  	}


}




