var FXAPI;

if(typeof(FXAPI) === 'undefined') {
	
	FXAPI = {};
	
	FXAPI.setfx = function(r) {
	
		var z, e, s;
			
		if(r.err || !(e = document.getElementById(r.id)) || !(s = e.attributes['format'].value)){
			return;
		}
								
		z = s.replace('{v1}', r.val_from);
		z = z.replace('{v2}', r.val_to);
		z = z.replace('{f1}', r.val_format1);
		z = z.replace('{f2}', r.val_format2);
		z = z.replace('{date}', r.date);
		z = z.replace('{date_y}', r.date_y);
		z = z.replace('{date_m}', r.date_m);
		z = z.replace('{date_d}', r.date_d);
		z = z.replace('{ds_en}', 'European Central Bank');
		z = z.replace('{ds_ja}', 'ヨーロッパ中央銀行');
				
		e.innerHTML = z;
	};
	
}

(function() {

	var elms, span, i, cf;

	elms = document.getElementsByTagName('span');
	
	for(i=0;i<elms.length;i++){
	
		span = elms[i];
		
		if( -1 == span.className.search("^fxapi$") ) {
			continue;
		}
		
		cf = span.attributes['callback'] ? span.attributes['callback'].value : '';
		
		exchange(
			span.id,
			span.attributes['fcode'].value,
			span.attributes['tcode'].value,
			span.attributes['value'].value,
			cf
		);
	
	}
	
	
	function exchange(e, f, t, v, cf){
		
		document.write(
			'<script type="text/javascript" src="http://raku2fx.com/fxapi-getfx.php?e=' + e + 
			'&f=' + f + '&t=' + t + '&v=' + v + ( cf ? '&cf=' + cf : '' ) + '"></script>'
		);

	}
	
})();