
function AddTrack(URL, tag)
{
    if (URL.indexOf('?') == -1)
        trackURL = URL + "?trk=" + tag;
    else
        trackURL = URL + "&trk=" + tag;

        if ( typeof(cofActivate) == "function" && !URL.match(/checkoutnew/gi))
        cofActivate();

    document.location = trackURL;
}

// nameValueString example: "var1=value1&var2=value2&var3=value3"
function AddGetString(URL, nameValueString)
{
    if (URL.indexOf('?') == -1)
        newURL = URL + "?" + nameValueString;
    else
        newURL = URL + "&" + nameValueString;
    
        if ( typeof(cofActivate) == "function" )
        cofActivate();

    document.location = newURL;
}

var trackCount = new Array();
function UserTrackPageView(trkTag, prId)
{
    var httpRequest;
    var requestUrl;
    /*
    if(trackCount[trkTag] == 'undefined')
    {
        trackCount[trkTag] = new Array();
        
        if(prId)
        {
            trackCount[trkTag][prId] = true;
        }
    }
    else if(trackCount[trkTag] && prId != 'undefined')
    {
        if(trackCount[trkTag][prId] == 'undefined')
        {   
            trackCount[trkTag][prId] = true; 
        }
        else
        { 
            return false;
        }
    }
    else 
    {   
        return false; 
    }
    */  
    if (window.XMLHttpRequest) // Mozilla, Safari, ...
    {
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType)
        {
            httpRequest.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject) // IE
    {
        try
        {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {}
        }
    }

    if (!httpRequest)
    {
        return false;
    }

    requestUrl = '/inc/tracking/trackpageview.php?trk='+trkTag;
    if( prId )
        requestUrl += '&prId='+prId;

    httpRequest.onreadystatechange = function() {};
    httpRequest.open('GET', requestUrl, false);
    httpRequest.send(null);
    
}

function TrackAndSort(formObj, sorttype, trkTag)
{
    if ( trkTag)
        UserTrackPageView(trkTag);
    SubmitProductFinderMenuSort(formObj,sorttype, '', '');
}


