﻿(function() {
	if (typeof __StruqMedia !== "undefined")
		return;

	__StruqMedia = function(sid) {
		this.sid = sid;
		
		var parseParam = function(p)
		{
			return (typeof p == 'undefined' || p == "" || p == null) ? "-" : p;
		}
			
		this.buildUrl = function(data) {
			var rnd = parseInt(Math.random() * 10000000000000000);
			var protocol = (document.location.protocol == "https:" ? "https:" : "http:");
			
			if (this.sid == 9) {
				document.write("<img src='" + protocol + "//app.struq.com/content/pixel.gif?s=1&rnd=" + rnd + "'>");
			}
		
			return protocol + "//app.struq.com/t/i/"
				+ rnd + "/"
				+ parseParam(data.c) + "/"
				+ parseParam(data.pid) + "/"
				+ "?v=2&sid=" + this.sid
				+ "&src=" + escape(document.URL)
				+ "&sref=" + escape(document.referrer)
				+ "&rnd=" + rnd;
		}

		this.writeScript = function(url) {
			document.write("<iframe src='" + url + "' width='1' height='1' frameborder='0' marginheight='0' marginwidth='0' scrolling='no' xstyle='display:none'></iframe>");
		}

		this.load = function() {
			this.track("b");
		}

		this.track = function(k) {
			this.track2(null, "-");
		}

		this.track2 = function(k, c) {
			this.writeScript(this.buildUrl({ c: c }));
		}

		this.track3 = function(data) {
			this.writeScript(this.buildUrl(data));
		}

		this.trackEvent = function(data) {
			this.writeScript(this.buildUrl(data));
		}

	}

	if (typeof __StruqMediaAutoRun !== 'undefined') {
		__StruqMediaAutoRun();
	}

	return;
})();
