﻿//----------------------------------------//
//------ statistics for globeshops -------//
//----------------------------------------//
var amPid = 408; // given by Amadesa
var isAmdesaActive = 0;

// Function of the sale details page
function GetAmadesaProductPageTag(  AuctionId,
                                    ProductImg,
                                    ProductLink,
                                    ProductTitle,
                                    ProductDesc,
                                    ProductStatus,
                                    ProductDisplayPrice, 
                                    ProductListPrice) {
    amPPid = 5473;

    amProductId = AuctionId;
    amProductImg = ProductImg;
    amProductLink = ProductLink;
    amProductTitle = ProductTitle;
    amProductDesc = ProductDesc;
    amProductDisplayPrice = ProductDisplayPrice;
    amProductListPrice = ProductListPrice;
    amProductStatus = ProductStatus;
    amCategory = "Main" + mainPageCategoryPath;

    WriteAmadesaScript();
}

// Function of the category page
function GetAmadesaCategoryPageTag(sAmParam) {

    amCategory = "Main" + mainPageCategoryPath;
    amParams = sAmParam;

    WriteAmadesaScript();
}

// Function of the login page
function GetAmadesaLoginPageTag() {

    amPPid = 5650;
    amParams = '';

    WriteAmadesaScript();
}

// Function of the user fill details page
function GetAmadesaUserFillDetailsPageTag() {

    amPPid = 5651;
    amParams = '';

    WriteAmadesaScript();
}

// Function of the protected page
function GetAmadesaProtectedPageTag() {

    amPPid = 5657;
    amParams = '';

    WriteAmadesaScript();
}

// Home page tag
function GetHomePageTag() {

    amPPid = '5964';
    amParams = '';
    amCategory = 'Homepage';

    WriteAmadesaScript();
}

// Write the amadesa script
function WriteAmadesaScript() {

    if (isAmdesaActive == 1) {
        try {
            var amHost = (("https:" == document.location.protocol) ? "https://secure-" : "http://");
            document.write("<scr" + "ipt type='text/javascript' src='" + amHost + "cache.amadesa.com/static/client_js/engine/amadesajs.js'><\/scr" + "ipt>");
        }
        catch (err) { }
    }
}

// Thank you page (win offer) tag
function GetWinOfferTag(totalOrder, orderId, auctionId, productCat, city, delPrice) {

    GetAmadesaWinOfferTag(totalOrder, orderId, auctionId, productCat, city, delPrice);
    GetGoogleWinOfferTag(totalOrder, orderId, auctionId, productCat, city, delPrice);
}

// Amadesa win offer
function GetAmadesaWinOfferTag(totalOrder, orderId, auctionId, productCat, city, delPrice) {

    amPPid = '5429'; 
    amRevenue = 'totalOrder=' + totalOrder + '&orderId=' + orderId + '&productId=' + auctionId + '&productCat=' + productCat + '&city=' + city + '&delPrice=' + delPrice;
    re = new RegExp("&city=+(.*)", "g");
    
    amRevenue = amRevenue.replace(re, "");
    
    WriteAmadesaScript();
}

// Google analytics win offer
function GetGoogleWinOfferTag(totalOrder, orderId, auctionId, productCat, city, delPrice){

    var stam = 'totalOrder=' + totalOrder + '&orderId=' + orderId + '&productId=' + auctionId + '&productCat=' + productCat + '&city=' + city + '&delPrice=' + delPrice;
    document.getElementById("statistic_iframe").src = "/javascripts/globeshops/statistics.htm?amRevenue=" + stam;
}
