function inputErrorChecker()
{
	//if ( document.getElementById().value ) document.getElementById(id).style.visibility = "hidden";
	var doSubmit="TRUE";
	
	/*
	if ( document.getElementById('inputZipCode').value=="" && doSubmit=="TRUE")
	{
		alert("Du måste fylla i anläggningens postnummer för att kunna gå vidare.");
		doSubmit="FALSE";
	}
	*/
	
	//kollar att endast siffror har fyllts i förbrukning
	document.getElementById('inputConsumption').value=stripChar(",",document.getElementById('inputConsumption').value);
	document.getElementById('inputConsumption').value=stripChar(".",document.getElementById('inputConsumption').value);
	document.getElementById('inputConsumption').value=stripChar(" ",document.getElementById('inputConsumption').value);
	//document.getElementById('inputConsumptionTemp').value=document.getElementById('inputConsumption').value;
	
	if( document.getElementById('inputResidensType').value=="FALSE" && doSubmit=="TRUE")
	{
		alert("Välj vilken typ av bostad du har.");
		doSubmit="FALSE";
	}
	
		if( document.getElementById('inputConsumption').value=="" && doSubmit=="TRUE")
	{
		alert("Du måste fylla i din anläggnings årsförbrukning.");
		doSubmit="FALSE";
	}
	
	if ( isNaN( document.getElementById('inputConsumption').value ) && doSubmit=="TRUE")
	{
		alert("Ogiltiga karaktärer i angiven konsumtion");
		doSubmit="FALSE";
	}
	
	if( document.getElementById('inputPriceType').value=="NONE" && doSubmit=="TRUE")
	{
		alert("Välj vilken avtalstyp du vill ha.");
		doSubmit="FALSE";
	}
	
	if( document.getElementById('inputPaymentType').value=="NONE" && doSubmit=="TRUE")
	{
		alert("Välj på vilken sätt du vill betala för din el.");
		doSubmit="FALSE";
	}
	
	if( document.getElementById('inputSortBy').value=="NONE" && doSubmit=="TRUE")
	{
		alert("Välj hur du vill sortera dina resultat.");
		doSubmit="FALSE";
	}
	
	/*
		{
		//felsökningskod

		alert( document.getElementById('inputZipCode').value );
		var str=document.getElementById('inputZipCode').value;
		str.replace(/petter/gi);
		document.getElementById('inputZipCode').value=str;
		alert( document.getElementById('inputZipCode').value );

	}
	else
	*/
	/*
	<input id="inputZipCode" name="inputZipCode" type="hidden" value="<?php print $zipcode; ?>">
	<input id="inputProvinceCode" name="inputProvinceCode" type="hidden" value="FALSE">
	*/
	
	if ( doSubmit=="TRUE" ) document.getElementById('formUserInput').submit();
}

function inputErrorChecker2()
{
	//if ( document.getElementById().value ) document.getElementById(id).style.visibility = "hidden";
	var doSubmit="TRUE";
	
	//Förnamnshantering
		var TempFirstName=document.getElementById('inputFirstName').value;
		TempFirstName=stringToLowerCase(TempFirstName);
		
		if(TempFirstName.charAt(0)==" ") TempFirstName=TempFirstName.substring(1,TempFirstName.length);
		
		if( TempFirstName.indexOf("ab") != -1 )
		{
			if( TempFirstName.indexOf(" ab") != -1 )
			{
				if( TempFirstName.indexOf(" ab ") != -1)
				{
					TempFirstName=TempFirstName.substring(0,TempFirstName.indexOf(" ab "))+" AB "+TempFirstName.substring(TempFirstName.indexOf(" ab ")+4,TempFirstName.length);
				}
				else if( TempFirstName.indexOf(" ab")+4 > TempFirstName.length)
				{
					TempFirstName=TempFirstName.substring(0,TempFirstName.length-2)+"AB";
				}
			}
		}
		
		TempFirstName=stringToUpperCase(TempFirstName.charAt(0)) + TempFirstName.substring(1,TempFirstName.length);
		
		for(i=0; i<TempFirstName.length; i++)
		{
			if(TempFirstName.charAt(i)==" " || TempFirstName.charAt(i)=="-") TempFirstName=TempFirstName.substring(0,i+1)+stringToUpperCase(TempFirstName.charAt(i+1))+TempFirstName.substring(i+2,TempFirstName.length);
		}

		document.getElementById('inputFirstName').value=TempFirstName;
	
	if ( document.getElementById('inputFirstName').value=="" && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputFirstName').focus();
		alert("Du måste fylla i ditt förnamn.");
		doSubmit="FALSE";
	}
	
	//Efternamnshantering
		var TempLastName=document.getElementById('inputLastName').value;
		TempLastName=stringToLowerCase(TempLastName);
		
		if(TempLastName.charAt(0)==" ") TempLastName=TempLastName.substring(1,TempLastName.length);
		
		if( TempLastName.indexOf("ab") != -1 )
		{
			if( TempLastName.indexOf(" ab") != -1 )
			{
				if( TempLastName.indexOf(" ab ") != -1)
				{
					TempLastName=TempLastName.substring(0,TempLastName.indexOf(" ab "))+" AB "+TempLastName.substring(TempLastName.indexOf(" ab ")+4,TempLastName.length);
				}
				else if( TempLastName.indexOf(" ab")+4 > TempLastName.length)
				{
					TempLastName=TempLastName.substring(0,TempLastName.length-2)+"AB";
				}
			}
		}
		
		TempLastName=stringToUpperCase(TempLastName.charAt(0)) + TempLastName.substring(1,TempLastName.length);
		
		for(i=0; i<TempLastName.length; i++)
		{
			if(TempLastName.charAt(i)==" " || TempLastName.charAt(i)=="-") TempLastName=TempLastName.substring(0,i+1)+stringToUpperCase(TempLastName.charAt(i+1))+TempLastName.substring(i+2,TempLastName.length);
		}
	
		document.getElementById('inputLastName').value=TempLastName;
		
	if ( document.getElementById('inputLastName').value=="" && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputLastName').focus();
		alert("Du måste fylla i ditt efternamn.");
		doSubmit="FALSE";
	}
	
	//Telefonnr
		var TempPhoneNr=document.getElementById('inputPhoneNr').value;
		
		if(TempPhoneNr.charAt(0)==" ") TempPhoneNr=TempPhoneNr.substring(1,TempPhoneNr.length);
		
		var i=0;
		while(i<TempPhoneNr.length)
		{
			if( TempPhoneNr.indexOf("+46") != -1 ) TempPhoneNr=TempPhoneNr.substring(0,TempPhoneNr.indexOf("+46"))+"0"+TempPhoneNr.substring(TempPhoneNr.indexOf("+46")+3,TempPhoneNr.length);
			else if(TempPhoneNr.charAt(i)==" ") TempPhoneNr=TempPhoneNr.substring(0,i)+TempPhoneNr.substring(i+1,TempPhoneNr.length);
			else if(TempPhoneNr.charAt(i)=="-") TempPhoneNr=TempPhoneNr.substring(0,i)+TempPhoneNr.substring(i+1,TempPhoneNr.length);
			else if(TempPhoneNr.charAt(i)==",") TempPhoneNr=TempPhoneNr.substring(0,i)+TempPhoneNr.substring(i+1,TempPhoneNr.length);
			else if(TempPhoneNr.charAt(i)==".") TempPhoneNr=TempPhoneNr.substring(0,i)+TempPhoneNr.substring(i+1,TempPhoneNr.length);
			else if( i<6 && TempPhoneNr.charAt(i)=="/") TempPhoneNr=TempPhoneNr.substring(0,i)+TempPhoneNr.substring(i+1,TempPhoneNr.length);
			else i++;
		}
		document.getElementById('inputPhoneNr').value=TempPhoneNr;
	
	if ( document.getElementById('inputPhoneNr').value.substring(0,2)=="07" && doSubmit=="TRUE")
	{
		if ( document.getElementById('inputPhoneNr').value.length < 12 && document.getElementById('inputPhoneNr').value.length!=10 )
		{		
			window.scrollTo(0,0);
			document.getElementById('inputPhoneNr').focus();
			alert("Ditt telefonummer är inte korrekt.");
			doSubmit="FALSE";
		}
	}
	
	if ( document.getElementById('inputPhoneNr').value=="" && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputPhoneNr').focus();
		alert("Du måste fylla i ditt telefonnummer.");
		doSubmit="FALSE";
	}
	
	//Personnr check
		var TempPersNr=document.getElementById('inputPersNr').value;
		
		if(TempPersNr.charAt(0)==" ") TempPersNr=TempPersNr.substring(1,TempPersNr.length);
		
		var i=0;
		while(i<TempPersNr.length)
		{
			if(TempPersNr.charAt(i)==" ") TempPersNr=TempPersNr.substring(0,i)+TempPersNr.substring(i+1,TempPersNr.length);
			else if(TempPersNr.charAt(i)=="-") TempPersNr=TempPersNr.substring(0,i)+TempPersNr.substring(i+1,TempPersNr.length);
			else i++;
		}
		if( TempPersNr.length==12 ) TempPersNr=TempPersNr.substring(2,TempPersNr.length);
		if( TempPersNr.length>0 ) TempPersNr=TempPersNr.substring(0,6)+"-"+TempPersNr.substring(6,TempPersNr.length);
		document.getElementById('inputPersNr').value=TempPersNr;
	
	if ( document.getElementById('inputPersNr').value=="" && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputPersNr').focus();
		alert("Du måste fylla i ditt personnummer.");
		doSubmit="FALSE";
	}
	
	if ( document.getElementById('inputPersNr').value.length>11 && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputPersNr').focus();
		alert("Du har fyllt i ett för långt personnummer.");
		doSubmit="FALSE";
	}
	
	if ( document.getElementById('inputPersNr').value.length<11 && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputPersNr').focus();
		alert("Du har fyllt i ett för kort personnummer.");
		doSubmit="FALSE";
	}
	
	if( document.getElementById('inputPersNr').value.length==11 && doSubmit=="TRUE" )
	{
		if( new personnummer(TempPersNr).valid )
		{
			doSubmit="TRUE";
		} 
		else if( new organisationsnummer(TempPersNr).valid )
		{ 
			doSubmit="TRUE";
		} 
		else {
			window.scrollTo(0,0);
			document.getElementById('inputPersNr').focus();
			alert("Det angivna personnumret är felaktigt.");
			doSubmit="FALSE";
		}
	}
	
	//Addreshantering
		var TempPropertyAdress=document.getElementById('inputPropertyAdress').value;
		TempPropertyAdress=stringToLowerCase(TempPropertyAdress);
		
		if(TempPropertyAdress.charAt(0)==" ") TempPropertyAdress=TempPropertyAdress.substring(1,TempPropertyAdress.length);
		
		TempPropertyAdress=stringToUpperCase(TempPropertyAdress.charAt(0)) + TempPropertyAdress.substring(1,TempPropertyAdress.length);
		
		for(i=0; i<TempPropertyAdress.length; i++)
		{
			if(TempPropertyAdress.charAt(i)==" ") TempPropertyAdress=TempPropertyAdress.substring(0,i+1)+stringToUpperCase(TempPropertyAdress.charAt(i+1))+TempPropertyAdress.substring(i+2,TempPropertyAdress.length);
		}
		
		if( TempPropertyAdress.indexOf("Väg") != -1 )
		{
			if( TempPropertyAdress.indexOf(" Väg") != -1 )
			{
				if( TempPropertyAdress.indexOf(" Väg ") != -1)
				{
					TempPropertyAdress=TempPropertyAdress.substring(0,TempPropertyAdress.indexOf(" Väg "))+" väg "+TempPropertyAdress.substring(TempPropertyAdress.indexOf(" Väg ")+5,TempPropertyAdress.length);
				}
				else if( TempPropertyAdress.indexOf(" Väg")+5 > TempPropertyAdress.length)
				{
					TempPropertyAdress=TempPropertyAdress.substring(0,TempPropertyAdress.length-2)+"väg";
				}
			}
		}
		
		document.getElementById('inputPropertyAdress').value=TempPropertyAdress;
		
	if ( document.getElementById('inputPropertyAdress').value=="" && doSubmit=="TRUE" )
	{
		window.scrollTo(0,0);
		document.getElementById('inputPropertyAdress').focus();
		alert("Du måste fylla i din adress.");
		doSubmit="FALSE";
	}
	
	if ( document.getElementById('inputPropertyZipCode').value=="" && doSubmit=="TRUE" )
	{
		window.scrollTo(0,0);
		document.getElementById('inputPropertyZipCode').focus();
		alert("Du måste fylla i ditt postnummer.");
		doSubmit="FALSE";
	}
	
	//Postort check
		var TempPropertyPostCity=document.getElementById('inputPropertyPostCity').value;
		TempPropertyPostCity=stringToLowerCase(TempPropertyPostCity);
		
		if(TempPropertyPostCity.charAt(0)==" ") TempPropertyPostCity=TempPropertyPostCity.substring(1,TempPropertyPostCity.length);
		
		TempPropertyPostCity=stringToUpperCase(TempPropertyPostCity.charAt(0)) + TempPropertyPostCity.substring(1,TempPropertyPostCity.length);
		
		for(i=0; i<TempPropertyPostCity.length; i++)
		{
			if(TempPropertyPostCity.charAt(i)==" ") TempPropertyPostCity=TempPropertyPostCity.substring(0,i+1)+stringToUpperCase(TempPropertyPostCity.charAt(i+1))+TempPropertyPostCity.substring(i+2,TempPropertyPostCity.length);
		}
		
		document.getElementById('inputPropertyPostCity').value=TempPropertyPostCity;	
	
	if ( document.getElementById('inputPropertyPostCity').value=="" && doSubmit=="TRUE" )
	{
		window.scrollTo(0,0);
		document.getElementById('inputPropertyPostCity').focus();
		alert("Du måste fylla i din postort.");
		doSubmit="FALSE";
	}
	
	//NETID
		var TempPropertyNetCode=document.getElementById('inputPropertyNetCode').value;
		
		TempPropertyNetCode=stringToUpperCase(TempPropertyNetCode);	
		
		if(TempPropertyNetCode.charAt(0)==" ") TempPropertyNetCode=TempPropertyNetCode.substring(1,TempPropertyNetCode.length);
		
		if(TempPropertyNetCode.length>3)
		{
			if( isOnlyLetters( TempPropertyNetCode.substring(0,3) ) && TempPropertyNetCode.charAt(3)==" " ) TempPropertyNetCode=TempPropertyNetCode.substring(0,3);
		}
		
		if(TempPropertyNetCode.length==3)
		{
			document.getElementById('inputPropertyNetCode').value=TempPropertyNetCode;
		}
		
	//EAN
		var TempPropertyEAN=document.getElementById('inputPropertyEAN').value;
				
		if(TempPropertyEAN.charAt(0)==" ") TempPropertyEAN=TempPropertyEAN.substring(1,TempPropertyNetCode.length);
		
		TempPropertyEAN=stripChar(" ",TempPropertyEAN);
		TempPropertyEAN=stripChar("-",TempPropertyEAN);
		TempPropertyEAN=stringToUpperCase(TempPropertyEAN);			
		
		if( TempPropertyEAN.length==3 )
		{
			if( isOnlyLetters(TempPropertyEAN) )
			{
				TempPropertyNetCode=document.getElementById('inputPropertyNetCode').value;
				document.getElementById('inputPropertyNetCode').value=TempPropertyEAN;
				TempPropertyEAN=TempPropertyNetCode;
				document.getElementById('inputPropertyEAN').value=TempPropertyEAN;
			}			
		}
		
		if(TempPropertyEAN.substring(3,6)==735)
		{
			if( isOnlyLetters(TempPropertyEAN.substring(0,3)) )
			{
				document.getElementById('inputPropertyNetCode').value=TempPropertyEAN.substring(0,3);
				TempPropertyEAN=TempPropertyEAN.substring(3,TempPropertyEAN.length);
				document.getElementById('inputPropertyEAN').value=TempPropertyEAN;
			}			
		}
		
		if(TempPropertyEAN.substring(0,3)==735 && doSubmit=="TRUE")
		{
			if( TempPropertyEAN.length==17 )
			{
				if(TempPropertyEAN.substring(0,6)!="735999")
				{
					window.scrollTo(0,0);
					document.getElementById('inputPropertyEAN').focus();
					alert("Du har angivit ett felaktigt anläggnings id.");
					doSubmit="FALSE";
				}
			}
			
			if( TempPropertyEAN.length==18 )
			{
				var controlNr=calcControlNr(TempPropertyEAN);
				if( TempPropertyEAN.substring(17,18)!=controlNr )
				{
					window.scrollTo(0,0);
					document.getElementById('inputPropertyEAN').focus();
					alert("Du har angivit ett felaktigt anläggnings id.");
					doSubmit="FALSE";
				}
				else
				{
					document.getElementById('inputPropertyEAN').value=TempPropertyEAN;
				}
			}
			
			if( TempPropertyEAN.length==19 )
			{
				window.scrollTo(0,0);
				document.getElementById('inputPropertyEAN').focus();
				alert("Du har angivit ett för långt anläggnings id.");
				doSubmit="FALSE";
			}
		}
	
	if ( document.getElementById('inputPropertyNetCode').value=="" && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputPropertyNetCode').focus();
		alert("Du måste fylla i ditt områdes-id.");
		doSubmit="FALSE";
	}
	
	if(document.getElementById('inputPropertyNetCode').value<3 && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputPropertyNetCode').focus();
		alert("Ditt områdes-id är för kort.");
		doSubmit="FALSE";
	}
		
	if ( document.getElementById('inputPropertyEAN').value=="" && doSubmit=="TRUE")
	{
		window.scrollTo(0,0);
		document.getElementById('inputPropertyEAN').focus();
		alert("Du måste fylla i din EAN-kod / ditt Anläggnings ID.");
		doSubmit="FALSE";
	}
	
	//Faktura Addreshantering
		var TempBillAdress=document.getElementById('inputBillAdressTemp').value;
		TempBillAdress=stringToLowerCase(TempBillAdress);
		
		if(TempBillAdress.charAt(0)==" ") TempBillAdress=TempBillAdress.substring(1,TempBillAdress.length);
		
		TempBillAdress=stringToUpperCase(TempBillAdress.charAt(0)) + TempBillAdress.substring(1,TempBillAdress.length);
		
		for(i=0; i<TempBillAdress.length; i++)
		{
			if(TempBillAdress.charAt(i)==" ") TempBillAdress=TempBillAdress.substring(0,i+1)+stringToUpperCase(TempBillAdress.charAt(i+1))+TempBillAdress.substring(i+2,TempBillAdress.length);
		}
		
		if( TempBillAdress.indexOf("Väg") != -1 )
		{
			if( TempBillAdress.indexOf(" Väg") != -1 )
			{
				if( TempBillAdress.indexOf(" Väg ") != -1)
				{
					TempBillAdress=TempBillAdress.substring(0,TempBillAdress.indexOf(" Väg "))+" väg "+TempBillAdress.substring(TempBillAdress.indexOf(" Väg ")+5,TempBillAdress.length);
				}
				else if( TempBillAdress.indexOf(" Väg")+5 > TempBillAdress.length)
				{
					TempBillAdress=TempBillAdress.substring(0,TempBillAdress.length-2)+"väg";
				}
			}
		}
		
		document.getElementById('inputBillAdressTemp').value=TempBillAdress;
		
	//Faktura Postort check
		var TempBillPostCity=document.getElementById('inputBillPostCityTemp').value;
		TempBillPostCity=stringToLowerCase(TempBillPostCity);
		
		if(TempBillPostCity.charAt(0)==" ") TempBillPostCity=TempBillPostCity.substring(1,TempBillPostCity.length);
		
		TempBillPostCity=stringToUpperCase(TempBillPostCity.charAt(0)) + TempBillPostCity.substring(1,TempBillPostCity.length);
		
		for(i=0; i<TempBillPostCity.length; i++)
		{
			if(TempBillPostCity.charAt(i)==" ") TempBillPostCity=TempBillPostCity.substring(0,i+1)+stringToUpperCase(TempBillPostCity.charAt(i+1))+TempBillPostCity.substring(i+2,TempBillPostCity.length);
		}
		
		document.getElementById('inputBillPostCityTemp').value=TempBillPostCity;	
	
	if ( document.getElementById('inputSameBillAdress').checked==false)
	{
		document.getElementById('inputBillAdress').value=document.getElementById('inputBillAdressTemp').value;
		document.getElementById('inputBillZipCode').value=document.getElementById('inputBillZipCodeTemp').value;
		document.getElementById('inputBillPostCity').value=document.getElementById('inputBillPostCityTemp').value;
	}
	
	//EMAIL
		var TempUserEmail=document.getElementById('inputUserEmail').value;
		
		if(TempUserEmail.length!=0)
		{
			//Tar bort " " (space)
			while( TempUserEmail.indexOf(" ") != -1 ) TempUserEmail=TempUserEmail.substring(0,TempUserEmail.indexOf(" "))+""+TempUserEmail.substring(TempUserEmail.indexOf(" ")+1,TempUserEmail.length);
			//To lowercase
			TempUserEmail=stringToLowerCase(TempUserEmail);
			//Kolla och rätta "," till "."
			while( TempUserEmail.indexOf(",") != -1 ) TempUserEmail=TempUserEmail.substring(0,TempUserEmail.indexOf(","))+"."+TempUserEmail.substring(TempUserEmail.indexOf(",")+1,TempUserEmail.length);
			//Kolla och rätta ".." till "."
			while( TempUserEmail.indexOf("..") != -1 ) TempUserEmail=TempUserEmail.substring(0,TempUserEmail.indexOf(".."))+"."+TempUserEmail.substring(TempUserEmail.indexOf("..")+2,TempUserEmail.length);
			//Kolla att "@" finns
			if ( TempUserEmail.indexOf("@") == -1 && doSubmit=="TRUE")
			{
				window.scrollTo(0,0);
				document.getElementById('inputUserEmail').focus();
				alert("Du har fyllt i en felaktig e-post adress.");
				doSubmit="FALSE";
			}
		
			//Kolla efter ogiltiga tecken 
			var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
			if ( !emailPattern.test(TempUserEmail) && doSubmit=="TRUE" )  
			{
				window.scrollTo(0,0);
				document.getElementById('inputUserEmail').focus();
				alert("Du har fyllt i en felaktig e-post adress med ogiltiga tecken.");
				doSubmit="FALSE";
			}
			
			document.getElementById('inputUserEmail').value=TempUserEmail;
		}
    
	if ( doSubmit=="TRUE" ) document.getElementById('formUserInput').submit();
}

function personnummer(nr){
	this.valid=false;
	if(!nr.match(/^(\d{2})(\d{2})(\d{2})\-(\d{4})$/)){ return false; }
	this.now=new Date(); this.nowFullYear=this.now.getFullYear()+""; this.nowCentury=this.nowFullYear.substring(0,2); this.nowShortYear=this.nowFullYear.substring(2,4);
	this.year=RegExp.$1; this.month=RegExp.$2; this.day=RegExp.$3; this.controldigits=RegExp.$4;
	this.fullYear=(this.year*1<=this.nowShortYear*1)?(this.nowCentury+this.year)*1:((this.nowCentury*1-1)+this.year)*1;
	var months = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	if(this.fullYear%400==0||this.fullYear%4==0&&this.fullYear%100!=0){ months[1]=29; }
	if(this.month*1<1||this.month*1>12||this.day*1<1||this.day*1>months[this.month*1-1]){ return false; }
	this.alldigits=this.year+this.month+this.day+this.controldigits;
	var nn="";
	for(var n=0;n<this.alldigits.length;n++){ nn+=((((n+1)%2)+1)*this.alldigits.substring(n,n+1)); }
	this.checksum=0;
	for(var n=0;n<nn.length;n++){ this.checksum+=nn.substring(n,n+1)*1; }
	this.valid=(this.checksum%10==0)?true:false;
	this.sex=parseInt(this.controldigits.substring(2,3))%2;
}

function organisationsnummer(nr){
	this.valid=false;
	if(!nr.match(/^(\d{1})(\d{5})\-(\d{4})$/)){ return false; }
	this.group=RegExp.$1;
	this.controldigits=RegExp.$3;
	this.alldigits=this.group+RegExp.$2+this.controldigits;
	if(this.alldigits.substring(2,3)<2){ return false }
	var nn="";
	for(var n=0;n<this.alldigits.length;n++){ nn+=((((n+1)%2)+1)*this.alldigits.substring(n,n+1)); }
	this.checksum=0;
	for(var n=0;n<nn.length;n++){ this.checksum+=nn.substring(n,n+1)*1; }
	this.valid=(this.checksum%10==0)?true:false;
}

function calcControlNr(EAN)
{
	//Steg 1 summera varannan siffra från höger och multiplicera summan med tre.
	sumStep1=parseFloat(EAN.charAt(0))+parseFloat(EAN.charAt(2))+parseFloat(EAN.charAt(4))+parseFloat(EAN.charAt(6))+parseFloat(EAN.charAt(8))+parseFloat(EAN.charAt(10))+parseFloat(EAN.charAt(12))+parseFloat(EAN.charAt(14))+parseFloat(EAN.charAt(16));
	//Steg3 summera därefter de övriga siffrorna (gärna från höger).
	sumStep2=parseFloat(EAN.charAt(1))+parseFloat(EAN.charAt(3))+parseFloat(EAN.charAt(5))+parseFloat(EAN.charAt(7))+parseFloat(EAN.charAt(9))+parseFloat(EAN.charAt(11))+parseFloat(EAN.charAt(13))+parseFloat(EAN.charAt(15));
	tempNr=Math.floor((sumStep1*3+sumStep2+10)*0.1);
	//alert((sumStep1*3+sumStep2)*0.1);
	//alert(tempNr*10);
	//alert(sumStep1*3+sumStep2);
	resultNr=((tempNr*10)-(sumStep1*3+sumStep2));
	if(resultNr==10) resultNr=0;
	return resultNr;
}

function stringToUpperCase(tempString)
{
	tempString=tempString.toUpperCase();
	return tempString;
}

function stringToLowerCase(tempString)
{
	tempString=tempString.toLowerCase();
	return tempString;
}

function stripChar(tempChar,tempString)
{
	var i=0;
	while(i<tempString.length)
	{
		if(tempString.charAt(i)==tempChar) tempString=tempString.substring(0,i)+tempString.substring(i+1,tempString.length);
		else i++;
	}
	return tempString;
}

function isNumeric(tempString)
{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;

	for (i = 0; i < tempString.length && IsNumber == true; i++) 
	{
		Char = tempString.charAt(i);
		if (ValidChars.indexOf(Char) == -1) IsNumber = false;
	}
	return IsNumber;
}

function isOnlyLetters(tempString)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ";
	var IsLetters=true;
	var Char;

	for (i = 0; i < tempString.length && IsLetters == true; i++) 
	{
		Char = tempString.charAt(i);
		if (ValidChars.indexOf(Char) == -1) IsLetters = false;
	}
	return IsLetters;
}

function firstCharacterToUpperCase(tempString)
{
	var tempChar;
	tempString.charAt(0)=tempString.charAt(0).toUpperCase();
	
	tempChar=tempString.charAt(0);
	tempChar.toUpperCase();
	tempString.charAt(0)=tempChar;
	return tempString;
}

function removeCharacters(tempChar,tempString)
{
	tempString.replace(tempChar, "");
	return tempString;
}

function hasNumbers(t)
{
	var regex = /\d/g;
	return regex.test(t);
}