window.addEvent('domready',function()
{
	/* IE fixes*/
	if(Browser.Engine.trident)
	{
		document.styleSheets[0].addRule('#logo', 'behavior: url("iepngfix.htc");', 0);
		//document.styleSheets[0].addRule('#menu li span', 'behavior: url("iepngfix.htc");', 0);
		document.styleSheets[0].addRule('.png', 'behavior: url("iepngfix.htc");', 0);
		document.styleSheets[0].addRule('#top div', 'display:inline-block;', 0); //Fixes so the menu is 100% wide
		//IE 6 only
		if(Browser.Engine.version == 4)
		{
			document.styleSheets[0].addRule('.wrap img.arrow', 'margin-top:-20px;', 0); //Fixes the arrows in the right column
			document.styleSheets[0].addRule('.textcontent .fordelar h3', 'position:relative;top:-3px;', 0); //Fixes the headline alignment on Fordelar_med_SPP.php
		}
	}
	//Font replacements
	//Cufon.replace('#menu li a', { fontFamily: 'signacolumnbold' });
	Cufon.replace('#bottom', { fontFamily: 'signacolumnbold' });
	Cufon.replace('.sigcolbold', { fontFamily: 'signacolumnbold' });
	//Cufon.replace('.sigcolbook', { fontFamily: 'signacolumnbook' });
	Cufon.replace('.sigcolblack', { fontFamily: 'signacolumnblack' });
	Cufon.replace('.sigcollight', { fontFamily: 'signacolumnlight' });
	
	if($('paperform'))
	{
		$('paperform').addEvent('submit',function()
		{
			var objForm = this;
			objForm.setProperty('error','false');
			objForm.setProperty('radioboxvalue','');
			objForm.getElements('input').each(function(objInput)
			{
				if(objInput.getProperty('type') == 'text')
				{
					if(objInput.value.length == 0 || objInput.value.length > (objInput.getAttribute('maxlength')-0))
					{
						objForm.setProperty('error','true');
					}
					if(objInput.getProperty('id') == 'personnr' && objInput.value.length < 9)
					{
						objForm.setProperty('error','true');
					}
				}
				if(objInput.getProperty('type') == 'radio')
				{
					if(objInput.getProperty('checked') == true)
					{
						objForm.setProperty('radioboxvalue',objInput.getProperty('value'));
					}
				}
			});
			if(!objForm.getProperty('radioboxvalue'))
			{
				objForm.setProperty('error','true');
			}
			if(objForm.getProperty('error') == 'true')
			{
				$('error').setStyle('visibility','visible');
				return false;
			}
			else
			{
				$('error').setStyle('visibility','hidden');
			}
			
		});
	}
	
	if($('3secredirect'))
	{
		var timeout = setTimeout('document.location.href = "/main.php"',3000);
	}
	
	$('wrapper').getElements('a').each(function(objLink)
	{
		if(objLink.getProperty("rel") == "external")
		{
			objLink.target = "_blank"
			
		}
		if(objLink.getProperty("rel") == "popup")
		{
			objLink.addEvent('click',function()
			{
				var strSRC = this.getProperty('href');
				var newWin = window.open (strSRC,"newWin");
				return false;
			});
		}
	});
	
	if($('kommunform'))
	{
		$('submit').setStyle('visibility','hidden');
		$('kommun').addEvent('change',function() {
			document.location.href = 'Sa_funkar_valet.php?kommun='+ $('kommun').value;
		});
	}
});

