// use direct paypal
        var SWITCH_CURRENCY_EUR_RATE     =   0;
        
        UpdateInfoOnClick("personalw_15",   "personalw_15_link",    "Kon-Boot Personal License",              0, 35);
        UpdateInfoOnClick("commercialw_75", "commercialw_75_link",  "Kon-Boot Commercial License",            1, 75);
        UpdateInfoOnClick("personalm_15",   "personalm_15_link",    "Kon-Boot for Mac Personal License",      2, 35);
        UpdateInfoOnClick("commercialm_75", "commercialm_75_link",  "Kon-Boot for Mac Commercial License",    3, 75);
       
        UpdateInfoOnClick("personal_26",    "personal_26_link",     "Kon-Boot 2in1 Personal License",         4, 60);
        UpdateInfoOnClick("commercial_140",  "commercial_140_link",  "Kon-Boot 2in1 Commercial License",       5, 140);    
    
        
        if (EU_CLIENT == 1)
        {
            UpdateInfoOnClick("personalw_15", "personalw_15_link",    "[EU] Kon-Boot Personal License",              0, 39);
            UpdateInfoOnClick("personalm_15", "personalm_15_link",    "[EU] Kon-Boot for Mac Personal License",      2, 39);
            UpdateInfoOnClick("personal_26", "personal_26_link",     "[EU] Kon-Boot 2in1 Personal License",          4, 64);
            
            
            
            
            
          
        }
    
    
            try {
                    // https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
         
      
            } catch(error) {
                console.error(error);
            }
    
    
    
    
    function UpdateInfoOnClick(idText, idLink, ProductName, ProductNumber, ProductPrice) {
        
        
        
        
        try
        {
            
            if (idText != 0)
            {
                var text_elem = document.getElementById(idText);
                text_elem.innerHTML = "$" + ProductPrice;
                
                if (EU_CLIENT && SWITCH_CURRENCY_EUR_RATE)
                {
                    text_elem.innerHTML = "€" + Math.ceil(ProductPrice / SWITCH_CURRENCY_EUR_RATE);
                }
                    
            }
                
            var link_elem = document.getElementById(idLink);
            link_elem.onclick     =   function() {  SendForm(ProductName, ProductNumber, ProductPrice); }
            
            
        }
         catch(err) { }        
    }    
    
    
    function UpdateInfo2(idLink, LinkUrl) {
        try
        {
            var link_elem = document.getElementById(idLink);
            
            link_elem.href        =   LinkUrl;  
            link_elem.onclick     =   function() { document.location = LinkUrl; }
        }
         catch(err) { }        
    }
    
    
    
    function IsCookieSet(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(";");
        for(var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == " ") {
                c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
                return c.substring(name.length, c.length);
            }
        }
        return "";
    }    
    
   
    function IsSetCookiePurchase(cookieName, cookieValue)
    {
        if (IsCookieSet(cookieName)) return 1;
        
        var now     = new Date();
        var time    = now.getTime();
        time        += 3600 * 1000;
        now.setTime(time);
        document.cookie = cookieName + "=" + cookieValue + "; expires=" + now.toUTCString() + "; path=/";
        return 0;
    }
   
   
    
    function SendGoogleEvent(ProductName, ProductNumber, ProductPrice, MagicID)
    {
        
        if (IsSetCookiePurchase("purchaseCookie", 1) == 1)
        {
            return;
        }
        
        
        var url         = document.location;
        var hostname    = (new URL(url)).hostname;
        try 
        {
            gtag("event", "begin_checkout", {
                "value": ProductPrice,
                "currency": "USD",
                "affiliation": hostname,
                "tax": 0.0,
                "shipping": 0,
                "items": [ {
                    "id": ProductNumber,
                    "name": ProductName,
                    "category": "Software",
                    "list_position": ProductNumber,
                    "quantity": 1,
                    "price": ProductPrice
                } ]
            });
        } catch(e) { } 
          
  
    }
    
    
    var CancelPageURL       =   "https://kon-boot.com/paypal/canceled_new.html";
    var ReturnPageURL       =   "https://kon-boot.com/paypal/success_new.html";
    var NotifyPageURL       =   "https://kon-boot.com/paypal/paypal_notify.php";
    
    function SendForm(ProductName, ProductNumber, ProductPrice)
    {
        
        console.log("on click!");
        
        if ((ProductNumber == 2) || (ProductNumber == 3))
        {
            window.location.href = "https://kon-boot.com/paypal/stripe/";
            return;
            
        }
        
        
        var paypal_dest     =   "https://www.paypal.com/cgi-bin/webscr";
        var url_url         =   window.location.href;
        var MagicID         =   "ID_216.73.216.183_HuQbDitwZeSPo_690496c0d9d3e";
        
        var url_url2            =   url_url.replace("https://", "");
        var extra               =   encodeURI("?FullURL=" + url_url2 + "&ProductName=" + ProductName + "&ProductNumber=" + ProductNumber + "&ProductPrice=" + ProductPrice + "&MagicID=" + MagicID);
        
        
        var newReturnPageURL    =   ReturnPageURL + extra;
        var newCancelPageURL    =   CancelPageURL + extra;
        
        
        
        var params          =   {   cmd: "_xclick", business: "sales@thelead82.com", amount: ProductPrice, item_name: ProductName, item_number: ProductNumber,
                                    currency_code: "USD", cancel_return: newCancelPageURL, return: newReturnPageURL, notify_url: NotifyPageURL,
                                    no_shipping: 1, custom: "216.73.216.183_HuQbDitwZeSPo" }
        
       
        
        
        // this is only for website on kon-boot.com
        //if ((url_url.indexOf("kon-boot.com") > -1) || (url_url.indexOf("kbcom") > -1))
        
        if (typeof window.gUSE_CONFIRM != "undefined")
        {
      
            
            try
            {
                $.confirm({
                    title: "License Agreement",
                    content: "Please confirm that you read and agree to terms and conditions. 
After you click I AGREE you will be redirected to paypal payments.",
                    type: "blue",
                    typeAnimated: true,
                    buttons: {
                        tryAgain: {
                            text: "I AGREE",
                            btnClass: "btn-blue",
                            action: function(){
                                
                                
                                SendGoogleEvent(ProductName, ProductNumber, ProductPrice, MagicID);
                                PostForm(paypal_dest, params, "post");
                            }
                        },
                        close: function () {
                        }
                    }
                });
            
                
            } catch(error) {
                console.error(error);
            }
            
        }
        else
        {
            console.log("########## POST FORM ############");
            
            //SendGoogleEvent(ProductName, ProductNumber, ProductPrice, MagicID);
            PostForm(paypal_dest, params, "post");
        }
    }
    
    // grabbed from: https://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
    function PostForm(path, params, method) {
        //console.log(params);
    
        method = method || "post"; 
        
        var form = document.createElement("form");
        form.setAttribute("method", method);
        form.setAttribute("action", path);
        for(var key in params) {
            if(params.hasOwnProperty(key)) {
                var hiddenField = document.createElement("input");
                hiddenField.setAttribute("type", "hidden");
                hiddenField.setAttribute("name", key);
                hiddenField.setAttribute("value", params[key]);
                form.appendChild(hiddenField);
            }
        }
        document.body.appendChild(form);
        form.submit();
    }