if (typeof fx4u_allowed_symbols=="undefined") fx4u_allowed_symbols=['EURUSD','GBPUSD','USDJPY','GBPJPY','EURJPY','USDCHF','EURGBP','USDCAD','AUDUSD','NZDUSD','CADCHF','EURCHF','GOLD','SILVER'];
if ((typeof fx4u_update_delay=="undefined") || fx4u_update_delay<2) fx4u_update_delay=0; // in seconds
if (typeof fx4u_quotes_header=="undefined" || typeof fx4u_quotes_quote=="undefined" || typeof fx4u_quotes_footer=="undefined") {
 fx4u_quotes_header='<table><tr><td align="center"><strong>Символ</strong></td><td align="center"><strong>Бид</strong></td><td></td><td align="center"><strong>Аск</strong></td></tr>';
 fx4u_quotes_quote='<tr><td>%SYMBOL%</td><td><span class="%DIRECTION%">%BID%</span></td><td><img src="%ICON_DIR%" alt="%DIRECTION%" /></td><td><span class="%DIRECTION%">%ASK%</span></td></tr>';
 fx4u_quotes_footer='<tr><td align="center" colspan="4" nowrap><hr size="1">%UPDATED_DATE% %UPDATED_TIME% GMT+1</td></tr></table>';
}

setTimeout("fx4u_retrieve_quotes();",10);
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://www.forex4you.org:81/quotes_json.js?'+"rnd="+(new Date().getTime());
document.documentElement.firstChild.appendChild(script);
}

function fx4u_update_quotes(quotes)
{
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])
 {
  r={'%SYMBOL%':s,'%DIRECTION%':q['dir'],'%BID%':q['bid'],'%ASK%':q['ask'],'%ICON_DIR%':'http://forex4you.org:81/arrow-'+('up'==q['dir']?'up':'dn')+'.gif'};
  o=fx4u_quotes_quote;
  for (k in r) {o=o.replace(new RegExp(k,'g'),r[k]);}
  out+=o;
 }
}
out+=fx4u_quotes_footer;

r={'%UPDATED_DATE%':quotes['updated']['date'],'%UPDATED_TIME%':quotes['updated']['time']};
for (k in r) {out=out.replace(new RegExp(k,'g'),r[k]);}

out+=' Котировки от <a href="http://www.forex4you.org">Forex4You</a>';

if (document.getElementById('fx4u_quotes')) document.getElementById('fx4u_quotes').innerHTML=out;

}
