fx4u_allowed_symbols=["EURUSD","GBPUSD","USDJPY","GOLD", "#IBM"];
lg_value = 'cs';
fx4u_update_delay=5; // in seconds
fx4u_quotes_header='<h1 class="subtitle">外汇市场概况</h1><table style="width:270px;" cellpadding="0" cellspacing="0"><tr style="border-bottom:1px solid #efefef;"><th>文书</th><th id="q-bid">买入价</th><th>卖出价</th></tr>';
fx4u_quotes_quote='<tr style="border-bottom:1px solid #efefef;" class="q-%DIRECTION%"><td width="110px">%SYMBOL%</td><td class="q-bid">%BID%<sup>%BIDP%</sup></td><td class="q-ask">%ASK%<sup>%ASKP%</sup></td></tr>';
fx4u_quotes_footer='</table><div id="q-datetime"><span id="qd-playPause" onclick="toggleQuotes()" class="qd-%CLASS%"></span><div id="qd-content"><span id="qdc-time">%UPDATED_TIME%</span> GMT+2, %UPDATED_DATE%</div></div>';

if (typeof fx4u_update_quotes_callback=='undefined') fx4u_update_quotes_callback={};


if (fx4u_update_delay) fx4u_update_timer = setInterval("fx4u_retrieve_quotes();",fx4u_update_delay*1000);

function fx4u_retrieve_quotes()
{
var script = document.createElement('SCRIPT');
script.type='text/javascript';
script.src='http://js.forex4you.com/quotes_json.js?'+"rnd="+(new Date().getTime());
document.documentElement.firstChild.appendChild(script);
}

function fx4u_update_quotes(quotes)
{
if ('undefined' == typeof quotes.updated) {
	return false;
}

var q=[],i,k,o,r;

if ('ALL'==fx4u_allowed_symbols)
{
 fx4u_allowed_symbols=[];
 for (var i in quotes['data']) fx4u_allowed_symbols.push(i);
}

var out=fx4u_quotes_header;
for (i in fx4u_allowed_symbols)
{
 var s=fx4u_allowed_symbols[i];

 if (q=quotes['data'][s])
 {
  q['askp'] = '';
  q['bidp'] = '';
  if (quotes['precise'][s]) {
   q=quotes['precise'][s];
   q['askp'] = q['ask'].substring(q['ask'].length-1,q['ask'].length);
   q['ask'] = q['ask'].substring(0,q['ask'].length-1);
   q['bidp'] = q['bid'].substring(q['bid'].length-1,q['bid'].length);
   q['bid'] = q['bid'].substring(0,q['bid'].length-1);
  }


  var s = s.replace("#", "");
  r={'%SYMBOL%':s,'%DIRECTION%':('up'==q['dir']?'up':'down'),'%BID%':q['bid'],'%BIDP%':q['bidp'],'%ASK%':q['ask'],'%ASKP%':q['askp'],'%ICON_DIR%':('up'==q['dir']?'hign':'low')};
  o=fx4u_quotes_quote;
  for (k in r) {o=o.replace(new RegExp(k,'g'),r[k]);}
  out+=o;
 }
}
out+=fx4u_quotes_footer;

var but_class; if (quotesStarted) but_class = "pause"; else but_class = "play";

r={'%CLASS%':but_class,'%UPDATED_DATE%':quotes['updated']['date_symbol'][lg_value],'%UPDATED_TIME%':quotes['updated']['time']};
for (k in r) {out=out.replace(new RegExp(k,'g'),r[k]);}



if (document.getElementById('quotes')) document.getElementById('quotes').innerHTML=out;

for (i in fx4u_update_quotes_callback) fx4u_update_quotes_callback[i](quotes);

}


