	function UnrulyTracking(stats1, stats2, stats3, vid, ppid, apid, aid, pid, cid, size, autoplay, autoUnit) {
	this.myStats1 = stats1;
	this.myStats2 = stats2;
	this.myStats3 = stats3;
	this.myVid = vid;
	this.myPpid = ppid;
	this.myApid = apid;
	this.myAid = aid;
	this.myPid = pid;
	this.mySize = size;
	this.myAutoplay = autoplay;
	this.myAutoUnit = autoUnit;
	this.myCid = cid;
	
	this.skipTracking = false;
	if (location.href.indexOf("skiptracking=true") != -1) this.skipTracking = true;
	if (typeof wildfireAddParams != "undefined" && wildfireAddParams.indexOf("skiptracking=true") != -1) this.skipTracking = true;
}

UnrulyTracking.prototype.setThirdPartyPlayTrackingUrl = function(thirdPartyPlayTrackingUrl) {
	this.myThirdPartyPlayTrackingUrl = thirdPartyPlayTrackingUrl;
} 

UnrulyTracking.prototype.setThirdPartyImpTrackingUrl = function(thirdPartyImpTrackingUrl) {
	this.myThirdPartyImpTrackingUrl = thirdPartyImpTrackingUrl;
} 

UnrulyTracking.prototype.getReferrerURL = function() {
	try {
		var pos = location.href.indexOf("refurl=");
		if (pos != -1) {
			pos = pos + 7; // get rid of parameter name
			var endPos = location.href.indexOf("&", pos);
			if (endPos != -1) {
				return location.href.substring(pos, endPos);
			}
			else {
				return location.href.substring(pos, location.href.length);
			}
		}
	}
	catch (e) {
		// ignore
	}
	return "";
}

UnrulyTracking.prototype.track = function(type, name, value) {
	if (this.skipTracking) return;
	
	var rn = Math.random() * 1000000;
	
	var params = "t=" + type;
	params += "&vid=" + this.myVid;
	params += "&ppid=" + this.myPpid;
	params += "&apid=" + this.myApid;
	params += "&aid=" + this.myAid;
	params += "&pid=" + this.myPid;
	params += "&cid=" + this.myCid;
	if (typeof this.myAutoplay != "undefined") {
		params += "&autoplay=" + this.myAutoplay
	}
	if (typeof this.myAutoUnit != "undefined") {
		params += "&auto_unit=" + this.myAutoUnit
	}
	if (typeof this.mySize != "undefined") {
		params += "&size=" + this.mySize
	}
	params += "&lang=" + this.lang();
	params += "&d=" + new Date().getTime();
	params += "&rn=" + rn;
	
	if (typeof name != "undefined" && typeof value != "undefined") {
		params = params + "&" + name + "=" + encodeURIComponent(value);
	}
	
	if (type == "imp") {
		params = params + "&refurl=" + encodeURIComponent(this.getReferrerURL());
	}

	var img = new Image(1, 1);
	img.src = this.myStats1 + "blank.gif?" + params;
	img.onload = function() { };
	
	var img2 = new Image(1, 1);
	img2.src = this.myStats2 + "blank.gif?" + params;
	img2.onload = function() { };
	
	var img3 = new Image(1, 1);
	img3.src = this.myStats3 + "blank.gif?" + params;
	img3.onload = function() { };
	
	if (type == "play" && typeof this.myThirdPartyPlayTrackingUrl != "undefined") {
		var img4 = new Image(1, 1);
		img4.src = this.myThirdPartyPlayTrackingUrl.replace("[CACHEBUSTER]", rn);
		img4.onload = function() { };
	}
	
	if (type == "imp" && typeof this.myThirdPartyImpTrackingUrl != "undefined") {
		var img5 = new Image(1, 1);
		img5.src = this.myThirdPartyImpTrackingUrl.replace("[CACHEBUSTER]", rn);
		img5.onload = function() { };
	}
}


UnrulyTracking.prototype.lang = function() {
	try {
    	if (navigator.language == null) {
    		if (navigator.userLanguage == null) {
    			return "";
    		}
    		else {
    			return navigator.userLanguage;
    		}
    	}
    	else {
    		return navigator.language;
    	}
	}
	catch (e) {
		return "";
	}
}

function unruly_5816524Widget() {
	this.adCreated = false;
	this.myUnrulyTracking = new UnrulyTracking(
		"http://stats.unrulymedia.com/", 
		"http://stats2.unrulymedia.com/", 
		"http://stats3.unrulymedia.com/", 
		1380,
		200308,
		1220,
		25,
		4971,
		801,
		'160x-1',
		false,
		false
	);
		
	this.videoUri = 'http://video.unrulymedia.com/iframe_5816524.html?d=' +	new Date().getTime() + 
    	'&rn=' + (Math.random() * 1000000) + 
    	(typeof wildfireAddParams != "undefined" ? wildfireAddParams : '') +
    	'&skipimp=true&autoplay=true&refurl=' + encodeURIComponent(document.location.href); 
		
    this.findPos = function(obj) {
    	var curleft = curtop = 0;
    	if (obj.offsetParent) {
    		curleft = obj.offsetLeft
    		curtop = obj.offsetTop
    		while (obj = obj.offsetParent) {
    			curleft += obj.offsetLeft
    			curtop += obj.offsetTop
    		}
    	}
    	return [curleft,curtop];
    }
	
	this.expand = function(open) {
		if (open) {
			if (!this.adCreated) {
				this.createIframeAd();
				this.adCreated = true;
			}

			var iframe = this.createVideoIframe();
			this.mainDiv.appendChild(iframe);
			
			this.positionAsset();
			this.enableHover = false;
		}
		else {
			var elIFrame = document.getElementById('unruly_5816524_iframe');
			elIFrame.style.left = "-3500px";
			
			this.iframeHack1.style.display = 'none';
			this.iframeHack2.style.display = 'none';
		}
	}
	
	this.hover = function(hoverIn) {
		var elFacade = document.getElementById('unruly_5816524_facade');

		if (hoverIn) {
			elFacade.style.background = "#CCC";
		}
		else {
			elFacade.style.background = "";
		}
	}
	
	this.positionAsset = function() {
		var elWrapper = document.getElementById('unruly_5816524_wrapper');
		var elIFrame = document.getElementById('unruly_5816524_iframe');
		
		var dim = this.pageDimensions();
		var pos = this.findPos(elWrapper);
		var wrapperLeft = pos[0];
		var wrapperTop = pos[1] - 1;
		
		this.iframeHack1.style.display = 'block';
		this.iframeHack1.style.top = wrapperTop + "px";
		
		this.iframeHack2.style.display = 'block';
		this.iframeHack2.style.top = (wrapperTop + 250) + "px";
		
		elIFrame.style.top = wrapperTop + "px";
		if (wrapperLeft / dim[0] < 0.5) {
			var offset = 1;
			this.iframeHack1.style.left = (wrapperLeft - offset) + "px"; 
			this.iframeHack2.style.left = (wrapperLeft - offset) + "px"; 
			elIFrame.style.left = (wrapperLeft - offset) + "px";
		}
		else {
			var offset = 120;
			this.iframeHack1.style.left = (wrapperLeft - offset) + "px"; 
			this.iframeHack2.style.left = (wrapperLeft - offset) + "px"; 
			elIFrame.style.left = (wrapperLeft - offset) + "px";
		}
		
	}
	
	this.pageDimensions = function() {
		var myWidth = 0, myHeight = 0;
        if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } 
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }
		
		return [myWidth,myHeight];
	}
	
	this.lang = function() {
		try {
        	if (navigator.language == null) {
        		if (navigator.userLanguage == null) {
        			return "";
        		}
        		else {
        			return navigator.userLanguage;
        		}
        	}
        	else {
        		return navigator.language;
        	}
		}
		catch (e) {
			return "";
		}
    }

	this.createVideoIframe = function() {
		var iframe = document.createElement('iframe');
		iframe.src = this.videoUri;
		iframe.style.width = "300px";
		iframe.style.height = "250px";
		iframe.setAttribute("frameborder", "0");
		iframe.setAttribute("scrolling", "no");
		iframe.scrolling = "no";
		iframe.frameborder = 0;
		iframe.style.background = '#fff';
		iframe.style.zIndex = 15;

		this.videoIframe = iframe;
		
		return iframe;
	}
	
	this.createIframeHack = function() {
		var iframehack = document.createElement('iframe');
		iframehack.style.display = 'none';
		iframehack.setAttribute("frameborder", "0");
		iframehack.setAttribute("scrolling", "no");
		iframehack.frameborder = 0;
		iframehack.scrolling = "no";
		iframehack.style.background = '#fff';
		iframehack.style.width = "300px";
		iframehack.style.height = "22px";
		iframehack.style.position = 'absolute';
		iframehack.style.padding = '0 !important';
		iframehack.style.margin = '0 !important';
		iframehack.style.border = '0';
		iframehack.style.zIndex = 5;

		return iframehack;
	}
	
	this.createIframeAd = function() {
		var thiss = this;
		var body = document.getElementsByTagName('body')[0];
		
		var div = document.createElement('div');
		div.id = 'unruly_5816524_iframe';
		div.style.background = '#eee';
		div.style.width = '300px';
		div.style.height = '270px';
		div.style.position = 'absolute';
		div.style.left = "-5000px";
		div.style.top = 0;
		div.style.padding = '0px !important';
		div.style.margin = '0 !important';
		div.style.background = '#fff';
		div.style.zIndex = 10;
		div.style.border = '#888 1px solid';
		this.mainDiv = div;

		var divControls = document.createElement('div');
		divControls.style.position = 'relative';
		divControls.style.padding = '0 !important';
		divControls.style.paddingTop = '0';
		divControls.style.paddingLeft = '0';
		divControls.style.margin = '0 !important';
		divControls.style.background = '#eee';
		divControls.style.height = '20px';

		var img = document.createElement('img');
		img.src = "http://video.unrulymedia.com/close.gif";
		img.width = 14;
		img.height = 14;
		img.style.border = 0;

		var a = document.createElement('a');
		a.style.position = 'absolute';
		a.style.textDecoration = 'none';
		a.style.border = 0;
		a.style.top = "3px";
		a.style.right = "3px";
		a.href = '#';
		a.onclick = function() {
			thiss.expand(false);
			thiss.mainDiv.removeChild(thiss.videoIframe);
			return false;
		}
		a.appendChild(img);
		a.onmouseover = function() {
			img.src = "http://video.unrulymedia.com/close_hover.gif";
		}
		a.onmouseout = function() {
			img.src = "http://video.unrulymedia.com/close.gif";
		}
		
		divControls.appendChild(a);
		
		var title = "The Conduit";
		var divTitle = document.createElement("div");
		divTitle.style.position = "absolute";
		divTitle.style.top = "2px";
		divTitle.style.left = "3px";
		divTitle.style.fontWeight = 'normal';
		divTitle.style.fontSize = '12px';
		divTitle.style.fontFamily = 'arial,sans-serif';
		
		divTitle.appendChild(document.createTextNode(title));

		divControls.appendChild(divTitle);
		div.appendChild(divControls);
		
		var iframeHack1 = this.createIframeHack();
		this.iframeHack1 = iframeHack1;
		
		var iframeHack2 = this.createIframeHack();
		this.iframeHack2 = iframeHack2;
		
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(iframeHack1);
		body.appendChild(iframeHack2);
		body.appendChild(div);
	}
	
	//output the ad wrapper
	document.write('<div style="border: 0 !important; padding: 0 !important; margin: 0 !important; width: 160px;" id="unruly_5816524_wrapper"');
   	document.write(' >');
    	
    document.write('<div style="border: 0 !important; padding: 2px !important; margin: 0px !important;" id="unruly_5816524_facade">');
    document.write('<a style="border: 0 !important;" href="#" onmouseover="unruly_5816524w.hover(true);" onmouseout="unruly_5816524w.hover(false);" onclick="unruly_5816524w.expand(true); return false;"><img src="http://cloud.video.unrulymedia.com/7k9ai-1246448915769_t.jpg?1" width="156" height="117" title="Watch me" border="0"></a>');
    document.write('</div>');
	document.write("The Conduit");
    
   	document.write('</div>');
	this.myUnrulyTracking.track("imp");
}

var unruly_5816524w = new unruly_5816524Widget();