

<!--

function returnfalse(){
return false;
}

function selectPossibleUnits(n){

document.huvud.answerBox.value="";
	
	if(n<=3){
	   document.huvud.rightList.options[0].selected=true;
	   document.huvud.rightList.options[0].disabled="";
   	   document.huvud.rightList.options[1].disabled="";
   	   document.huvud.rightList.options[2].disabled="";
   	   document.huvud.rightList.options[3].disabled="disabled";
   	   document.huvud.rightList.options[4].disabled="disabled";
   	   document.huvud.rightList.options[5].disabled="disabled";
   	   document.huvud.rightList.options[6].disabled="disabled";
   	   document.huvud.rightList.options[7].disabled="disabled";
   	   document.huvud.rightList.options[8].disabled="disabled";
 	}
	
	else if(n==4){
	   document.huvud.rightList.options[0].disabled="disabled";
   	   document.huvud.rightList.options[1].disabled="disabled";
   	   document.huvud.rightList.options[2].disabled="disabled";
   	   document.huvud.rightList.options[3].disabled="";
   	   document.huvud.rightList.options[3].selected=true;
   	   document.huvud.rightList.options[4].disabled="disabled";
   	   document.huvud.rightList.options[5].disabled="disabled";
   	   document.huvud.rightList.options[6].disabled="disabled";
   	   document.huvud.rightList.options[7].disabled="disabled";
   	   document.huvud.rightList.options[8].disabled="disabled";
 	}
 	
 	else if(n>4 && n<=6){
	   document.huvud.rightList.options[0].disabled="disabled";
   	   document.huvud.rightList.options[1].disabled="disabled";
   	   document.huvud.rightList.options[2].disabled="disabled";
   	   document.huvud.rightList.options[3].disabled="disabled";
   	   document.huvud.rightList.options[4].selected=true;
   	   document.huvud.rightList.options[4].disabled="";
   	   document.huvud.rightList.options[5].disabled="";
   	   document.huvud.rightList.options[6].disabled="disabled";
   	   document.huvud.rightList.options[7].disabled="disabled";
   	   document.huvud.rightList.options[8].disabled="disabled";
 	}
 	
 	else{
 	   document.huvud.rightList.options[0].disabled="disabled";
   	   document.huvud.rightList.options[1].disabled="disabled";
   	   document.huvud.rightList.options[2].disabled="disabled";
   	   document.huvud.rightList.options[3].disabled="disabled";
   	   document.huvud.rightList.options[4].disabled="disabled";
   	   document.huvud.rightList.options[5].disabled="disabled";
   	   document.huvud.rightList.options[6].selected=true;
   	   document.huvud.rightList.options[6].disabled="";
   	   document.huvud.rightList.options[7].disabled="";
   	   document.huvud.rightList.options[8].disabled="";
 
 	}
	
}



function checknumber(){
var x=document.huvud.msg.value
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
alert(x+ " är inte ett giltigt nummer (komma tecken skrivs som punkt '.' inte ',')")
testresult=false
}
return (testresult)
}

function calcAnswer(){
	checknumber();

	var leftSelected;
	var rightSelected;
	var answer="----------------------";
	var value=document.huvud.msg.value;
	var leftSvAm = document.huvud.leftList.options[0].text=="km";
	
	
	
	for(var i=0; i<document.huvud.leftList.options.length; i++) {
    	if(document.huvud.leftList.options[i].selected){
    		 leftSelected = i;
    		 break;
    	}
	}
	
	for(var i=0; i<document.huvud.rightList.options.length; i++) {
    	if(document.huvud.rightList.options[i].selected){
    		 rightSelected = i;
    		 break;
    	}
	}
	
	
	if(leftSvAm){
	
		if(leftSelected==0){ //km
				//km -> mile			
				if(rightSelected==0) answer = (value/1.609);
				//km -> foot
				if(rightSelected==1) answer = ((value/30.48)*100*1000);
				//km->inch
				if(rightSelected==2) answer = ((value/2.54)*100*1000);	
					
		}
		
		else if(leftSelected==1){ //meter
			//meter -> mile			
				if(rightSelected==0) answer = (value/1609);
				//meter -> foot
				if(rightSelected==1) answer = ((value/30.48)*100);
				//meter ->inch
				if(rightSelected==2) answer = ((value/2.54)*100);		
			
		}
			
		else if(leftSelected==2){ //cm
				//cm -> mile			
				if(rightSelected==0) answer = (value/160900);
				//cm -> foot
				if(rightSelected==1) answer = (value/(30.48));
				//cm ->inch
				if(rightSelected==2) answer = (value/(2.54));		
			
		}

		else if(leftSelected==3){ //Celsius
				//Celsius -> Farenheit			
				if(rightSelected==3) answer = (value*1.8+32);
		}
			
		else if(leftSelected==4){ //Liter
			//Liter -> Gallon			
			if(rightSelected==4) answer = (value/3.78);
			//Liter -> Pint
			if(rightSelected==5) answer = (value/0.47);
			
		}
		
		else if(leftSelected==5){ //dl
			//dl -> Gallon			
			if(rightSelected==4) answer = ((value/3.78)/10);
			//dl -> Pint
			if(rightSelected==5) answer = ((value/0.47)/10);
		}
	
	
		else if(leftSelected==6){ //kg
			//kg -> pound			
			if(rightSelected==6) answer = ((value/453.59237)*1000);
			//kg -> cup
			if(rightSelected==7) answer = (((value/453.59237)*1000)/2);
	    	//kg -> oz
			if(rightSelected==8) answer = ((value/28.349523)*1000);
		}
		
		else if(leftSelected==7){ //hg
			//hg -> pound			
			if(rightSelected==6) answer = (((value/453.59237)*1000)/10);
			//hg -> cup
			if(rightSelected==7) answer = ((((value/453.59237)*1000)/2)/10);
	    	//hg -> oz
			if(rightSelected==8) answer = (((value/28.349523)*1000)/10);
		}
		
		else if(leftSelected==8){ //g
			//g -> pound			
			if(rightSelected==6) answer = ((value/453.59237));
			//g -> cup
			if(rightSelected==7) answer = ((value/453.59237)/2);
	    	//g -> oz
			if(rightSelected==8) answer = (value/28.349523);
	
		}
	}
	
	else{
		
		if(leftSelected==0){ //mile
			//mile -> km			
			if(rightSelected==0) answer = (value*1.609);
			//mile -> meter
			if(rightSelected==1) answer = ((value*1.609)*1000);
			//mile -> cm
			if(rightSelected==2) answer = ((value*1.609)*1000*100);	
		}
	
		else if(leftSelected==1){ //foot
			//foot -> km			
			if(rightSelected==0) answer = ((value*30.48)/1000);
			//foot -> meter
			if(rightSelected==1) answer = ((value*30.48)/100);
			//foot -> cm
			if(rightSelected==2) answer = (value*30.48);	
		}
	
		else if(leftSelected==2){ //inch
			//inch -> km			
			if(rightSelected==0) answer = ((value*2.54)/1000);
			//inch -> meter
			if(rightSelected==1) answer = ((value*2.54)/100);
			//inch -> cm
			if(rightSelected==2) answer = (value*2.54);	
		}

		else if(leftSelected==3){ //Farenheit
		    //Farenheit -> Celsius			
			if(rightSelected==3) answer = ((value-32)/1.8);
		}
		
		else if(leftSelected==4){ //Gallon
			//Gallon -> Liter			
			if(rightSelected==4) answer = (value*3.78);
			//Gallon -> dl
			if(rightSelected==5) answer = ((value*3.78)/10);
			
		}
	
		else if(leftSelected==5){ //Pint
			//Pint -> Liter			
			if(rightSelected==4) answer = (value*0.47);
			//Pint -> dl
			if(rightSelected==5) answer = ((value*0.47)/10);
			
		}
	
		else if(leftSelected==6){ //pound
			//pound -> kg			
			if(rightSelected==6) answer = (value*0.45359237);
			//pound -> hg
			if(rightSelected==7) answer = ((value*0.45359237)/10);
	    	//pound -> g
			if(rightSelected==8) answer = ((value*0.45359237)/100);
		}

		else if(leftSelected==7){ //cup
			//cup -> kg			
			if(rightSelected==6) answer = ((value*0.45359237)/2);
			//cup -> hg
			if(rightSelected==7) answer = (((value*0.45359237)/10)/2);
	    	//cup -> g
			if(rightSelected==8) answer = (((value*0.45359237)/100)/2);
		}

		else if(leftSelected==8){ //oz
			//oz -> kg			
			if(rightSelected==6) answer = (value*0.028349523);
			//oz -> hg
			if(rightSelected==7) answer = ((value*0.028349523)/10);
	    	//oz -> g
			if(rightSelected==8) answer = ((value*0.028349523)/100);
		}
	
	}


document.huvud.answerBox.value=answer;

}




function setList(n){

 if(n==1){
 ListSvLeft();
 ListAmRight();
 }
 else{
 ListAmLeft();
 ListSvRight();
 
 }
  
}
function ListAmLeft(){
	document.huvud.leftList.options[0].text="mile     ";
	document.huvud.leftList.options[1].text="foot     ";
	document.huvud.leftList.options[2].text="inch     ";
	document.huvud.leftList.options[3].text="Farenheit";
	document.huvud.leftList.options[4].text="Gallon   ";
	document.huvud.leftList.options[5].text="Pint     ";
	document.huvud.leftList.options[6].text="pound(lb)";
	document.huvud.leftList.options[7].text="cup      ";
	document.huvud.leftList.options[8].text="oz       ";
}

function ListSvLeft(){
	document.huvud.leftList.options[0].text="km";
	document.huvud.leftList.options[1].text="meter";
	document.huvud.leftList.options[2].text="cm";
	document.huvud.leftList.options[3].text="Celsius";
	document.huvud.leftList.options[4].text="Liter";
	document.huvud.leftList.options[5].text="dl";
	document.huvud.leftList.options[6].text="Kg";
	document.huvud.leftList.options[7].text="hg";
	document.huvud.leftList.options[8].text="g";
	
}
function ListAmRight(){
	document.huvud.rightList.options[0].text="mile";
	document.huvud.rightList.options[1].text="foot";
	document.huvud.rightList.options[2].text="inch";
	document.huvud.rightList.options[3].text="Farenheit";
	document.huvud.rightList.options[4].text="Gallon";
	document.huvud.rightList.options[5].text="Pint";
	document.huvud.rightList.options[6].text="pound(lb)";
	document.huvud.rightList.options[7].text="cup";
	document.huvud.rightList.options[8].text="oz";
}

function ListSvRight(){
	document.huvud.rightList.options[0].text="km";
	document.huvud.rightList.options[1].text="meter";
	document.huvud.rightList.options[2].text="cm";
	document.huvud.rightList.options[3].text="Celsius";
	document.huvud.rightList.options[4].text="Liter";
	document.huvud.rightList.options[5].text="dl";
	document.huvud.rightList.options[6].text="kg";
	document.huvud.rightList.options[7].text="hg";
	document.huvud.rightList.options[8].text="g";	
}

function loadpage(){
setList(1);
selectPossibleUnits(1);

}

//-->

