/**
 * 创建底部工具条的国际时间flash
 * 
 */
function toolbar_global_flash() {
	var flashvars = {
		area_id :2,
		bgcolor :"#555555", // #000000
		footercolor :"#FF0000", // FF0000
		timeServer :'http://time08.shouyibao.com/WORLD_TIME/time.php?rn=',
		end_of_define :''
	};
	
	var params = {
		menu :"false",
		wmode :"opaque",
		quality :"high",
		bgcolor :"#FFFFFF",
		allowScriptAccess :'sameDomain', // always
		end_of_define :''
	};

	var attributes = {
		id :"swf_worldtime",
		name :"swf_worldtime"
	};
	
	swfobject.embedSWF("/swf/worldtime.swf", "div_worldtime", "150", "170",
					"10.0.32", "/swf/expressInstall.swf", flashvars, params,
					attributes);
}

/**
 * 底部工具条常用函数
 */
function toolbar(){
	//切换工具条panel
	$('#toolbar .item').click(function(){
		$('#toolbar iframe').hide();
		$('.toolbar_panel').hide();
		$(this).prev().show().parent().find('iframe').show();
	});
	
	//显示隐藏工具条
	$('#tbar_min_max').click(function(){
		$('#toolbar').toggle();
		$(this).parent().toggleClass('close').toggleClass('open');
	});
	
	$('#tbar_buy_btn').click(function(){
		var val = $('#tbar_buy_text').val();
		if(val.length==6){
			location.href = '/person/exchange/buy/'+val;
		}
	});
	
	$('#tbar_sell_btn').click(function(){
		var val = $('#tbar_sell_text').val();
		if(val.length==6){
			location.href = '/person/exchange/sell/'+val;
		}
	});
	
	//创建工具条股票框提示
	StockSuggestConfiguration_chn[6] = 3; // 表格中只有最多3个选项
	var suggest_chn_bottom_buy = new Suggest_chn('tbar_buy_text', "",
			common_config('site', 'domain') + '/stock_codes.js', [ "astock_suggest" ],
			StockSuggestConfiguration_chn, null, [ 160, 400, 0.95, "solid",
					"#EEE", "#FFF", 3, 3, 0.2, "#000", "#444", "#e5ebfb",
					false ]);
	StockSuggestConfiguration_chn[6] = 10;
	
	StockSuggestConfiguration_chn[6] = 3; //表格中只有最多3个选项
	var suggest_chn_bottom_sell = new Suggest_chn('tbar_sell_text', "", common_config('site', 'domain') + '/stock_codes.js', ["astock_suggest"], StockSuggestConfiguration_chn, null, [160, 400, 0.95, "solid", "#EEE", "#FFF", 3, 3, 0.2, "#000", "#444", "#e5ebfb", false]);
	StockSuggestConfiguration_chn[6] = 10;
	
	toolbar_global_flash();
	
	//阻止事件冒泡
	$('#toolbar_wrap').click(function(event){
		event.stopPropagation();		
	});
	//其他处的点击，均关闭toolbar
	$(document).click(function(){
		$('#toolbar_wrap div.toolbar_item').each(function(){
			$(this).children('iframe').hide();
			$(this).children('div').hide();
		});
	});
}

$(document).ready( function() {
	toolbar();
});


