var plainplay_maxtime = 10;var plainplay_pageid = 92;var plainplay_msg = '10,7,';var plainplay_width = 140;var plainplay_height = 90;var plainplay_maxmsgs=4;var plainplay_ad_div = "plainplay_id_msgs_92";document.write('<div id="plainplay_id_msg_container" style="width: 100%; overflow-x: hidden; overflow-y: hidden; overflow: hidden; font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: normal; margin: 0px; padding: 0px; background-color: white; text-align:left;">');document.write('<div id="plainplay_id_msgs_92" style="word-wrap: break-word; text-align:left;"> </div> </div>');var plainplay_click_for_more = "Klikkaa lisätietoja!";var plainplay_day = "päivä";var plainplay_days = "päivää";var plainplay_week = "viikko";var plainplay_weeks = "viikkoa";var plainplay_title = "Jätä ilmoitus";var plainplay_text = "Tähän oma ilmoitus minuutissa.";var plainplay_price_only = "Hinta vain";var plainplay_currency = "\u20AC";var plainplay_locale = "&cc=fi&cl=fi";
function plainplay_ad_add(container, title, description, httplink, linkid, isInfo)
{
	if (!container)
		return;

	var oDiv;

	oDiv = document.createElement('a');

	if (!oDiv)
		return;

	oDiv.setAttribute("href", linkid);
	oDiv.setAttribute("target", "_blank");
	oDiv.setAttribute("title", plainplay_click_for_more);
	oDiv.setAttribute("style", "display: block; top: 0; left: 0; text-decoration: none; width: "+plainplay_width+"px; height: "+plainplay_height+"px; border-top: solid red 1px; cursor: pointer; position: relative; overflow-x: hidden; overflow-y: hidden; overflow: hidden; text-align: left;");

oDiv.style.display = "block";
oDiv.style.top = "0";
oDiv.style.left = "0";
oDiv.style.textDecoration = "none";
oDiv.style.width = plainplay_width+"px";
oDiv.style.height = plainplay_height+"px";
oDiv.style.borderTop = "solid red 1px";
oDiv.style.cursor = "pointer";
oDiv.style.position = "relative";
oDiv.style.overflowX = "hidden";
oDiv.style.overflowY = "hidden";
oDiv.style.overflow = "hidden";
oDiv.style.textAlign = "left";

	if (container.appendChild(oDiv))
	{
		if (title)
		{
			var titleDiv = document.createElement('div');
			if (titleDiv)
			{
				var newText = document.createTextNode(title);
				if (newText)
				{
					titleDiv.appendChild(newText);
					var title_style;
					if (isInfo)
					{
						title_style = "font-size: 12px; white-space: nowrap; padding-top: 1px; color: red;";
					} else
					{
						title_style = "font-size: 12px; white-space: nowrap; padding-top: 1px; color: green; height: 16px; overflow: hidden;";
					}
					titleDiv.setAttribute("style", title_style);
					if (isInfo)
					{
						title_style = "font-size: 12px; white-space: nowrap; padding-top: 1px; color: red;";
titleDiv.style.color = "red";
					} else
					{
						title_style = "font-size: 12px; white-space: nowrap; padding-top: 1px; color: green; height: 16px; overflow: hidden;";
titleDiv.style.color = "green";
titleDiv.style.height = "16px";
titleDiv.style.overflow = "hidden";
					}
					oDiv.appendChild(titleDiv);
				}
titleDiv.style.fontSize = "12px";
titleDiv.style.whiteSpace = "nowrap";
titleDiv.style.paddingTop = "1px";
titleDiv.style.fontWeight = "normal";
			}
		}

		if (description)
		{
			var pDiv = document.createElement('div');
			if (pDiv)
			{
				var newText = document.createTextNode(description);
				if (newText)
				{
					pDiv.appendChild(newText);
					var desc_style = "addescription";
					pDiv.setAttribute("style", "font-size: 11px; line-height: 12px; color: black;");
pDiv.style.fontSize = "11px";
pDiv.style.lineHeight = "12px";
pDiv.style.color = "black";
pDiv.style.fontWeight = "normal";
					oDiv.appendChild(pDiv);
				}
			}
		}
		if (httplink && !isInfo)
		{
			if (httplink.substr(0,"http://".length) == "http://")
				httplink = httplink.substr("http://".length);
			if (httplink.substr(0,"https://".length) == "https://")
				httplink = httplink.substr("https://".length);
			var pos = httplink.indexOf("/");
			if (pos > 0)
			{
				httplink = httplink.substr(0,pos);
			}
			var pos2 = httplink.indexOf("?");
			if (pos2 > 0)
			{
				if (pos2 < pos || pos < 0)
					httplink = httplink.substr(0,pos2);
			}
			var linkDiv = document.createElement('div');
			if (linkDiv)
			{
				var newText = document.createTextNode(httplink);
				if (newText)
				{
					linkDiv.appendChild(newText);
					var link_style = "adlink";
					linkDiv.setAttribute("style", "font-size: 9px; white-space: nowrap; color: blue;");
linkDiv.style.fontSize = "9px";
linkDiv.style.whiteSpace = "nowrap";
linkDiv.style.color = "blue";
linkDiv.style.fontWeight = "normal";
					oDiv.appendChild(linkDiv);
				}
			}
		}
	}
}

function plainplay_handle(str,msgs_container)
{
//alert(str);
	var pagetype = 0;
	var timetoshow = 0;
	var i=0;
var msgcount = 0;
	if (str && msgs_container)
	{
		var pos = str.indexOf(",");
		if (pos > 0 && pos < 10)
		{
			pagetype = str.substr(0,pos);
		} else
		{
			pos = str.length;
		}
		i = pos+1;
		pos = str.indexOf(",",i);
		if (pos <= i)
			return;
		timetoshow = parseInt(str.substr(i,pos-i));
		if (timetoshow < 0 || timetoshow > 255)
			return;
//alert(timetoshow);
//alert("pagetype: "+str.substr(0,pos));
		for (i=pos+1; i<str.length && pos > 0; i)
		{
			var adtitle = '';
			var adcontent = '';
			var adlink = '';
			var msgtext = '';
			var linkid = '';

			var contentlen = 0;
						var msglen = 0;
						var msgtype = 0;
						var contenttext = '';
						var httplen = 0;
						var httplink = '';
						var linkidlen = 0;
						var httplinkid = '';
						var msgid = 0;
						var eof = str.indexOf(",",i);

//alert("str: "+str.substr(i));
						if (eof > 0)
						{
							// get message type (reserved)
							pos = str.indexOf(",",i);
							if (pos <= i)
								return;
							msgtype = parseInt(str.substr(i,pos-i));
//alert("msgtype: "+str.substr(i,pos-i));
							if (msgtype < 0 || msgtype > 255)
								return;

							i = pos+1;

							// get message id
							pos = str.indexOf(",",i);
							if (pos <= i)
								return;
							msgid = parseInt(str.substr(i,pos-i));
//alert("msgid: "+str.substr(i,pos-i));
							if (msgtype < 0 || msgtype > 255)
								return;

							i = pos+1;

							// get msgtext
							pos = str.indexOf(":",i);
							if (pos <= i)
								return;
							msglen = parseInt(str.substr(i,pos-i));
							if (msglen < 0 || msglen > 255)
								return;

							i = pos+1;
							msgtext = str.substr(i,msglen);
//alert("msgtext: "+msglen+", "+msgtext);

							i += msglen+1;


							// get ad content
							pos = str.indexOf(":",i);
							if (pos <= i)
								return;
							contentlen = parseInt(str.substr(i,pos-i));
							if (contentlen < 0 || contentlen > 255)
								return;

							i = pos+1;
							contenttext = str.substr(i,contentlen);

							i += contentlen+1;

							// get link
							pos = str.indexOf(":",i);
							if (pos <= i)
								return;
							httplen = parseInt(str.substr(i,pos-i));

							if (httplen < 0 || httplen > 255)
								return;

							i = pos+1;
							httplink = str.substr(i,httplen);
//alert("httplink: "+httplink);

							if (httplink && httplink != '0')
								linkid = 'http://plainplay.com/?i=' + msgid;

							i += httplen+1;
//alert(str.substr(i));

/*
							// get msg id for link
							pos = str.indexOf(":",i);
							if (pos <= i)
								return;
							linkidlen = parseInt(str.substr(i,pos-i));
//alert(str.substr(i,pos-i));
							if (linkidlen < 0 || linkidlen > 255)
								return;

							i = pos+1;
							linkid = str.substr(i,linkidlen);

							i += linkidlen;


							if (httplink && httplink != '0')
								httplinkid = 'http://plainplay.com/?i=' + linkid;

							// get image id
							pos = str.indexOf(":",i);
							if (pos <= i)
								return;
							var imageidlen = parseInt(str.substr(i,pos-i));
//alert(str.substr(i,pos-i));
							if (imageidlen < 0 || imageidlen > 255)
								return;

							i = pos+1;
							var imageid = str.substr(i,imageidlen);

							i += imageidlen;
*/
//contenttext.replace('\u128!','\u20AC!');
							plainplay_ad_add(msgs_container, msgtext, contenttext, httplink, linkid, false);
msgcount++;
			}

			}
	}
	if (msgs_container)
	{
		var link = 'https://plainplay.com/i.php?ref=engine&id='+plainplay_pageid+plainplay_locale;

		var timestring = '';
		if (timetoshow == 1)
			timestring = plainplay_day;
		else if (timetoshow == 7)
			timestring = plainplay_week;
		else if (timetoshow % 7 == 0)
			timestring = timetoshow/7 + ' ' + plainplay_weeks;
		else
			timestring = timetoshow + ' ' + plainplay_days;

var tt = '';
var plainplay_adtime = '';
if (timetoshow % 7 == 0)
{
	tt = plainplay_weeks;
	plainplay_adtime = plainplay_maxtime;
} else
{
	tt = plainplay_days;
	plainplay_adtime = (plainplay_maxtime*timetoshow);
}

		plainplay_text += ' ' + plainplay_price_only + ' ' + pagetype + plainplay_currency + ' / ' + timestring+'!' + ' Max. '+plainplay_adtime+' ' +tt+'.';

		if (pagetype > 0 && msgcount < plainplay_maxmsgs)
		{
			plainplay_ad_add(msgs_container, plainplay_title, plainplay_text, link, link, true);
		}
	}
}

function plainplay_start()
{
	var plainplay_msgs_scroll = document.getElementById(plainplay_ad_div);
	if (plainplay_msgs_scroll)
	{
		plainplay_handle(plainplay_msg,plainplay_msgs_scroll);
	}
}

plainplay_start();
