var FBwWidth = 740;
var FBwHeight = 540;
var FBwBG = 'E0E0E0';
var FBwl1 = 'EFEFEF';
var FBwl2 = 'E0E0E0';
var FBwlc = '000000';
var FBwfont = '0';
var FBwfs = '10';
var FBwth = 'ffffff';
var FBwtc = '000000';
var FBwtz = '-08:00';
var FBwln = 'en';
var FBcid = '87d19fdb';
var FBpair = '01000011010001100000';
//alert('FBpair ='+FBpair);
var refreshrate = 15000; //page refresh rate - every 15 seconds
//the params from the host site
var widgetURL ="http://fastbrokers.com/widgets/quotes-json_all.php";
var flagURL = "http://fastbrokers.com/widgets/flags";
var priURL = "http://fastbrokers.com/widgets/img";
var iconsURL = "http://fastbrokers.com/widgets/icons";
var bannerURL = "http://fastbrokers.com/widgets/banner_feeder.php?id=1";
var bannerpicURL = "http://fastbrokers.com/widgets/banners/";
var d = new Date();
var session_id = d.getTime();
var url = window.location.href;
var day = 0;
var FBwdpar;
FBwFontList = ["Verdana","Arial","Tahoma","Trebuchet MS","Calibri"];
var todaysdate = 'Friday, September 3 2010';
var FBWversion3 = 'v1.0.42 - 7/9/2010';
// takes a hex string and returns the r, g, b values
function parseColor(text){
var ot = text;
if(ot.length == 3){
t1 = ot.substr(0,1);
t2 = ot.substr(1,1);
t3 = ot.substr(2,1);
ot = t1+t1+t2+t2+t3+t3;
// alert("ot = "+ot);
text = ot;
}
// this regular expression checks for a hex color in proper format
if(/^\#?[0-9A-F]{6}$/i.test(text)){
return {
r: eval('0x'+text.substr(text.length==6?0:1, 2)),
g: eval('0x'+text.substr(text.length==6?2:3, 2)),
b: eval('0x'+text.substr(text.length==6?4:5, 2))
}
}
// return {r:255,g:0,b:0};
}
function hex(c){
c=parseInt(c).toString(16);
return c.length<2?"0"+c:c
}
function colorAverageOpposite(daColor){
var colorcomponent = parseColor(daColor);
daaverage = Math.round((colorcomponent.r+colorcomponent.g+colorcomponent.b)/3);
if (daaverage<=128){
return "fff";
} else {
return "000";
}
}
/*defines the styleSheets*/
var head = document.getElementsByTagName('head')[0],
style = document.createElement('style'),
rules = document.createTextNode('#FBquotes{display:block; width:'+ FBwWidth +'px; height:'+ FBwHeight +'px; background: #'+FBwBG+'; position:relative;}'+'\n'
+ '#FBquotesArea{display:block; width:'+ (FBwWidth-4) +'px; height:'+ (FBwHeight-90) +'px; overflow:hidden; font-family:'+FBwFontList[FBwfont]+',sans-serif; position:relative;}'+'\n'
+ '#FBquotestop{display:block; width:'+FBwWidth+'px; height:63px; background-color:#'+FBwBG+';}'+'\n'
+ '#FBquotesscroll{display:block; position:absolute; width:'+ (FBwWidth-6) +'px; height:'+ (FBwHeight-90) +'px; left:3px;}'+'\n'
+ '#FBquotesbottom {display:block; width:'+FBwWidth+'px; height:20px; top:'+(FBwHeight -20)+'px; font-family:'+FBwFontList[FBwfont]+',sans-serif; font-size:80%; background:#'+FBwBG+'; color:#'+colorAverageOpposite(FBwBG)+';}'+'\n'
+ '#qtimestamp{float:left; font-family:calibri,sans-serif; font-size:12px; color: #'+colorAverageOpposite(FBwBG)+'; margin-left:3px; padding-top:3px; padding-bottom:3px; width:90%; }'+'\n'
+ '#FBbannerArea2 {display:block; float:left; /*width:'+(FBwWidth-6)+'px;*/ height:35px; background-color:transparent; margin-left:3px;}'+'\n'
+ '#FBquotes #FBdisclaimer0{display:none; width:'+(FBwWidth-10)+'px; height:120px; position:absolute; top:'+(FBwHeight-150 )+'px; margin-left:3px; padding:3px; overflow:none; z-index:3000; background-color: #'+ FBwl2 +'; font-family: calibri,sans-serif; font-size:11px; color:#'+colorAverageOpposite(FBwl2)+'; /*letter-spacing:-1px;*/ filter:alpha(opacity=80); opacity: 0.8; -moz-opacity:0.8;}'+'\n'
+ '#quotestable {width:'+FBwWidth+'; font-size:'+FBwfs+'px;}'+'\n'
+ '#quotestable tr{border-bottom: 1px #'+FBwl1+' solid; padding:0 4px 0 4px;}'+'\n'
+ '#quotestable tr .tablehead td{padding:0px !important;}'+'\n'
+ '#quotestable tr .tablecaption td{height:12px !important;}'+'\n'
+ '#quotestable td{ padding:4px;}'+'\n'
+ '.line1{background: #'+FBwl1+'; color:#'+FBwlc+'; }'+'\n'
+ '#quotestable tr .line1 td{border-bottom: 1px #'+FBwth+' solid;}'+'\n'
+ '#quotestable tr .line2 td{border-bottom: 1px #'+FBwth+' solid;}'+'\n'
+ '.line2 {background: #'+FBwl2+'; color:#'+FBwlc+'; }'+'\n'
+ '.currency{font-weight:bold; font-size:105%;}'+'\n'
+ '.format {width:400px; padding:4px; background:#ffc;}'+'\n'
+ '#quotestable tr.tablecaption td { background-color:#'+FBwth+'; color:#'+FBwtc+'; border-bottom: 1px solid;}'+'\n'
+ '.fbctitle{font-size:120%; padding-bottom:8px; color:'+FBwtc+'; font-weight:bold;}'+'\n'
+ '.fbctitle a {color:'+FBwtc+'; text-decoration:none;}'+'\n'
+ '#tooltip h3, #tooltip div { margin: 0; font-weight:normal;}'+'\n'
+ '.moretitle{font-size:120%; font-weight:bold; clear:both; padding-bottom:4px;}'+'\n'
+ '.FBbottomleftside2{float:left;margin-left:3px; color:#'+colorAverageOpposite(FBwBG)+'; font-family:calibri,sans-serif; font-size:12px; padding-top:3px;}'+'\n'
+ '.FBbottomrightside2{float:right; margin-right:3px; color:#'+colorAverageOpposite(FBwBG)+'; font-family:calibri,sans-serif; font-size:12px; padding-top:3px;}'+'\n'
+ 'a.FBbottomlink2:active,a.FBbottomlink2:link,a.FBbottomlink2:visited{text-decoration:none; color:#'+colorAverageOpposite(FBwBG)+';}'+'\n'
+ 'a.FBbottomlink2:hover{text-decoration:underline; color:#'+colorAverageOpposite(FBwBG)+';}'+'\n'
+ 'a.alwaysul,a.alwaysul:active,a.alwaysul:link,a.alwaysul:visited,a.alwaysul:hover{text-decoration:underline;}'+'\n'
+ '.paddingleft0{padding-left: '+((FBwWidth-306)/2)+'px;}'+'\n'
+ '.leftside{display:block;width:100px; float:left;}'+'\n');
style.type = 'text/css';
if(style.styleSheet)
style.styleSheet.cssText = rules.nodeValue;
else style.appendChild(rules);
head.appendChild(style);
/*defines the div for the ajax to come out - redone with injectors*/
if(!qmaindoc) {
var qmaindoc = document.createElement('div');
qmaindoc.setAttribute('id','FBquotes');
document.getElementById('FastBrokersQuotes').appendChild(qmaindoc);
var base = document.getElementById('FBquotes');
var qcalendartop = document.createElement('div');
qcalendartop.setAttribute('id','FBquotestop');
qcalendartop.innerHTML = '
Forex Live Quotes
';
base.appendChild(qcalendartop);
//document.getElementById('FBquotes').appendChild(qcalendartop);
var qcalendararea = document.createElement('div');
qcalendararea.setAttribute('id','FBquotesArea');
document.getElementById('FBquotes').appendChild(qcalendararea);
var qdisclaimer = document.createElement('div');
qdisclaimer.setAttribute('id','FBdisclaimer0');
qdisclaimer.setAttribute('style','display:none;');
qdisclaimer.innerHTML = 'Disclaimer: '
+ 'FastBrokers' widgets are provided for information purposes only and under no circumstances should be regarded neither as an investment advice nor as a solicitation or an offer to sell/buy any financial product. FastBrokers assumes no responsibility or liability from gains or losses incurred by the information herein contained. Live quotes are delayed. '
+ 'Risk Disclosure: '
+ 'There is a substantial risk of loss in trading futures and foreign exchange. Please carefully review all risk disclosure documents before opening an account as these financial instruments are not appropriate for all investors.';
document.getElementById('FBquotes').appendChild(qdisclaimer);
var qcalendarscroll = document.createElement('div');
qcalendarscroll.setAttribute('id','FBquotesscroll');
document.getElementById('FBquotesArea').appendChild(qcalendarscroll);
var qbottom = document.createElement('div');
qbottom.setAttribute('id','FBquotesbottom');
qbottom.innerHTML = '
';
document.getElementById('FBquotes').appendChild(qbottom);
}
var params = "?pair="+FBpair;
var myurl = widgetURL+params;
var lastMessage = 0;
var mTimer;
var scrme;
//initialize the widget now
addScript(myurl);
//initialize banner
addBannerScript2(bannerURL);
function addScript(myurl) {
// alert("script invoked");
clearInterval(scrme);
var script = document.createElement('script');
script.setAttribute('id','Cparameter');
script.src = myurl;
// script.onload = tellStatus;
document.getElementsByTagName('head')[0].appendChild(script);
// document.body.appendChild(script);
// tellStatus("Loading...");
}
function refreshScript(myurl){
clearInterval(scrme);
var script = document.getElementById('Cparameter');
if (script) {
document.getElementsByTagName('head')[0].removeChild(script);
// document.body.removeChild(script);
}
addScript(myurl);
}
//banner load script
function addBannerScript2(myurl) {
// alert("script invoked");
// clearInterval(scrme);
var bannerscript1 = document.createElement('script');
bannerscript1.setAttribute('id','bannerdata1');
bannerscript1.src = myurl;
document.getElementsByTagName('head')[0].appendChild(bannerscript1);
// document.getElementById('FBcalendarscroll').style.top = 0+'px';
// document.body.appendChild(script);
// tellStatus("Loading...");
}
//banner feeded script
function jsonbanner1(myresponse){
var bannerres = myresponse;
var banner_div = document.getElementById('FBbannerArea2');
if(bannerres.banner.data[0].isflash=='1'){
var blink = document.createElement('div');
// blink.innerHTML = '';
blink.innerHTML = '';
banner_div.appendChild(blink);
} else {
var blink = document.createElement('a');
blink.setAttribute('href',bannerres.banner.data[0].link+'?'+FBcid);
blink.setAttribute('target','_blank');
// blink.cssText = paddingleft;
// blink.setAttribute('class','paddingleft');
blink.innerHTML = '';
banner_div.appendChild(blink);
} //end if
}
function tellStatus(){
alert('loaded');
}
function processFlags(dasymbol){
// alert('dasymbol = '+dasymbol);
var symbol = dasymbol;
var symbol1 = symbol.substr(0,3).toUpperCase();
var symbol2 = symbol.substr(4,3).toUpperCase();
var output = '
';
// alert('output = '+output);
return output;
}
function jsonquotes(daresponse){
clearInterval(scrme);
//alert('1');
var alticon;
var response = daresponse;
var color;
var quotes_div = document.getElementById('FBquotesscroll'); //indicates where to write the table
var headline_div = document.getElementById('FBquotestop'); //indicates where to write the table
var myinnerHTML = "";
myinnerHTML +='
';
//the single pixel row adjuster
myinnerHTML += '
';
myinnerHTML += '
';
myinnerHTML += '
';
myinnerHTML += '
';
myinnerHTML += '
';
myinnerHTML += '
';
myinnerHTML +='
';
myinnerHTML +='
';
myinnerHTML += '
Currency
';
myinnerHTML += '
';
myinnerHTML += '
Date
';
myinnerHTML += '
Ask
';
myinnerHTML += '
Bid
';
myinnerHTML += '
Spread
';
// the headlines go here
myinnerHTML +='
';
//the table body and datas
myinnerHTML +='';
color = '1';
for(i=0;i < response.quotes.data.length; i++) {
var tradedate = response.quotes.data[i].tradedate[0];
if(color=='1'){
// alert('2');
myinnerHTML +='