﻿var appPath = '/';

function TrackPpcClickSiteMap( src, svc, ip, cid, ind, val, clind )
{
    $.ajax({ type: "POST"
        , contentType: "application/json; charset=utf-8"
        , url: appPath + "WebServices/StorageSiteMap.asmx/SavePPCClick"
        , data: "{ 'domain' : '" + src + "', 'serviceName' : '" + svc + "', 'ipAddress' : '" + ip + "', 'campaignID' : '" + cid + "', 'levelInd' : '" + ind + "', 'levelVal' : '" + val + "', 'clickSourceInd' : '" + clind + "'}"
        , dataType: "text"
        , dataFilter: function(data) {var msg;if (typeof (JSON) !== 'undefined' && typeof (JSON.parse) === 'function') {msg = JSON.parse(data);}else {msg = eval('(' + data + ')');}if (msg.hasOwnProperty('d')) {return msg.d;}else {return msg;}}
        , success: function() {            
                      
        }
        , error: function(XMLHttpRequest, textStatus, errorThrown) { 
        }
    });
}



function TrackClick(guid, pagename) {
//    storageclick = getCookie('storageclick');
//    alert('Tracking CampaignID: ' + guid + ' Cookie Value: ' + storageclick + ' IP: ' + ip);
//    if (storageclick != null && storageclick == guid) {
//        alert('Welcome again !');
//    }
//    else {
	var d = new Date();
        pic1 = new Image(1, 1);
        pic1.src = "http://www.vanlines.com/RemoteTracking.aspx?type=storageppc&guid=" + guid +"&pagename=" + pagename + '&d=' + d.getDate();
//        setCookie("storageclick", guid, 1);
//    }
}

function TrackSmCl(seourl, ip, userId) {
	var p = new Image(1, 1);
	var d = new Date();

    	p.src = "http://beta.vanlines.com/RemoteTracking.aspx?type=sitemapstorateppc"
			+ "&seourl=" + seourl
			+ "&ip=" + ip
			+ "&userId=" + userId
			+ "&d=" + d.getDate()
		;

}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
	((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}
