$(document).ready(function(){
	$("div.tabs").tabs(".promoItem",{effect:'fade',fadeOutSpeed:"slow",rotate:true,initialIndex:0}).slideshow({autoplay:true,interval:9000,clickable:false});
	var api = $("div.tabs").tabs();
	$("div.tabs a").click(function(){api.stop();});
	
	Cufon.now();
	//Key visual function: Gold Trading
	loadPrice();
	//Key visual function: Gold Trading END	
	
	loadRate();
	animatedNews();		
});
					//Key visual function: Gold Trading
var refreshCount = 1;
function loadPrice(){
	var params = {};	
	params["type"] = "price";
	if (refreshCount%2 == 0) {
		$('#header').text('Gold Price');
		if($('#homePage').hasClass('tc'))  $('#header').text('黃金報價');
		if($('#homePage').hasClass('gb'))  $('#header').text('黄金报价');
		params["pair"] = "xauusd";
		$('#silverBg').fadeOut("slow"); 

	} else {
		$('#header').text('Silver Price');
		if($('#homePage').hasClass('tc'))  $('#header').text('白銀報價');
		if($('#homePage').hasClass('gb'))  $('#header').text('白银报价');
		params["pair"] = "xagusd";
		$('#silverBg').fadeIn("slow"); 		
	}
	$.ajax({
		url: '/js/post.php', cache: false, dataType: 'json', type: 'GET', data: params,
		success: function(data) {
			$('#bid').text(data.bid);
			$('#ask').text(data.ask);
			$('#high').text(data.high);
			$('#low').text(data.low);
		}
	});
	refreshCount++;
	setTimeout(loadPrice, 5000);		
}
					//Key visual function: Gold Trading END	
								
					function loadRate(){
						$.ajax({
							url: '/js/price.php', cache: false, dataType: 'json', type: 'GET', data: "lang="+currlang,
							success: function(data) {
								var header = "Name | Sell | Buy | High | Low <br>";
								var pricelist = "<ul>";
								var k = ' class="alt"';	
								$.each(data, function(i, item) {
									if (k == ' class="alt"') { k = ''; }  else { k = ' class="alt"'; }
									pricelist += '<li'+ k + '><span class="pair">' + data[i]["name"] + '</span> <span class="sell">' + data[i]["bid"] + '</span> <span class="buy">' + data[i]["ask"] + '</span></li>';
									datetime = data[i]["datetime"];
								});
								pricelist += '</ul>';
								$("div#rate").html(pricelist);
								$("div.datetime").html(datetime);
								clearInterval(window['price']); 
								animatedPrice();
							}
						});
						
						setTimeout(loadRate, 60000);
					}
					function animatedPrice() {
						$('#rate').vTicker({
							speed: 500,
							pause: 3000,
							showItems: 5,
							animation: 'fade',
							mousePause: false,
							height: 0,
							direction: 'up',
							intervalName: 'price'
						});
					}
					
					function animatedNews() {
						$('.bottomNews').vTicker({
							speed: 500,
							pause: 3000,
							showItems: 2,
							animation: 'fade',
							mousePause: true,
							height: 0,
							direction: 'up',
							intervalName: 'news'
						});
					}
