function resizeIframe(window, relpath) 
{ 
	if (!relpath) relpath = "";
	window.document.cookie = "poieditinline=" + window.location.href + "; path=/";
	if (window.parent == self || window.parent.name != 'poieditmain')
	{
		window.location.href = "http://www.poiedit.com/index.htm";
	}
} 

function initLanguage()
{
	c = getCookie("lang");
	if (c != null)
	{
	  lang = c; // retrieve language from cookie
	  lang = checkLang(lang);
	}
	else
	{
		// retrieve language from browser specs
		var isIE = (navigator.appName.indexOf("Microsoft") != -1);
		var lang = "";
		if (isIE)
			lang = navigator.userLanguage;
		else
			lang = navigator.language;
		lang = lang.substring(0,2);
		lang = lang.toLowerCase();
	  lang = checkLang(lang);
	}
	// retrieve language from parameters
	idx = window.location.href.indexOf("lang=");
	if (idx > 0)
	{
		lang = window.location.href.substring(idx+5,idx+7);
		lang = checkLang(lang);
		nextyear = new Date();
		nextyear.setFullYear(nextyear.getFullYear()+1);
		document.cookie = "lang=" + lang + "; expires=" + nextyear.toGMTString() + "; path=/";
	}

	return lang;
}

function checkLang(aLang)
{
	// correct invalid languages
	if (aLang != "nl" /* && aLang != "it" */) 
	  return "en";
	else
	  return aLang;
}

function updateLang(aLang)
{
	// sets language dynamically from e.g. a button and stores it in a cookie
	lang = checkLang(aLang);
	nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear()+1);
	document.cookie = "lang=" + lang + "; expires=" + nextyear.toGMTString() + "; path=/";
	showLanguageElements(lang);
	return lang;
}

function getCookie(aName)
{
	idx = document.cookie.indexOf(aName + "=");
	if (idx != -1)
	{
		start = idx + aName.length + 1;
		end = document.cookie.indexOf(";", start);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(start, end));
	}
	return null;
}

function showLanguageElements(aLang)
{
	var all = document.all || document.getElementsByTagName('*');
	for (i=0; i<all.length; i++)
	{
		if (all.item(i).lang != "")
		{
			all.item(i).className = all.item(i).className.replace(/\s*hidden/i, "");
			if (all.item(i).lang != aLang)
				all.item(i).className += " hidden";
		}
	}
}