// Spyware stuff for Eyeblaster
// Currently featured on Milan pages

// These are their instructions:
// INSTRUCTIONS
// The Activity Tags should be placed at the top of the <BODY> section of the HTML page.
// In case you want to ensure that the full page loads as a prerequisite for a conversion being
// recorded, place the tag at the bottom of the page. Note, however, that this may skew the
// data in the case of slow-loading pages and in general not recommended.
//
// NOTE: It is possible to test if the tags are working correctly before campaign launch 
// as follows:  Browse to http://activity.serving-sys.com/activity/testmode.asp, which is 
// a page that lets you set your local machine to "testing" mode.  In this mode, when
// visiting a page that includes an activity tag, a new window will open, showing you the
// data sent by the activity tag to the Eyeblaster servers.
//
// END of instructions (These instruction lines can be deleted from the actual HTML).

function placeEyeBlasterSpyTag(activityID, advertiserID) {
	if (! activityID || ! advertiserID)
		return;
	
	//console.log('Calling eyeblaster activity: ' + activityID + ', adveriser: ' + advertiserID);
		
	var ebRand = Math.random()+ ' ';
	var url;
	ebRand = ebRand * 1000000;
	url = 'http://activity.serving-sys.com/Activity/Pipe.asp?ActivityID=' + activityID + '&AdvertiserID=' + advertiserID + '&Frequency=0&rnd=' + ebRand;
	
	scriptElem = document.createElement ('script')
	scriptElem.src = url;
	document.body.appendChild( scriptElem );
}

function initMilanFeaturesEyeBlaster(featureId, activityID, advertiserID) {
	var featureElem = document.getElementById(featureId);
	
	if (! featureElem) {
		//console.log('feature element ' + featureId + ' not found');
		return;
	}
	
	featureElem.onclick = function () {
		//console.log('Feature onclick called for ' + featureId);
		placeEyeBlasterSpyTag(activityID, advertiserID);
	};
}
