// Cybersource Device Fingerprinting ID Generator

var cybsDeviceFingenprintProfiler =  function ( merchantID, sandBox, sessionID ){  

    if ( sandBox == 1 ) {
        var orgID = '1snn5n9w';
    } else {
        var orgID = 'k8vif92e';
        
    }

    //var sessionID = new Date().getTime();

	pngImage(orgID, merchantID, sessionID);
	javaScriptCode(orgID, merchantID, sessionID); 
    flashCode(orgID, merchantID, sessionID);

    return sessionID;
 }


 var pngImage = function( orgID, merchantID, sessionID ){

    // Generate p element
    var p   = document.createElement("p");
    cssStyle       = "background:url(https://h.online-metrix.net/fp/clear.png?org_id=" + orgID + "&session_id="  + merchantID + sessionID + "&m=1)";

    p.style.cssText  = cssStyle;
    p.height        = "0";
    p.width         = "0";
    p.hidden        = "true";

    // Generate Image
    var img = document.createElement("img");
    str     = "https://h.online-metrix.net/fp/clear.png?org_id=" + orgID + "&session_id="  + merchantID + sessionID + "&m=2";
    img.src = str;

    // append to body
    jQuery("body").append(p,img);
 }

 var javaScriptCode = function( orgID, merchantID, sessionID ){

    var js = document.createElement("script");
    js.src = "https://h.online-metrix.net/fp/check.js?org_id=" + orgID + "&session_id=" + merchantID + sessionID;
    js.type = "text/javascript";

    // append to body
    jQuery("body").append(js);
 }

 var flashCode = function( orgID, merchantID, sessionID ){

    var obj     = document.createElement("object");
    obj.data    = "https://h.online-metrix.net/fp/fp.swf?org_id=" + orgID + "&session_id=" + merchantID + sessionID;
    obj.width   = "1";
    obj.height  = "1";
    obj.id      = "thm_fp";

    var param   = document.createElement("param");
    param.name  = "movie";
    param.value = "https://h.online-metrix.net/fp/fp.swf?org_id=" + orgID + "&session_id=" + merchantID + sessionID;
    obj.appendChild(param);
    
    // append to body
    jQuery("body").append(obj);
    
 }