/*--start of const--*/
var BANNER_BASE_URL = 'http://www.conduit-banners.com/';
var LOG_SITE_URL = 'http://usage.conduit-banners.com/Logger/';
var LOG_ENABLED = true;
/*--end of const--*/
function __CreateDownloadToolbar()
{   
   var w="252px";
   var h="275px";
   if (window.navigator.userAgent.indexOf("MSIE") > 0)
   {
     h="245px";
   }

    var strCulture = "";
   
    if (typeof downloadButtonBannerCulture == 'string')
    {
        strCulture  = downloadButtonBannerCulture;
    }
    
    if (typeof setup == "undefined") //support for old banners
    {
        if (typeof (downloadUrl) != 'undefined' && downloadUrl != null)
            document.write("<iframe style='width:" + w + ";height:" + h + ";' frameborder=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" src='" + downloadUrl + "Banners/Download/?culture=" + strCulture + "'></iframe>");
        else
            document.write("<iframe style='width:" + w + ";height:" + h + ";' frameborder=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" src='" + get_clientBaseUrl() + "Download/?culture=" + strCulture + "&ctId=" + ctId + "'></iframe>");
    } //new banners with setup enabled
    else {
        if (typeof (downloadUrl) != 'undefined' && downloadUrl != null)
            document.write("<iframe style='width:" + w + ";height:" + h + ";' frameborder=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" src='" + downloadUrl + "Banners/Download/?culture=" + strCulture + "&setup=" + setup + "'></iframe>");
        else
            document.write("<iframe style='width:" + w + ";height:" + h + ";' frameborder=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" src='" + get_clientBaseUrl() + "Download/?culture=" + strCulture + "&ctId=" + ctId + "&setup=" + setup + "'></iframe>");
    }
   //log the banner
   if (LOG_ENABLED)
       var req = new LogScriptRequest(LOG_SITE_URL + logUsage(strCulture));
}

function get_clientBaseUrl()
{
    if (clientBaseUrl == 'http://hosting.conduit.com/' || typeof(clientBaseUrl)=='undefined' || clientBaseUrl==null)
        return BANNER_BASE_URL;
    return clientBaseUrl;
}
//------Log section------------//
String.format = function(text) {

    if (arguments.length <= 1) return text;
    var tokenCount = arguments.length - 2;
    for (var token = 0; token <= tokenCount; token++)
        text = text.replace(new RegExp("\\{" + token + "\\}", "gi"),
                                                    arguments[token + 1]);
    return text;
};
function LogScriptRequest(fullUrl) {
    // REST request path
    this.fullUrl = fullUrl;
    // Get the DOM location to put the script tag
    this.headLoc = document.getElementsByTagName("head").item(0);
    // Create the script tag
    this.scriptObj = document.createElement("script");

    // Add script object attributes
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("src", this.fullUrl);
    this.scriptObj.setAttribute("id", this.scriptId);
    //add the Script tag
    this.headLoc.appendChild(this.scriptObj);
}

function logUsage(strCulture) {
    try {
        var req = String.format('/?logType=impression&ctid={0}&bannertypeid={1}&bannerName={2}&bannerculture={3}', ctId, 6, "Download_button", strCulture);
        return req;
    }
    catch (e) {}
};
//------Log section------------//