﻿
// tracking location for sendTrackingCode()
var trackLocation = "";                         //should be overwrited in each master page with unique project identifier, for example:
                                                //Rio - /catalog/
                                                //Copa - /login/

//Set user status
var salvadorUserStatus;
//Set url
var GARawUrl;
//Set LobbyType name (עולם) //set in BREADCRUM.ascx
var LobbyTypeForGA;
//Set LobbyType name (עולם) //set in BREADCRUM.ascx
var LanguageBranch;


// debug mode
var DEBUGMODE = false;
var pageTracker = null;

//To disable GA for a certain page set this parameter to false -- right now is used only in JsIncludeDown, if needed use it at needed sections
var SendPageGA = true;

// sends tracking codes to Google Analytics
// requires a list of pairs of arguments
//
// examples:
//      sendTrackingCode("Location", "", "Button_Clicked", "LoginButton", "UserStatus", "NotLoggedIn");
//      sendTrackingCode("EnteredSMSPage", null, "Button_Clicked", "LoginButton", "UserStatus", "NotLoggedIn");


//alert("GA.js");


function sendTrackingCode() {
    try {
        // the concated code that will be send to Google
        var code = trackLocation;
        // index for the arguments list
        var argIndex = 0;

        while (argIndex < arguments.length) {
            // if it's not the first pair
            if (argIndex >= 2) {
                code += "&";
            }

            // add the current pair
            code += arguments[argIndex];

            // if the argument is undefined, don't add it nor the equation mark
            if (arguments[argIndex + 1] != undefined) {
                if (arguments[argIndex + 1] != "") {
                    code += "=" + arguments[argIndex + 1].toLowerCase();        //Convert value to lower case
                }
                else {
                    code += "=null";
                }
            }

            // go to the next pair
            argIndex += 2;
        }

        //Add url הפרמטר של העמוד בו אתה נמצא מאותחל פעם אחת ולא מועבר בפונקציות של סלבדור
        if (GARawUrl) {
            code += "&URL=";     
            code += GARawUrl;
        }
        
        if (DEBUGMODE) {
            alert(code);
        }

   
        
        
        if (pageTracker == null) {
                //alert("pageTracker == null");
                pageTracker = _gat._getTracker("UA-3291374-1");
                pageTracker._setDomainName(".orange.co.il");
            }


        // send the code
         pageTracker._trackPageview(code);
 
    }
    catch (err) {
        // if an error occured, nothing to do unless it's debug mode
        if (DEBUGMODE) {
            alert(err);
        }
    }
}



