// JavaScript Document

$(document).ready(function(){
	if(typeof FS_ajaxFeed == 'function') {
		home_ajax = new FS_ajaxFeed(['homeSpotPrices','homeTotals'],"/ajax/home/",60000);
		home_ajax.loadAjaxData();
	}	

	$('a.show-message').click(function(event)
	{
		if(is_mobile)
		{
			event.preventDefault();
			rel = $(this).attr('rel');
			document.location.href = '/message/lang/'+rel+'/?mobile=true';
		}
	});
	
	
});


var tabs = ['home','usa','singapore','japan','hongkong'];
var home_tab = 'home';
$(function(){
	
	// mobiles dont get the tabs, iOS does.
	if(is_mobile && !is_ios)
	{
		return;	
	}
	
	$(window).bind( 'hashchange', function(e) {
	
	var hash = $.param.fragment();
	
	if(hash == '')
	{
		// page just loaded / no hash, so show the home tab
		$('#'+home_tab+'Txt').show();
		$('#tab_'+home_tab+'').addClass('active');
		// and hide everything else
		$.each(tabs,function(index,value)
		{
			if(value != home_tab)
			{
				$('#'+value+'Txt').hide();	
				$('#tab_'+value+'').removeClass('active');
			}
		});
	}
	else
	{
		// show/hide content according to the hash
		$('#'+hash+'Txt').show();
		$('#tab_'+hash+'').addClass('active');
		$.each(tabs,function(index,value)
		{
			if(value != hash)
			{
				$('#'+value+'Txt').hide();	
				$('#tab_'+value+'').removeClass('active');
			}
		});	
	}
	})
	$(window).trigger( 'hashchange' );
});

