// x24 search v1b
// Copyright (c) AS SANOMA BALTICS. All rights reserved

var oX24 = null;

function X24Handler()
{
	this.resize = X24Handler_resize;
	this.getURLArg = X24Handler_getURLArg;
}

function X24Handler_getURLArg(sURL, sKey)
{
	sKey = sKey.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var pPattern = "[\\?&]" + sKey + "=([^&#]*)";
	var rRegExp = new RegExp(pPattern);
	var aResults = rRegExp.exec(sURL);
	if	(aResults == null)
		return 0;
	else
		return aResults[1];
}

function X24Handler_resize()
{
	var oIFRAME = null;
	var iPostId = null;
	try
	{
		oIFRAME = window.parent.parent.document.getElementById('x24');
		if (oIFRAME)
		{
			iPostId = this.getURLArg(window.location.href, 'post_id');
			if (iPostId != 0)
				window.parent.parent.location.hash = iPostId;
			oIFRAME.height = parseInt(this.getURLArg(window.location.href, 'height'));
		}
	}
	catch (oError)
	{
	}
}

oX24 = document.getElementById('x24');
if (oX24)
{
	if (typeof sX24URL != 'undefined')
	{
		if (window.parent.parent.location.hash != '')
			sX24URL = sX24URL + '&x24_hash=' + window.parent.parent.location.hash.replace(/#/g, '');
		oX24.src = sX24URL;
	}
}
else
{
	oX24 = new X24Handler();
	oX24.resize();	
}
	



