//////////////////////////////////////////////////////////////////////////////////
//																				//
//	Determine type of browser.													//
//																				//
//////////////////////////////////////////////////////////////////////////////////

var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all);

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	showDiv(divId,withinDivId)													//
//	Makes the division starting with divId - and residing in division			//
//	withinDivId - visible.														//
//	Divisions whos name matches withinDivId but not divId is hidden.			//
//	If the second parameter is supplied, only divisions within that	specific	//
//	division is affected.														//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function showDiv(divId,withinDivId,hideDivId)
	{
	if (document.getElementById)
		{
		if (withinDivId == '')
			divs = document.getElementsByTagName('div')
		else
			divs = document.getElementById(withinDivId).getElementsByTagName('div');
		for (i = 0; i < divs.length; i++)
			if (divs[i].id.indexOf(withinDivId,0) != -1)
				if ((divs[i].id.indexOf(divId,0) != -1) &&
					(hideDivId == '' || divs[i].id.indexOf(hideDivId,0) == -1))
					divs[i].style.visibility = 'visible'
				else
					divs[i].style.visibility = 'hidden';
		}
	}

function showDiv_old(divId,withinDivId)
	{
	if (document.getElementById)
		{
		if (withinDivId == '')
			divs = document.getElementsByTagName('div')
		else
			divs = document.getElementById(withinDivId).getElementsByTagName('div');
		for (i = 0; i < divs.length; i++)
			if (divs[i].id.indexOf(withinDivId,0) != -1)
				if (divs[i].id.indexOf(divId,0) != -1)
					divs[i].style.visibility = 'visible'
				else
					divs[i].style.visibility = 'hidden';
		}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	divVisible(divId,visible)													//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function divVisible(divId,visible)
	{
	if (document.getElementById)
		{
		document.getElementById(divId).style.visibility = visible;
		}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	showSubmenu(obj,visibility,withFilters)										//
//	The submenu named by the parameter obj is made visible or hidden depending	//
//	on the value of the second parameter visibility. The value of the third		//
//	parameter is either true or false depending on wether we are using filter	//
//	to change the visibility (e.g. fade in/out).								//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function showSubmenu(obj,visibility,withFilters)
	{
	if (ie5 || ns6)
   		menu = document.getElementById('menuDiv').getElementsByTagName('div');
	if (ie5 && withFilters)
		{
		menu[obj].style.filter = 'revealTrans(Duration=0.5,Transition=5)';
//		menu[obj].style.filter = 'blendTrans(Duration=1)';
		menu[obj].filters[0].Apply();
		menu[obj].style.visibility = visibility;
		menu[obj].filters[0].Play();
		}
	else
		if (ie5 || ns6)
			menu[obj].style.visibility = visibility;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	displayDiv(divId)															//
//	Display the division.														//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function displayDiv(divId)
	{
	document.getElementById(divId).style.display = "block";
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	noDisplayDiv(divId)															//
//	Do not display the division.												//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function noDisplayDiv(divId)
	{
	document.getElementById(divId).style.display = "none";
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	toggleDiv(divId)															//
//	Toggle the division.														//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function toggleDiv(divId)
	{
	if (document.getElementById(divId).style.display == "block")
		document.getElementById(divId).style.display = "none"
	else
		document.getElementById(divId).style.display = "block";
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	fixNSInput(obj)																//
//	There is a bug in NS6 & NS7 that doesn't make the changing of an inputfield	//
//	show until the screen is refreshed when working with multiple layers.		//
//	This function must be called by the event onclick in the checkbox- or		//
//	radioobject, or by onkeydown in any other inputobejct and with a suitable	//
//	superior id of a layer as parameter.										//
//	The bug is reported on http://bugzilla.mozilla.org with id# 154112.			//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function fixNSInput(divId)
	{
	if (ns6)
		{
		document.getElementById(divId).style.visibility = 'hidden';
		document.getElementById(divId).style.visibility = 'visible';
		}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	showPopup(url,name,width,height)											//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function ShowPopup(url,name,width,height)
	{
	showPopup(url,name,width,height)
	}

function showPopup(url,name,width,height)
	{
	if (width < 0)
		width = screen.width+width;
	if (height < 0)
		height = screen.height+height-100;
	var left = (screen.width-width)/2;
	var top  = (screen.height-height-100)/2;
	var popup = window.open(url,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	popup.focus();
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	showTip(eventObj,tipText,width,xoffset,yoffset)								//
//	Show a tip with tipText.													//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function showTip(eventObj,tipText,width,xoffset,yoffset)
	{
	tipDiv = document.getElementById('tip');
	tipDiv.innerHTML = unescape(tipText);
	if (ie5)
		{
//		tipDiv.style.left = eventObj.clientX+document.documentElement.scrollLeft+xoffset+'px';
//		tipDiv.style.top  = eventObj.clientY+document.documentElement.scrollTop+yoffset+'px';
		tipDiv.style.left = eventObj.clientX+document.body.scrollLeft+xoffset+'px';
		tipDiv.style.top  = eventObj.clientY+document.body.scrollTop+yoffset+'px';
		}
	if (ns6)
		{
		tipDiv.style.left = eventObj.clientX+window.pageXOffset+xoffset+'px';
		tipDiv.style.top  = eventObj.clientY+window.pageYOffset+yoffset+'px';
		}
	if (width != '')
		tipDiv.style.width = width+'px';
	tipDiv.style.visibility = 'visible';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	hideTip																		//
//	Hide the content of tip.													//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function hideTip()
	{
	document.getElementById('tip').style.visibility = 'hidden';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	showHelp(eventObj,helpfile,width,height)									//
//	Show a helpfile.															//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function showHelp(eventObj,helpfile,width,height)
	{
	var helpDiv = document.getElementById('help');
	helpDiv.style.width  = width+'px';
	helpDiv.style.height = height+'px';
	var iframe_height = height-20;
	helpDiv.innerHTML = '<table border=0 cellpadding=0 cellspacing=0 background="/images/backgrounds/iu_navframe_1x25.gif" width=100%><tr><td align=right><input type=button value="X" onclick="hideHelp()" class=close></td></tr></table><iframe id=helpframe width=100% height='+iframe_height+' leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=auto bordercolor=ffffff src="'+helpfile+'"></iframe>';
	if (ie5)
		{
		helpDiv.style.left = eventObj.clientX+document.documentElement.scrollLeft+10+'px';
		helpDiv.style.top  = eventObj.clientY+document.documentElement.scrollTop+10+'px';
		}
	if (ns6)
		{
		helpDiv.style.left = eventObj.clientX+window.pageXOffset+10+'px';
		helpDiv.style.top  = eventObj.clientY+window.pageYOffset+10+'px';
		}
	helpDiv.style.visibility = 'visible';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	hideHelp																	//
//	Hide the content of help.													//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function hideHelp()
	{
	helpDiv = document.getElementById('help');
	helpDiv.style.visibility = 'hidden';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	clickMap(obj,areacode)														//
//	When a map is clicked, the corresponding area is marked on the map and in	//
//	the selectionbox.															//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function clickMap(obj,divId,areacode)
	{
	if (document.getElementById)
		{
		var i = obj.options.length;
		for (i2 = 0; i2 < i; i2++)
			if (obj.options[i2].value == areacode)
				if (obj.options[i2].selected)
					{
					obj.options[i2].selected = false;
					document.getElementById(divId+areacode).style.visibility = 'hidden';
					}
				else
					{
					obj.options[i2].selected = true;
					document.getElementById(divId+areacode).style.visibility = 'visible';
					}
		}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	updateMap(obj,obj2,divId)													//
//	When a change is made in the selectionbox, the corresponding areas are		//
//	marked on the map.															//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function updateMap(obj,obj2,divId)
	{
	if (document.getElementById)
		{
		var i = obj.options.length;
		for (i2 = 0; i2 < i; i2++)
			if (document.getElementById(divId+obj.options[i2].value))
				if (obj.options[i2].selected)
					document.getElementById(divId+obj.options[i2].value).style.visibility = 'visible'
				else
					document.getElementById(divId+obj.options[i2].value).style.visibility = 'hidden';
		if (obj2)
			{
			var i = obj2.options.length;
			for (i2 = 0; i2 < i; i2++)
				if (document.getElementById(divId+obj2.options[i2].value))
					if (obj2.options[i2].selected)
						document.getElementById(divId+obj2.options[i2].value).style.visibility = 'visible'
					else
						document.getElementById(divId+obj2.options[i2].value).style.visibility = 'hidden';
			}
		}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	resetSelect(obj)															//
//	Reset all selections made in a selectbox.									//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function resetSelect(obj)
	{
	if (obj.multiple)
		{
		var i = obj.options.length;
		for (i2 = 0; i2 < i; i2++)
			if (obj.options[i2].selected)
				obj.options[i2].selected = false;
		}
	else
		obj.value = '';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	resetField(obj)																//
//	Reset all fields, regardless of type.										//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function resetField(obj)
	{
	if (obj.type == 'text' || obj.type == 'textarea')
		obj.value = ''
	else
		if (obj.type == 'radio' || obj.type == 'checkbox')
			obj.checked = ''
		else
			if (obj.type == 'select-one')
				{
				obj.selectedIndex = -1;						//	Init none selected
				for (i = 0; i < obj.options.length; i++)	//	Fix to reset
					if (obj.options[i].value == '')			//	selectbox to first
						obj.selectedIndex = i;				//	empty value
				}
			else
				if (obj.type == 'select-multiple')
					{
					var i = obj.options.length;
					for (i2 = 0; i2 < i; i2++)
						if (obj.options[i2].selected)
							obj.options[i2].selected = false;
					}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	resetAdvanced(obj)															//
//	Reset all fields with attribute advanced=yes.								//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function resetAdvanced(obj)
	{
	var elems = obj.elements;
	for (var i = 0; i < elems.length; i++)
		if (elems[i].getAttribute('advanced') == 'yes' || elems[i].advanced == 'yes')
			resetField(elems[i]);
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	uncheckDefault(obj)															//
//	Uncheck default value if others are selected in a selectbox.				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function uncheckDefault(obj)
	{
	var i = obj.options.length;
	for (i2 = 1; i2 < i; i2++)
		if (obj.options[i2].selected)
			obj.options[0].selected = false;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	getRadioValue()																//
//	Get value of checked radiobutton.											//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function getRadioValue(obj)
	{
	var result = '';
	for (var i=0; i < obj.length; i++)
	   if (obj[i].checked)
	      var result = obj[i].value;
	return result;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	getScreenWidth()															//
//	Get current width of screen.												//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function getScreenWidth()
	{
	var width = 0;
	if (ns6)
		width = innerWidth
	else
		width = document.body.offsetWidth;
	return width;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	getScreenHeight()															//
//	Get current height of screen.												//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function getScreenHeight()
	{
	var height = 0;
	if (ns6)
		height = innerHeight
	else
		height = document.body.offsetHeight;
	return height;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	setIframeSize(obj,width,height)												//
//	Set size of Iframe.															//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function setIframeSize(obj,width,height)
	{
	if (width < 0)
		width = getScreenWidth()+width;
	if (height < 0)
		height = getScreenHeight()+height;
	ifrm = document.getElementById(obj);
	ifrm.style.width=width;
	ifrm.style.height=height;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	btnMouseOver(divId)															//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function btnMouseOver(divId)
	{
	btn = document.getElementById('btn'+divId);
	if (btn.src.toLowerCase().indexOf(divId.toLowerCase()+'.gif') >= 0)
		btn.src = btn.src.substr(0,btn.src.toLowerCase().indexOf(divId.toLowerCase()+'.gif'))+divId+'_active.gif';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	btnMouseOut(divId)															//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function btnMouseOut(divId)
	{
	if (document.getElementById(divId).style.visibility == 'hidden')
		{
		btn = document.getElementById('btn'+divId);
		if (btn.src.toLowerCase().indexOf(divId.toLowerCase()+'_active.gif') >= 0)
			btn.src = btn.src.substr(0,btn.src.toLowerCase().indexOf(divId.toLowerCase()+'_active.gif'))+divId+'.gif';
		}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	btnMouseOut2(divId)															//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function btnMouseOut2(divId)
	{
	btn = document.getElementById('btn'+divId);
	if (btn.src.toLowerCase().indexOf(divId.toLowerCase()+'_active.gif') >= 0)
		btn.src = btn.src.substr(0,btn.src.toLowerCase().indexOf(divId.toLowerCase()+'_active.gif'))+divId+'.gif';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	btnClick(divId,withinId,imgId)												//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function btnClick(divId,withinId,hideDivId,imgId)
	{
	showDiv(divId,withinId,hideDivId);
	btnSet(imgId);
	}

function btnClick_old(divId,withinId,imgId)
	{
	showDiv_old(divId,withinId);
	btnSet(imgId);
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	btnSet(name)																//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function btnSet(imgId)
	{
	imgs = document.getElementsByTagName('img');
	for (i = 0; i < imgs.length; i++)
		if (imgs[i].id.toLowerCase().indexOf(imgId.toLowerCase()) >= 0)
			{
			divId = imgs[i].id.substr(3,imgs[i].id.length-3);
			if (document.getElementById(divId))
				{
				if (document.getElementById(divId).style.visibility == 'hidden')
					{
					if (imgs[i].src.toLowerCase().indexOf(divId.toLowerCase()+'_active.gif') >= 0)
						imgs[i].src = imgs[i].src.substr(0,imgs[i].src.toLowerCase().indexOf(divId.toLowerCase()+'_active.gif'))+divId+'.gif';
					}
				else
					if (imgs[i].src.toLowerCase().indexOf(divId.toLowerCase()+'.gif') >= 0)
						imgs[i].src = imgs[i].src.substr(0,imgs[i].src.toLowerCase().indexOf(divId.toLowerCase()+'.gif'))+divId+'_active.gif';
				}
			}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	checkDate(dateToCheck)														//
//	Check the date to see of it has the right format.							//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function checkDate(dateToCheck)
	{
	pattern = /^20([0]|[1]|[2])[0-9]-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/;
	return pattern.test(dateToCheck);
	}														

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	getCookie(name)																//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function getCookie(name)
	{
	var arg = name+'=';
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
		{
		var j = i+alen;
		if (document.cookie.substring(i,j) == arg)
			{
			var endstr = document.cookie.indexOf(';',j);
			if (endstr == -1)
				endstr = document.cookie.length;
			return unescape(document.cookie.substring(j,endstr));
			}
		i = document.cookie.indexOf(' ',i)+1;
		if (i == 0)
			break;
		}
	return '';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	SetCookie(name,value,days,path,secure)										//
//																				//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function setCookie(name,value,days,path,secure)
	{
	var a = document.domain.split(".");
	if (a.length >= 2)
		var domain = "."+a[a.length-2]+"."+a[a.length-1]
	else
		var domain = ".informus.se";
	var expires = new Date();
	var base = new Date(0);
	var skew = base.getTime();	// Dawn of (Unix) time - should be 0
	if (skew > 0)				// Except on the Mac - ahead of its time
		expires.setTime(expires.getTime()-skew);
	expires.setTime(expires.getTime()+(days*24*60*60*1000));
	document.cookie = name+'='+escape(value) +
					((expires)? '; expires='+expires.toGMTString() : '')+
					((path)? '; path='+path : '')+
					((domain)? '; domain='+domain : '')+
					((secure)? '; secure' : '');
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	setAdvancedCookie(set) and readAdvancedCookie()								//
//	Used to set and read the cookie that stores information on whether the		//
//	user wants to work in advanced mode when searching.							//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function setAdvancedCookie(set)
	{
	setCookie('advanced',(set)?'Yes':'',90,'/');
	}

function readAdvancedCookie()
	{
	return (getCookie('advanced') == 'Yes')
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	initSrchForm(), btnsrchClick(divId) and showsrchResult()					//
//	Used to initialize and handle searchforms.									//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function initSrchForm()
	{
	setIframeSize('resultFrame',-200,-125);
	if (document.srchform.srchtype)
		document.srchform.srchtype.checked = (hideDivId == '');
	btnsrchClick(activeDivId);
	}

function btnsrchClick(divId)
	{
	activeDivId = divId;
	btnClick(activeDivId,'srch',hideDivId,'btnsrch');
	if (activeDivId == 'srchPlace')
		updateMap(document.srchform.omrade,document.srchform.omrade2,'srchPlaceMap');
	if (resultFrame.document.applets.map)
		if (activeDivId == 'srchResult')
			resultFrame.document.applets.map.style.visibility = 'visible'
		else
			resultFrame.document.applets.map.style.visibility = 'hidden';
	}

function showsrchResult()
	{
	activeDivId = 'srchResult';
	showDiv(activeDivId,'srch',hideDivId);
	btnSet('btnsrch');
	if (resultFrame.document.applets.map)
		resultFrame.document.applets.map.style.visibility = 'visible';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	updateHits(form)															//
//	Take the field values of the form and submit it.							//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function updateHits(form)
	{
	var parm = '';
	for (i = 0; i < form.length; i++)
		{
		var obj = form.elements[i]
		if ((obj.name != 'mall') && (obj.name != 'funktion'))
			if ((obj.type == 'text') || (obj.type == 'hidden'))
				{
				if (obj.value != '')
					parm += '&'+obj.name+'='+escape(obj.value);
				}
			else
				if (obj.type == 'radio' || obj.type == 'checkbox')
					{
					if ((obj.checked) && (obj.value != ''))
						parm += '&'+obj.name+'='+escape(obj.value);
					}
				else
					if ((obj.type == 'select-one') || (obj.type == 'select-multiple'))
						{
						var i2 = obj.options.length;
						for (i3 = 0; i3 < i2; i3++)
							if ((obj.options[i3].selected) && (obj.options[i3].value != ''))
								parm += '&'+obj.name+'='+escape(obj.options[i3].value);
						}
		}
	hitFrame.location.href = '/cgi-win/kusok2.exe?mall=hits&funktion=hits'+parm;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	oldBrowserWarning(url)														//
//	Checks to se if the browser used is new enough. If it is not, a popup with	//
//	a warning message is displayed.												//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function oldBrowserWarning(url)
	{
	if (ie5 || ns6)
		return;
	if (getCookie('checkBrowser') != 'No')
		showPopup(url,'oldbrowser',550,250);
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	setCheckBrowserCookie()														//
//	Used to set the cookie that stores information on whether the user wants	//
//	to have the browser type checked in the future.								//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function setCheckBrowserCookie(set)
	{
	setCookie('checkBrowser',(set)?'No':'',183,'/');
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	insertText(field,text)														//
//	Used to insert text at cursor position in an input field.					//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function insertText(field,text)
	{
	if (field.setSelectionRange)
		{
		var selectionStart = field.selectionStart;
		var selectionEnd   = field.selectionEnd;
		field.value = field.value.substring(0,selectionStart)+text+
					  field.value.substring(selectionEnd);
		field.setSelectionRange(selectionStart+text.length,selectionStart+text.length);
		}
	else
		if (document.selection)
			{
			var range = document.selection.createRange();
			if (range.parentElement() == field)
				range.text = text;
			}
	field.focus();
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	checkEmail(s_email,s_msg)													//
//	Check to verify that the e-mailaddress is correct.							//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function checkEmail(s_email,s_msg)
	{

//
//	Check e-mail address. Return true if it is ok.
//	[a-zA-Z0-9\._-]+	Multiple letters, digits etc are allowed.
//	@					A @ must occur.
//	[a-zA-Z0-9\._-]+	Multiple letters, digits etc are allowed.
//	\.					A dot must occur.
//	[a-zA-Z0-9]{2,4}	Between 2 and 4 letters or digits are allowed.
//

	var filter = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.[a-zA-Z0-9]{2,4}$/;
	if (filter.test(s_email))
		return true
	else
		{
		if (s_msg != '')
			alert(s_email+' - '+s_msg);
		return false;
		}
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	createEmail(obj,s_email)													//
//	Creates a mailto with a given address. Used to hide address from spiders.	//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function createEmail(obj,s_email)
	{

//
//	Set the href for the calling object to mailto a given address at Informus.
//

	obj.href = 'mailto:'+s_email+'@'+'informus.se';
	return true;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	writeEmail(s_email)															//
//	Writes a given address. Used to hide address from spiders.					//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function writeEmail(s_email)
	{

//
//	Output to document the email for a given address at Informus.
//

	document.write(s_email+'@informus.se');
	return true;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	returnEmail(s_email)														//
//	Returns a given address. Used to hide address from spiders.					//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function returnEmail(s_email)
	{

//
//	Return the email for a given address at Informus.
//

	return s_email+'@informus.se';
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	setIframeHeight(framename,minheight,extraheight,obj1,obj2)					//
//	Sets the height of an Iframe - and 2 other objects - depending on content.	//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function setIframeHeight(framename,minheight,extraheight,obj1,obj2)
	{
	var h = document.getElementById(framename).contentWindow.document.body.scrollHeight+extraheight;
	if (h < minheight)
		h = minheight;
	document.getElementById(framename).style.height = h;
	if (obj1)
		document.getElementById(obj1).style.height = h;
	if (obj2)
		document.getElementById(obj2).style.height = h;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	getNameAddress(formobj)														//
//	Get name and address stored in cookies and fill into form.					//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function getNameAddress(formobj)
	{
	setField(formobj,"ftagnamn",getCookie("ftagnamn"));
	setField(formobj,"kontaktpers",getCookie("kontaktpers"));
	setField(formobj,"tele",getCookie("tele"));
	setField(formobj,"adress",getCookie("adress"));
	setField(formobj,"pstnr",getCookie("pstnr"));
	setField(formobj,"padress",getCookie("padress"));
	setField(formobj,"epost",getCookie("epost"));
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	setNameAddress(formobj)														//
//	Store name and address from form into cookies.								//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function setNameAddress(formobj)
	{
	if (formobj.ftagnamn)		setCookie("ftagnamn",formobj.ftagnamn.value,180,"/");
	if (formobj.kontaktpers)	setCookie("kontaktpers",formobj.kontaktpers.value,180,"/");
	if (formobj.tele)			setCookie("tele",formobj.tele.value,180,"/");
	if (formobj.adress)			setCookie("adress",formobj.adress.value,180,"/");
	if (formobj.pstnr)			setCookie("pstnr",formobj.pstnr.value,180,"/");
	if (formobj.padress)		setCookie("padress",formobj.padress.value,180,"/");
	if (formobj.epost)			setCookie("epost",formobj.epost.value,180,"/");
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	setField(formobj,fieldname,value)											//
//	Set fieldvalue.																//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function setField(formobj,fieldname,value)
	{
	for (var i = 0; i < formobj.elements.length; i++)
		if (formobj.elements[i].name == fieldname)
			if (formobj.elements[i].type == 'select-one')
				{
				for (var i2 = 0; i2 < formobj.elements[i].options.length; i2++)
					if (formobj.elements[i].options[i2].value.toUpperCase() == value.toUpperCase())
						{
						formobj.elements[i].selectedIndex = i2;
						i2 = formobj.elements[i].options.length;
						}
				}
			else
				if (formobj.elements[i].type == 'radio' || formobj.elements[i].type == 'checkbox')
					{
					if (formobj.elements[i].value.toUpperCase() == value.toUpperCase())
						formobj.elements[i].checked = true;
					}
				else
					formobj.elements[i].value = value;
	}

//////////////////////////////////////////////////////////////////////////////////
//																				//
//	unicodeToAscii(text)														//
//	Convert unicode characters to ASCII.										//
//																				//
//////////////////////////////////////////////////////////////////////////////////

function unicodeToAscii(text)
	{
	var result = text;
    result = result.replace(/\xC3\xA5/gi,"å");	// C3A5
    result = result.replace(/\xC3\xA4/gi,"ä");	// C3A4
    result = result.replace(/\xC3\xB6/gi,"ö");	// C3B6
    result = result.replace(/\xC3\xA9/gi,"é");	// C3A9
    result = result.replace(/\xC3\xBC/gi,"ü");	// C3BC
    result = result.replace(/\xC3\x85/gi,"Å");	// C385
    result = result.replace(/\xC3\x84/gi,"Ä");	// C384
    result = result.replace(/\xC3\x96/gi,"Ö");	// C396
    result = result.replace(/\xC3\x89/gi,"É");	// C389
    result = result.replace(/\xC3\x9C/gi,"Ü");	// C39C
	return result;
	}

