﻿//var _gaq = _gaq || [];

jQuery.ajax({
    type: "POST",
    url: "/LookupService.asmx/LookupIdentity",
    data: '{}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: success,
    error: error
});

function success(resp) {
    var json = jQuery.parseJSON(resp.d);
    var action = json.CountryCode + " | " + json.Provider; // + " | " + json.State + " | " + json.City + " | " + json.IpAddress;

    var location = (window.location + "").replace("http://", "");
    location = location.replace(location.substring(0, location.indexOf("/")), "");

    var date = new Date();

    var year = date.getYear();
    var month = date.getMonth();
    var day = date.getDay();
    var hours = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();

    if (month < 10) month = "0" + month;
    if (day < 10) day = "0" + day;

    if (hours < 10) hours = "0" + hours;
    if (minutes < 10) minuts = "0" + minutes;
    if (seconds < 10) seconds = "0" + seconds;

    var opt_label = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds + " | " + location;

    if ((json.Provider + "") != "") {
        _gaq.push(['_trackEvent', "DIS/PLAY IP Tracking", action, opt_label]);
    }
}

function error(xhr, ajaxOptions, thrownError) {
    //alert("An error occured while reading webservice data");
}

