var gsm_gemius_proto = (document.location && document.location.protocol && document.location.protocol=='https:')?'https://':'http://';
if (typeof gsm_gemius_hitcollector == 'undefined') {
	gsm_gemius_hitcollector = 'pro.hit.gemius.pl';
}
var gsm_gemius_host = gsm_gemius_proto+gsm_gemius_hitcollector+'/_';

function gsm_gemius_parameters_fn() {
	var d=document;
	var href=new String(d.location.href);
	var ref;
	var f=0;
	var fv='-';
	if (d.referrer) { ref=new String(d.referrer); } else { ref=''; }
	if (typeof Error!='undefined') {
		var fo;
		eval('try { f=(d==top.document)?1:2; if (typeof top.document.referrer=="string") { ref=top.document.referrer } } catch(e) {f=3;}');
		eval('try { fv=navigator.plugins["Shockwave Flash"].description; } catch (e) {}');
		eval('if (typeof ActiveXObject!="undefined") { try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch(e) { try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); fv="X"; fo.AllowScriptAccess="always"; } catch(e) { if (fv=="X") { fv="WIN 6,0,20,0"; }} try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e) {} } if ((fv=="-" || fv=="X") && fo) { fv=fo.GetVariable("$version"); }}');
	}
	var url='&fr='+f+'&fv='+escape(fv)+'&tz='+(new Date()).getTimezoneOffset()+'&href='+escape(href.substring(0,1024))+'&ref='+escape(ref.substring(0,1024));
	if (screen) {
		var s=screen;
		if (s.width) url+='&screen='+s.width+'x'+s.height;
		if (s.colorDepth) url+='&col='+s.colorDepth;
	}
	return url;
}

var gsm_gemius_parameters = gsm_gemius_parameters_fn();

function gsm_gemius_escape(str,limit) {
	function Hex(n) {
		var hexMap = "0123456789ABCDEF";
		return hexMap.charAt(n>>4)+hexMap.charAt(n&0xF);
	}
	var c,s,uc,ul;
	var dst = "";
	for (var i=0 ; i<str.length ; i++) {
		c = str.charCodeAt(i);
		if ((c>=0xDC00)&&(c<0xE000)) continue;
		if ((c>=0xD800)&&(c<0xDC00)) {
			i++;
			if (i>=str.length) continue;
			s = str.charCodeAt(i);
			if ((s<0xDC00)||(s>=0xE000)) continue;
			c = ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
		}
		if (c<0x80) {
			uc = escape(String.fromCharCode(c)).replace(/\+/g,"%2B").replace(/\//g,"%2F");
			if (c<=0x20) {
				ul=3;
			} else {
				ul=1;
			}
		} else if (c<0x800) {
			uc = "%"+Hex((c>>6)|0xC0)+"%"+Hex((c&0x3F)|0x80);
			ul = 2;
		} else if (c<0x10000) {
			uc = "%"+Hex((c>>12)|0xE0)+"%"+Hex(((c>>6)&0x3F)|0x80)+"%"+Hex((c&0x3F)|0x80);
			ul = 3;
		} else if (c<0x200000) {
			uc = "%"+Hex((c>>18)|0xF0)+"%"+Hex(((c>>12)&0x3F)|0x80)+"%"+Hex(((c>>6)&0x3F)|0x80)+"%"+Hex((c&0x3F)|0x80);
			ul = 4;
		} else {
			uc = "";
			ul = 0;
		} 
		limit -= ul;
		if (limit<0) {
			return dst;
		}
		dst+=uc;
	}
	return dst;
}
/*
 *
 * Gemius Stream v 4.3
 *
 */
if(!gSmDebug){
	var gSmDebug = new function(){
		this.HTML_DIV = "gSmDebugConsole";
		this.WINDOW = undefined;
		this._debugMode = "none";
		this.DEBUG_WINDOW = "window";
		this.DEBUG_PAGE = "page";
		this.ready = false;
		this.events = new Array();
		this.init = function(){
			if(String(window.location).split("#gSmDebugMode="+this.DEBUG_WINDOW).length>1){
				this._debugMode = this.DEBUG_WINDOW;
			}else if(String(window.location).split("#gSmDebugMode="+this.DEBUG_PAGE).length>1){
				this._debugMode = this.DEBUG_PAGE;
			}
			if(this._debugMode == this.DEBUG_WINDOW){
				var content = "<HTML><HEAD><TITLE>gSm - debug</TITLE></HEAD><BODY style=\"background: #000000;margin: 0;word-wrap: break-word\">";
				content += "<div id=\""+this.HTML_DIV+"\" style=\"padding: 5px;width: 100%;height: 100%;overflow: auto;background: #000000;\"></div></HTML>";
				this.WINDOW = window.open("","gSmDebugWindow","menubar=0,location=0,resizable=1,scrollbars=0,status=0,width=600,height=300");
				if(!this.WINDOW.document.getElementById(this.HTML_DIV)){
					this.WINDOW.document.open();
					this.WINDOW.document.write(content);
					this.WINDOW.document.close();
				}
			}
			if (window.addEventListener){
				window.addEventListener('load',this.onLoad,true);
			}else if(window.attachEvent){
				window.attachEvent('onload',this.onLoad);
			}
		}
		this.onLoad = function(){
			gSmDebug.ready = true;
			for(var i=0 ; i<gSmDebug.events.length ; i++){
				gSmDebug.trace(gSmDebug.events[i]);
			}
			gSmDebug.events = [];
		}
		this.trace = function(arr){
			if(!this.ready){
				this.events.push(arr);
				return;
			}
			switch(this._debugMode){
				case this.DEBUG_PAGE:
					this.traceDebugPage(arr);
					break;
				case this.DEBUG_WINDOW:
					this.traceDebugWindow(arr);
					break;
			}
		}
		this.traceDebugPage = function(arr){
			try{
				var element = document.getElementById(this.HTML_DIV);
				element.style.wordWrap = "break-word";
				element.style.background = "#000000";
				element.style.overflow = "auto";
				element.innerHTML += this.formatEvent(arr)+"<br />";
			}catch(e){}
		}
		this.traceDebugWindow = function(arr){
			if(this.WINDOW){
				try{
					var element = this.WINDOW.document.getElementById(this.HTML_DIV);
					element.innerHTML += this.formatEvent(arr)+"<br />";
				}catch(e){}
			}
		}
		this.formatEvent = function(arr){
			var leftType = "<span style=\"font: bold 11px Arial, Helvetica, sans-serif;color: #13b884;\">";
			var color;
			switch(arr[0]){
				case "newStream":
					color = "#117ed2";
					break;
				case "closeStream":
					color = "#ff00b4";
					break;
				case "event":
					color = "#686868";
					break;
				case "traceData":
					color = "#eaa500";
					break;
				case "timeCheck":
					color = "#7ebe19";
					break;
				default:
					color = "#666666";
					break;
			}
			var hour = (new Date()).getHours();
			var min = (new Date()).getMinutes();
			var sec = (new Date()).getSeconds();
			var time = ((hour<10)?("0"+hour):hour) + ":" + ((min<10)?("0"+min):min)+":" + ((sec<10)?("0"+sec):sec);
			var left = "<span style=\"font: 11px Arial, Helvetica, sans-serif;color: "+color+";\">";
			var str = "<span style=\"font: normal 11px Arial, Helvetica, sans-serif;color: #654384;\">" + time + "&nbsp;&nbsp;</span>" + leftType + arr[0]+" &nbsp;&nbsp;&nbsp;&nbsp;" + "</span>";
			arr.shift();arr.shift();
			str += left + arr.join(" &nbsp;&nbsp;&nbsp;&nbsp;") + "</span>";
			return str;
		}
		this.init();
	}
}
if(!gSmUtil){
	var gSmUtil = new function(){
		this.sid = "";
		this.protectedInterval = 100;
		this.oldSystemTime = (new Date()).getTime();
		this.oldSystemTimeTmp = (new Date()).getTime();
		this.newSystemTime = (new Date()).getTime();
		this.currentTime = 0;
		this.delta = 0;
		this.init = function(){
			while(this.sid.length<10){
				this.sid += Math.round(Math.random()*32).toString(32);
			}
			setTimeout("gSmUtil.updateProtectedTime()", this.protectedInterval);
		}
		this.updateProtectedTime = function(){
			setTimeout("gSmUtil.updateProtectedTime()", gSmUtil.protectedInterval);
			gSmUtil.newSystemTime = (new Date()).getTime();
			var diff = gSmUtil.newSystemTime - gSmUtil.oldSystemTimeTmp - gSmUtil.protectedInterval;
			if(diff < -1000 || diff > 60000){
				gSmUtil.delta += gSmUtil.oldSystemTimeTmp - gSmUtil.newSystemTime + gSmUtil.protectedInterval;
			}
			gSmUtil.oldSystemTimeTmp = gSmUtil.newSystemTime;
			gSmUtil.currentTime = Math.floor((gSmUtil.newSystemTime - gSmUtil.oldSystemTime + gSmUtil.delta)/1000);
		}
		this.formatString = function(string, maxLength, restricted){
			string = (string.length>maxLength)?string.substr(0, maxLength):string;
			for(var i=0 ; i<restricted.length ; i++){
				string = string.replace(restricted[i], " ");
			}
			return string;
		}
		this.getTimeSec = function(){
			return this.currentTime;
		}
		this.isOpera = function(){
			return (window.opera);
		}
		this.isSafari = function(){
			if(this.isChrome())return false;
			return (navigator.userAgent.toLowerCase().indexOf('safari')!=-1);
		}
		this.isChrome = function(){
			return (navigator.userAgent.toLowerCase().indexOf('chrome')!=-1);
		}
		this.isIE = function(){
			return (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
		}
		this.isFF = function(){
			return (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
		}
		this.getBytesLength = function(str) {
			return encodeURIComponent(str).replace(/%../g, 'x').length;
		};
		this.limitBytesLength = function(str, maxBytes, restricted) {
			var currBytes = 0;
			var outStr = "";
			for(var i=0 ; i<restricted.length ; i++){
				str = str.replace(restricted[i], " ");
			}
			for (var i = 0 ; i < str.length ; i++ ) {
				currBytes += gSmUtil.getBytesLength(str.charAt(i));
				if (currBytes > maxBytes) {
					return outStr;
				}
				outStr += str.charAt(i);
			}
			return outStr;
		};
		this.init();
	}
}
if(!gSmNoUnload){
	var gSmNoUnload = new function(){
		this.streams = [];
		this.init = function(){
			if(this.hasUnload())return;
			this.sendAllStreams();
			setTimeout("gSmNoUnload.updateStreams()", 500);
		}
		this.hasUnload = function(){
			if(gSmUtil.isOpera() || gSmUtil.isChrome() || gSmUtil.isSafari())return false;
			return true;
		}
		this.addStream = function(stream, gSmId, gSmHc){
			if(this.hasUnload())return;
			var cookieId = ("gsm_"+(new Date()).getTime()+""+Math.round(Math.random()*1000));
			this.streams.push({cookieId:cookieId ,stream:stream, identifier:gSmId, hitcollector:gSmHc, startTime:(new Date()).getTime(), parameters:gsm_gemius_parameters});
			return cookieId;
		}
		this.updateStream = function(cookieId){
			if(this.hasUnload())return;
			var stream, hitcollector, identifier, encoding, lastTime;
			stream = this.getStream(cookieId);
			identifier = stream.identifier;
			hitcollector = stream.hitcollector;
			parameters = stream.parameters;
			encoding = gSmConfig.ENCODING;
			lastTime = (new Date()).getTime();
			this.writeStream(cookieId, hitcollector, identifier, encoding, stream.startTime, lastTime, stream.stream.getCurrentPackage(), parameters);
		}
		this.getStream = function(cookieId){
			for(var i=0 ; i<this.streams.length ; i++){
				if(this.streams[i].cookieId == cookieId)return this.streams[i];
			}
		}
		this.updateStreams = function(){
			setTimeout("gSmNoUnload.updateStreams()", 500);
			for(var i=0 ; i<gSmNoUnload.streams.length ; i++){
				gSmNoUnload.updateStream(gSmNoUnload.streams[i].cookieId);
			}
		}
		this.writeStream = function(cookieId, hitcollector, identifier, encoding, startTime, lastTime, data, parameters){
			this.createCookie(cookieId,(escape(gSmUtil.sid)+"|"+escape(hitcollector)+"|"+escape(identifier)+"|"+escape(encoding)+"|"+escape(startTime)+"|"+escape(lastTime)+"|"+escape(data)+"|"+escape(parameters)),10);
		}
		this.sendAllStreams = function(){
			var streamsData = this.getAllCookies();
			for(var s in streamsData){
				if((new Date()).getTime() - streamsData[s].lastTime>2000){
					var tdiff = (new Date()).getTime() - streamsData[s].startTime;
					if(tdiff>0 && tdiff<259200000){
						var dataArr = streamsData[s].data.split("|");
						var lastEventArr = dataArr[dataArr.length-1].split(";");
						if(lastEventArr[lastEventArr.length - 1] == 0){
							dataArr.splice(dataArr.length-1, 1);
						}
						if(dataArr.length>6){
							dataArr[5] = Number(dataArr[5])+Math.round(tdiff/1000);
							streamsData[s].data = dataArr.join("|");
							this.sendStream(streamsData[s].hitcollector, streamsData[s].identifier, streamsData[s].encoding, streamsData[s].data, streamsData[s].parameters);
						}
					}
					this.eraseCookie(s);
				}
			}
		}
		this.sendStream = function(hitcollector, identifier, encoding, data, parameters){
			if (typeof window.gsm_gemius_images == 'undefined') {
				window.gsm_gemius_images = new Array();
			}
			var gemius_l = window.gsm_gemius_images.length;
			window.gsm_gemius_images[gemius_l] = new Image();
			window.gsm_gemius_images[gemius_l].src = hitcollector+(new Date()).getTime()+'/redot.gif?id='+identifier+'&sargencoding='+encoding+'&sarg='+gsm_gemius_escape(data,1023)+parameters;
			gSmDebug.trace(["traceData", 0,data]);
		}
		this.getAllCookies = function(){
			var pairs = document.cookie.split(";");
			var cookies = {};
			var params;
			for (var i=0; i<pairs.length; i++){
				var pair = pairs[i].split("=");
				if(pair[0].split("gsm_").length>1){
					params = pair[1].split("|");
					cookies[pair[0]] = {
						sid: unescape(params[0]),
						hitcollector: unescape(params[1]),
						identifier: unescape(params[2]),
						encoding: unescape(params[3]),
						startTime: unescape(params[4]),
						lastTime: unescape(params[5]),
						data: unescape(params[6]),
						parameters: unescape(params[7])
					};
				}
			}
			return cookies;
		}
		this.createCookie = function(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}
		this.readCookie = function(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}
		this.eraseCookie = function(name) {
			this.createCookie(name,"",-1);
		}
		this.init();
	}
}
var gSmStream = function(contentId, player){
	this.contentId = contentId;
	this.contentIdFormated = gSmUtil.limitBytesLength(contentId, gSmConfig.MAX_ID_LENGTH, gSmConfig.ID_RES);
	this.player = player;
	this.init = function(){
		this.duration = null;
		this.time = null;
		this.customPackageString = "";
		this.lastPlayTime = null;
		this.lastEvent = "";
		this.lastPlayEndTime = null;
		this.firstTimeStamp = gSmUtil.getTimeSec();
		this.lastTimeStamp = gSmUtil.getTimeSec();
		this.isPlaying = false;
		this.forcedClose = false;
		this.controlBreak = false;
		this.eventString = "";
		this.infoString = ""
		this.viewId = "";
		this.cookieId = "";
		this.gSmId = "";
		this.gSmHost = "";
	}
	this.init();
	this.newStream = function (duration, customPackage, additionalPackage, gSmId, gSmHc){
		this.init();
		this.gSmId = (gSmId == undefined || gSmId == null)?gsm_gemius_identifier:gSmId;
		this.gSmHc = (gSmHc == undefined || gSmHc == null)?gsm_gemius_host:(gSmHc+"/_");
		this.cookieId = gSmNoUnload.addStream(this, this.gSmId, this.gSmHc);
		this.duration = (duration>0)?Math.round(duration):-1;
		this.time = 0;
		var criterion;
		var category;
		var max_i = (customPackage.length > gSmConfig.MAX_CRITERIONS)?gSmConfig.MAX_CRITERIONS:customPackage.length;
		for(var i=0 ; i<max_i ; i++){
			criterion = gSmUtil.limitBytesLength(customPackage[i]["name"], gSmConfig.MAX_CRITERION_LENGTH, gSmConfig.CRITERION_RES);
			category = gSmUtil.limitBytesLength(customPackage[i]["value"], gSmConfig.MAX_CATEGORY_LENGTH, gSmConfig.CATEGORY_RES);
			this.customPackageString += ((i==0)?"":";") + criterion + "=" + category;
		}
		gSmDebug.trace(["newStream", this.player.playerId, this.contentId, this.duration, this.customPackageString]);
	}
	this.getCurrentPackage = function(){
		return this.getFormatedData() + "|" + Math.round(this.lastTimeStamp - this.firstTimeStamp)+";"+Math.round(this.lastPlayTime)+";"+Math.round(this.getPlayLength(true));
	}
	this.closeStream = function(time){
		this.time = time;
		this.lastPlayEndTime = time;
		gSmDebug.trace(["closeStream", this.player.playerId, this.contentId, Math.round(this.time)]);
		this.sendStream();
		this.isPlaying = false;
	}
	this.closeStreamForced = function(){
		gSmDebug.trace(["closeStream", this.player.playerId, this.contentId, Math.round(this.time)]);
		this.forcedClose = true;
		this.sendStream();
		this.isPlaying = false;
	}
	this.sendStream = function(controlBreak){
		this.controlBreak = (controlBreak == undefined || controlBreak == null)?"":controlBreak;
		if(this.controlBreak == "time" && (this.getCurrEvent()+this.eventString!="")){
			if(this.viewId == "")this.viewId = gemiusStream.newViewId();
		}
		var playLength = this.getPlayLength();
		var currEvent = this.getCurrEvent();
		if(!this.checkLength(currEvent)){
			this.eventString += this.makeCurrEventViewId(currEvent);
			this.sendHit("");
			this.lastPlayTime += playLength;
		}
	}
	this.sendFirsPlayingEvent = function(){
		this.sendHit("",true);
		this.firsPlayingEvent = true;
	}
	this.event = function(time, eventType){
		this.forcedClose = false;
		this.time = time;
		if(this.lastEvent == eventType)return;
		gSmDebug.trace(["event", this.player.playerId, this.contentId, Math.round(time), eventType]);
		switch(eventType){
			case "playing":
				if(!this.firsPlayingEvent) this.sendFirsPlayingEvent();
				if(this.isPlaying) return;
				if(this.eventString == "") this.firstTimeStamp = gSmUtil.getTimeSec();
				this.lastTimeStamp = gSmUtil.getTimeSec();
				this.lastPlayTime = time;
				this.isPlaying = true;
				this.viewId = "";
				break;
			case "complete":
				this.lastPlayEndTime = time;
				this.sendStream();
				this.isPlaying = false;
				this.viewId = "";
				break;
			default:
				if(this.lastPlayTime == null)return;
				this.lastPlayEndTime = time;
				this.controlBreak = "length";
				var currEvent = this.getCurrEvent();
				if(!this.checkLength(currEvent)){
					this.eventString += this.makeCurrEventViewId(currEvent);
				}
				this.isPlaying = false;
				break;
		}
	}
	this.makeCurrEventViewId = function(currEvent){
		return currEvent+((this.viewId!="" && currEvent!="")?(";"+this.viewId):(""));
	}
	this.getPlayLength = function(operaCheck){
		if(operaCheck == undefined || operaCheck == null)operaCheck = false;
		if(this.isPlaying == false) return 0;
		var tCalc, tGet, tGetR;
		tCalc = gSmUtil.getTimeSec() - this.lastTimeStamp;
		tGet = this.lastPlayEndTime - this.lastPlayTime;
		tGetR = Math.round(this.lastPlayEndTime) - Math.round(this.lastPlayTime);
		if(this.forcedClose == true || this.duration==-1 || this.controlBreak != "" || operaCheck == true){
			return tCalc;
		}else if(tGetR==1 || tGetR==0){
			return tGetR;
		}else if(tCalc<=0){
			return tGet;
		}else if(tGet<=0){
			return tCalc;
		}else{
			return Math.min(tCalc, tGet);
		}
	}
	this.getCurrEvent = function(){
		var playLength = Math.round(this.getPlayLength());
		if(playLength > 0){
			return "|" + Math.round(this.lastTimeStamp - this.firstTimeStamp)+";"+Math.round(this.lastPlayTime)+";"+playLength;
		}else{
			return "";
		}
	}
	this.sendHit = function(currEvent, forced){
		if(forced == undefined) forced = false;
		if(this.eventString == "" && currEvent == "" && forced == false){
			return;
		}
		this.eventString += currEvent;
		var outputData = this.getFormatedData(forced);
		this.eventString = "";
		this.firstTimeStamp = gSmUtil.getTimeSec();
		this.lastTimeStamp = gSmUtil.getTimeSec();
		if (typeof window.gsm_gemius_images == 'undefined') {
			window.gsm_gemius_images = new Array();
		}
		var gemius_l = window.gsm_gemius_images.length;
		window.gsm_gemius_images[gemius_l] = new Image();
		window.gsm_gemius_images[gemius_l].src = this.gSmHc+(new Date()).getTime()+'/redot.gif?id='+this.gSmId+'&sargencoding='+gSmConfig.ENCODING+'&sarg='+gsm_gemius_escape(outputData,1023)+gsm_gemius_parameters;
		gSmNoUnload.updateStream(this.cookieId);
		gSmDebug.trace(["traceData", 0,outputData]);
	}
	this.hasEvent = function(){
		this.forcedClose = true;
		if(this.eventString + this.getCurrEvent() != "")return true;
		return false;
	}
	this.checkLength = function(currEvent){
		if(gSmUtil.getBytesLength(this.getFormatedData()) + currEvent.length + 1 >= (gSmConfig.MAX_LOG_LENGTH + gSmConfig.VIEW_ID_LENGTH)){
			this.sendHit(currEvent);
			return true;
		}
		return false;
	}
	this.getFormatedData = function(forced){
		var out = "";
		var delta = Math.round(gSmUtil.getTimeSec() - this.firstTimeStamp);
		var additionalVector = "";
		var forcedData = "";
		if(forced){
			forcedData = "|f;"+Math.round(gSmUtil.getTimeSec() - this.firstTimeStamp)+";"+Math.round(this.lastPlayTime);
		}
		this.infoString = "v="+gSmConfig.VERSION+"|"+this.contentIdFormated+"|"+this.duration+"|"+this.customPackageString+"|"+additionalVector+"|"+delta+forcedData;
		out = this.infoString+this.eventString;
		return out;
	}
}
var gSmPlayer = function(playerId){
	this.playerId = playerId;
	this.streamsArray = new Array();
	this.newStream = function(contentId, duration, customPackage, additionalPackage, gSmId, gSmHost){
		var stream = this.getStream(contentId, true);
		stream.newStream(duration, customPackage, additionalPackage, gSmId, gSmHost);
	}
	this.closeStream = function(contentId, time){
		var stream = this.getStream(contentId);
		if(stream == null)return;
		stream.closeStream(time);
		this.removeStream(contentId);
	}
	this.event = function(contentId, time, eventType){
		var stream = this.getStream(contentId);
		if(stream == null)return;
		stream.event(time, eventType);
	}
	this.getStream = function(contentId, forced){
		forced = (forced)?true:false;
		var stream = null;
		for(var i=0 ; i<this.streamsArray.length ; i++){
			if(this.streamsArray[i].contentId == contentId) stream = this.streamsArray[i];
		}
		if(stream == null && forced){
			stream = new gSmStream(contentId, this);
			this.streamsArray.push(stream);
		}
		return stream;
	}
	this.removeStream = function(contentId){
		for(var i=0 ; i<this.streamsArray.length ; i++){
			if(this.streamsArray[i].contentId == contentId){
				delete this.streamsArray[i];
				this.streamsArray.splice(i,1);
			}
		}
	}
	this.sendAllStreams = function(type){
		for(var i=0 ; i<this.streamsArray.length ; i++){
			this.streamsArray[i].sendStream(type);
		}
	}
	this.checkAllStreams = function(){
		for(var i=0 ; i<this.streamsArray.length ; i++){
			if(this.streamsArray[i].hasEvent())return true;
		}
		return false;
	}
	this.closeAllStreams = function(){
		for(var i=0 ; i<this.streamsArray.length ; i++){
			this.streamsArray[i].closeStreamForced();
		}
	}
}
if(!gSmConfig){
	var gSmConfig = new function(){
		this.VERSION = 4;
		this.MAX_CRITERIONS = 6;
		this.MAX_CRITERION_LENGTH = 16;
		this.MAX_CATEGORY_LENGTH = 64;
		this.MAX_ID_LENGTH = 64;
		this.VIEW_ID_LENGTH = 16;
		this.ID_RES = ["|","*","\n","\t","\r"];
		this.CRITERION_RES = ["|","*","\n","\t","\r",";","=","/","#"];
		this.CATEGORY_RES = ["|","*","\n","\t","\r",";","=","/","#"];
		this.TIMEOUT = 300;
		this.MAX_LOG_LENGTH = 990;
		this.ENCODING = "utf-8";
		this.setEncoding = function(encoding){
			this.ENCODING = encoding;
		}
	}
}
if(!gemiusStream){
	var gemiusStream = new function(){
		this.lastTimeCheck = gSmUtil.getTimeSec();
		this.init = function(){
			this.session = (new Date()).getTime().toString(36)+Math.round(Math.random()*100000000).toString(36)+Math.round(Math.random()*100000000).toString(36);
			this.flashObjectsArray = new Array();
			this.playersArray = new Array();
			if(gSmNoUnload.hasUnload()){
				if (window.addEventListener){
					window.addEventListener('unload',this.onUnload,true);
				}else if(window.attachEvent){
					window.attachEvent('onunload',this.onUnload);
				}
			}
			setTimeout("gemiusStream.timeCheck()", 1000);
		}
		this.newStream = function(playerId, contentId, duration, customPackage, additionalPackage, gSmId, gSmHc){
			if(customPackage == null)customPackage = new Array();
			if(additionalPackage == null)additionalPackage = new Array();
			if(playerId == null || contentId == null) return;
			var player = this.getPlayer(playerId);
			player.newStream(contentId, duration, customPackage, additionalPackage, gSmId, gSmHc);
		}
		this.closeStream = function(playerId, contentId, time){
			if(playerId == null || contentId == null) return;
			var player = this.getPlayer(playerId);
			player.closeStream(contentId, time);
		}
		this.event = function(playerId, contentId, time, eventType){
			if(playerId == null || contentId == null) return;
			var player = this.getPlayer(playerId);
			player.event(contentId, time, eventType);
		}
		this.getPlayer = function(playerId){
			var player = null;
			for(var i=0 ; i<this.playersArray.length ; i++){
				if(this.playersArray[i].playerId == playerId) player = this.playersArray[i];
			}
			if(player == null){
				player = new gSmPlayer(playerId);
				this.playersArray.push(player);
			}
			return player;
		}
		this.timeCheck = function(){
			setTimeout("gemiusStream.timeCheck()", 1000);
			if(gSmUtil.getTimeSec() - gemiusStream.lastTimeCheck >= gSmConfig.TIMEOUT){
				gemiusStream.lastTimeCheck = gSmUtil.getTimeSec();
				gSmDebug.trace(["timeCheck"]);
				this.sendAllStreams();
			}
		}
		this.sendAllStreams = function(){
			for(var i=0 ; i<this.playersArray.length ; i++){
				this.playersArray[i].sendAllStreams("time");
			}
		}
		this.checkAllStreams = function(){
			for(var i=0 ; i<this.playersArray.length ; i++){
				if(this.playersArray[i].checkAllStreams())return true;
			}
			return false;
		}
		this.closeAllStreams = function(){
			for(var i=0 ; i<this.playersArray.length ; i++){
				this.playersArray[i].closeAllStreams();
			}
		}
		this.registerFlashObject = function(objectId){
			if(objectId == null) return;
			for(var i=0 ; i<this.flashObjectsArray.length ; i++){
				if(objectId == this.flashObjectsArray[i]) return;
			}
			this.flashObjectsArray.push(objectId);
		}
		this.onUnload = function(){
			if(!gemiusStream.checkAllStreams())return;
			gemiusStream.closeAllStreams();
			var start = (new Date()).getTime();
			while (start+200>(new Date()).getTime());
		}
		this._viewId = 0;
		this.viewId = function(){
			return this._viewId;
		}
		this.newViewId = function(){
			this._viewId++;
			return this._viewId;
		}
		this.init();
	}
}
if(!gemius_sarg_proto){
	var gemius_sarg_proto;
	if(document.location && document.location.protocol) {
		gemius_sarg_proto = 'http'+((document.location.protocol=='https:')?'s':'')+'://';
	} else {
		gemius_sarg_proto = 'http://';
	}
	function gemius_parameters() {
		var d=document;
		var href=new String(d.location.href);
		var ref;
		if (d.referrer) { ref = new String(d.referrer); } else { ref = ""; }
		var t=typeof Error;
		if(t!='undefined') {
			eval("try { if (typeof(top.document.referrer)=='string') { ref = top.document.referrer } } catch(gemius_ex) { }")
		}
		var url='&tz='+(new Date()).getTimezoneOffset()+'&href='+escape(href.substring(0,299))+'&ref='+escape(ref.substring(0,299));
		if (screen) {
			var s=screen;
			if (s.width) url+='&screen='+s.width+'x'+s.height;
			if (s.colorDepth) url+='&col='+s.colorDepth;
		}
		return url;
	}
	function gemius_sarg_hit(sarg) {
		var gemius_url = gemius_sarg_proto+gsm_gemius_host+'/_'+(new Date()).getTime()+'/redot.gif?l=16&id='+gsm_gemius_identifier+'&sarg='+sarg+gemius_parameters();
		if (typeof window.gemius_sarg_images == 'undefined') {
				window.gemius_sarg_images = new Array();
		}
		var gemius_l = window.gemius_sarg_images.length;
		if (typeof gemius_sarg_sem == 'undefined') {
				gemius_sarg_sem=0;
		}
		if (gemius_l<=gemius_sarg_sem) {
				window.gemius_sarg_images[gemius_l]=new Image();
				window.gemius_sarg_images[gemius_l].src = gemius_url;
		}
		gemius_sarg_sem++;
	}
	function gemius_generate_STM(){
		var STM = (new Date()).getTime().toString(36)+Math.round(Math.random()*100000000).toString(36)+Math.round(Math.random()*100000000).toString(36);
		gemius_sarg_hit("SESSION_TO_MATCH="+STM);
		return STM;
	}
	function gemius_url(url, STM, id, catArray, enc, additional){
		additional = typeof(additional) != 'undefined' ? additional : "";
		var gemius_url = url + "?SESSION_TO_MATCH=" + STM + "&MATERIAL_IDENTIFIER=" + id.toString();
		for(var i=0; i<catArray.length; ++i){
			gemius_url += "&" + catArray[i][0] + "=" + catArray[i][1];
		}
		gemius_url += "&ENCODING=" + enc + additional;
		return gemius_url;
	}
}