
// required parameters
var urlParams = 'ad_referral_url=' + window.location + '&ad_format=' + ad_format;

// optional parameters
if (exists('ad_font_size')) urlParams += '&ad_font_size=' + ad_font_size;
if (exists('ad_font_family')) urlParams += '&ad_font_family=' + ad_font_family;
if (exists('color_border')) urlParams += '&color_border=' + color_border;
if (exists('color_bg')) urlParams += '&color_bg=' + color_bg;
if (exists('color_link')) urlParams += '&color_link=' + color_link;
if (exists('color_text_title')) urlParams += '&color_text_title=' + color_text_title;
if (exists('color_text_normal')) urlParams += '&color_text_normal=' + color_text_normal;
if (exists('color_whats_this_link')) urlParams += '&color_whats_this_link=' + color_whats_this_link;
if (exists('ad_creative_id')) urlParams += '&ad_creative_id=' + ad_creative_id;
if (exists('ad_affiliate_id')) urlParams += '&ad_affiliate_id=' + ad_affiliate_id;
if (exists('ad_minimal')) urlParams += '&ad_minimal=' + ad_minimal;
if (exists('default_league')) urlParams += '&default_league=' + default_league;
if (exists('default_conference')) urlParams += '&default_conference=' + default_conference;
if (exists('default_team')) urlParams += '&default_team=' + default_team;
if (exists('default_player')) urlParams += '&default_player=' + default_player;
if (exists('ad_hide_league')) urlParams += '&ad_hide_league=' + ad_hide_league;
if (exists('ad_hide_team')) urlParams += '&ad_hide_team=' + ad_hide_team;
if (exists('ad_horizontal')) urlParams += '&ad_horizontal=' + ad_horizontal;

var iframe_id = (exists('ad_iframe_id'))?ad_iframe_id:'_4InfoAd';
var baseUrl = 'http://www.' + (exists('USING_TEST_SERVER')?'test.':'') + '4info.com/';
var wl = window.location; var deployPath = String(wl).split('/')[3]; var testSvr = (/^(dev\.|test\.|www.test\.)4info\.net/i.test(wl.hostname));
if (testSvr) { deployPath = (deployPath=='alert')?'':deployPath+'/'; baseUrl = 'http://' + wl.hostname + (wl.port?':'+wl.port:'') + '/' + deployPath; }
var iFrameSrc = baseUrl + 'alert/ads/dispatcher.jsp?' + urlParams;

document.write('<div style="display:none">4INFO</div>'); // invisible div needed for ad to work properly in FireFox
document.write('<iframe allowTransparency="true" id="'+iframe_id+'" src="" width="'+ad_width+'" height="'+ad_height+'" frameborder="0" scrolling="no"></iframe>');
document.getElementById(iframe_id).src = iFrameSrc; // must refresh src since directly passing parameters when writing iframe does not work

function exists(varName) { return (eval('typeof '+varName) != 'undefined'); }