﻿var BCMRunning = false;

function IsBCMRunning(blnRunning)
{
    BCMRunning = blnRunning;
}

var BCMUrl;

function GetBCMUrl(strurl)
{
    BCMUrl = strurl;
}

function CallBehaviourModule(strurl, action)
{
    var newUrl = BCMUrl + '' + action + '&value=' + strurl
  	var onebyone = document.createElement('img');
  	onebyone.width='1px';
  	onebyone.height='1px';
  	onebyone.src=newUrl+'&cachebuster='+(Math.random()*1000000);
  	onebyone.id = "onebyone";
  	document.body.appendChild(onebyone);
  	if (action.toString().toLowerCase() == 'click' || action.toString().toLowerCase() == 'browse')
  	    return true;
}

function CallBehaviourModulePlayer(strurl, action) {
    action = 'Video';
    var newUrl = BCMUrl + '' + action + '&value=' + strurl
    var onebyone = document.createElement('img');
    onebyone.width = '1px';
    onebyone.height = '1px';
    onebyone.src = newUrl + '&cachebuster=' + (Math.random() * 1000000);
    onebyone.id = "onebyone";
    document.body.appendChild(onebyone);
}
  
function BCM()
{
    CallBehaviourModule(this.href, 'Browse');
}
				
function isHttps()
{
	//	Determine whether the page is using https
	return (location.protocol.toLowerCase() == "https:");
}

IsBCMRunning(true);

if(!isHttps())
	GetBCMUrl('http://bcm.itv.com/BehaviourCaptureHandler.ashx?action=');
else
	GetBCMUrl('https://bcm.itv.com/BehaviourCaptureHandler.ashx?action=');

