
var vin = ""
 
function SetVin (code) { 

  vin = code.toUpperCase()
  //fight with the Russian S
  vin = vin.replace ("S","C")
  //struggling with the symbol I
  vin = vin.replace ("I","1")
 //fighting symbol = O
  vin = vin.replace ("O","0")


  return (1)

}


function ChartoDigit (simbol) {
var ch = "1"
  if (simbol == "A") ch = "1"
  if (simbol == "B") ch = "2"
  if (simbol == "C") ch = "3"
  if (simbol == "D") ch = "4"
  if (simbol == "E") ch = "5"
  if (simbol == "F") ch = "6"
  if (simbol == "G") ch = "7"
  if (simbol == "H") ch = "8"
  if (simbol == "J") ch = "1"
  if (simbol == "K") ch = "2"
  if (simbol == "L") ch = "3"
  if (simbol == "M") ch = "4"
  if (simbol == "N") ch = "5"
  if (simbol == "P") ch = "7"
  if (simbol == "R") ch = "9"
  if (simbol == "S") ch = "2"
  if (simbol == "T") ch = "3"
  if (simbol == "U") ch = "4"
  if (simbol == "V") ch = "5"
  if (simbol == "W") ch = "6"
  if (simbol == "X") ch = "7"
  if (simbol == "Y") ch = "8"
  if (simbol == "Z") ch = "9"
  if (simbol == "0") ch = "0"
  if (simbol == "1") ch = "1"
  if (simbol == "2") ch = "2"
  if (simbol == "3") ch = "3"
  if (simbol == "4") ch = "4"
  if (simbol == "5") ch = "5"
  if (simbol == "6") ch = "6"
  if (simbol == "7") ch = "7"
  if (simbol == "8") ch = "8"
  if (simbol == "9") ch = "9"

    return (parseInt(ch))
}

function GetChar (position) { 

  return (vin.substring(position-1,position))

}
function CheckControl(control_result) { 

  //******************* Check control digit ***********************

	var digit_1 = ChartoDigit(GetChar(1)) * 8
	var digit_2 = ChartoDigit(GetChar(2)) * 7
	var digit_3 = ChartoDigit(GetChar(3)) * 6
	var digit_4 = ChartoDigit(GetChar(4)) * 5
	var digit_5 = ChartoDigit(GetChar(5)) * 4
	var digit_6 = ChartoDigit(GetChar(6)) * 3
	var digit_7 = ChartoDigit(GetChar(7)) * 2
	var digit_8 = ChartoDigit(GetChar(8)) * 10
	var digit_9 = ChartoDigit(GetChar(9))
	var digit_10 = ChartoDigit(GetChar(10)) * 9
	var digit_11 = ChartoDigit(GetChar(11)) * 8
	var digit_12 = ChartoDigit(GetChar(12)) * 7
	var digit_13 = ChartoDigit(GetChar(13)) * 6
	var digit_14 = ChartoDigit(GetChar(14)) * 5
	var digit_15 = ChartoDigit(GetChar(15)) * 4
	var digit_16 = ChartoDigit(GetChar(16)) * 3
	var digit_17 = ChartoDigit(GetChar(17)) * 2

	var sum_result = digit_1 + digit_2
	sum_result += digit_3 + digit_4 + digit_5 + digit_6 + digit_7 + digit_8 + digit_10
	sum_result += digit_11 + digit_12 + digit_13 + digit_14 + digit_15 + digit_16 + digit_17

	var round_result = Math.round(sum_result / 11)
	if (round_result > (sum_result/11)) {
	  round_result = round_result - 1
	}

	sum_result = sum_result - 11 * round_result

	control_result = "ERROR: Not been tested, the symbol for 9 - and the position must be " + sum_result
	if (sum_result == 10) {
	   control_result = "ERROR: not been tested, the symbol for 9 s position must be a X"
	}


	if ( sum_result == digit_9) {
	   control_result = "Tested OK"
	}

	if (sum_result == 10 && GetChar(9) == "X") {
	   control_result = "Tested OK" 
	}
return (control_result)

}
// For models until 1989
function GetTrans (trans_code) {

  if (trans_code == "A") return ("3 Speed, Automatic switching to the steering column - Part Time Transfer Case")
  if (trans_code == "B") return ("Automatic Part Time Transfer Case")
  if (trans_code == "C") return ("Automatic Full Time Transfer Case")
  if (trans_code == "D") return ("Automatic (2WD)")
  if (trans_code == "E") return ("Automatic - Part Time Transfer Case")
  if (trans_code == "F") return ("Manual, 5 Speed ( Part Time Transfer Case")
  if (trans_code == "G") return ("Manual, 4 Speed (Part Time Transfer Case")
  if (trans_code == "H") return ("Manual, 4 Speed floor location with a lever (4WD)")
  if (trans_code == "J") return ("3 Speed, automatic switching to the steering column (Full Time Transfer Case")
  if (trans_code == "1") return ("3 Speed, automatic switching to the steering column (Full Time Transfer Case")
  if (trans_code == "K") return ("Automatic Transmission, (4WD)")
  if (trans_code == "L") return ("Manual, 5 Speed (Part Time Transfer Case")
  if (trans_code == "M") return ("Manual, 4 - Express (Part Time Transfer Case")
  if (trans_code == "N") return ("Manual, 5 Speed (Part Time Transfer Case")
  if (trans_code == "P") return ("Manual, 5 Speed - Full Time Transfer Case")
  if (trans_code == "R") return ("Automatic Transmission, - Part Time Transfer Case")
  if (trans_code == "S") return ("Manual, 4 - with the speed of floor layout lever (2WD)")
  if (trans_code == "T") return ("Automatic Transmission, - Full Time Transfer Case")
  if (trans_code == "U") return ("Automatic - Rear WD")
  if (trans_code == "V") return ("5-Speed, Manual Transmission, Part Time Transfer Case")
  if (trans_code == "W") return ("Manual, 5 Speed - Rear WD")
  if (trans_code == "X") return ("Manual, 4 Speed - Part Time Transfer Case")
  if (trans_code == "Y") return ("Manual, 4 - with the speed of floor layout arm")
  if (trans_code == "Z") return ("Automatic CAT - box readings NP231")


  return ("Error: 5th Digit - Transmission Type")
}

function GetCountry (countrycode) {

	 if (countrycode == "1") return ("USA")
	 if (countrycode == "2") return ("Canada")
	 if (countrycode == "3") return ("Mexico")
     if (countrycode == "4") return ("USA")
     if (countrycode == "6") return ("Australia")
     if (countrycode == "8") return ("Venezuela")
     if (countrycode == "9") return ("Brazil")
     if (countrycode == "J") return ("Japan")
     if (countrycode == "K") return ("Korea")
     if (countrycode == "L") return ("Taiwan")
     if (countrycode == "S") return ("Kingdom")
     if (countrycode == "V") return ("France")
     if (countrycode == "W") return ("Germany")
     if (countrycode == "Y") return ("Sweden")
     if (countrycode == "Z") return ("Italy")

  return ("11th Digit - Country Code Error")
}

function GetMake (makecode) {

  if (makecode == "J") return ("Jeep (USA)")
  if (makecode == "B") return ("Jeep (Canada)")
  if (makecode == "E") return ("Jeep (China)")
  if (makecode == "Y") return ("Ensambladora Carabobo SA (Venezuela)")
  
  return ("No data on letter 2 - and the position ...")
}
// 8th Digit - Gross Vehicle Weight Rating (GVWR)
function GetGVWR (gvwrcode) {

  if (gvwrcode == "E") return ("3,001 - 4,000 lbs")
  if (gvwrcode == "F") return ("4,001 - 5000 lbs")
  if (gvwrcode == "G") return ("5,001 - 6,000 lbs")
  if (gvwrcode == "H") return ("6,001 - 7,000 lbs")

  return ("No value 8th Digit - Gross Vehicle Weight Rating (GVWR)")
}
// 5th Digit - Model
function GetTruck (truckcode, year_char) {
  if (truckcode == "K") return ("Liberty - rear")
  if (truckcode == "L") return ("Liberty - 4WD")
  if (truckcode == "M") return ("Liberty, RHD")
  if (truckcode == "A") return ("Wrangler")
  if (truckcode == "E") return ("Wrangler, RHD")
  if (truckcode == "4") return ("Wrangler, RHD")

  if (truckcode == "B"){
    if (year_char < 2007 ) return ("Cherokee - rear, RHD")
    return ("Wrangler - rear")
  }

  if (truckcode == "F"){
    if (year_char < 2007 ) return ("Cherokee - 4WD")
    return ("Compass, 4x4, LHD")
  }

  if (truckcode == "J") return ("Cherokee - 4WD, LHD")
  if (truckcode == "N"){
    if (year_char < 1991 ) return ("Cherokee Wagoneer")
    return ("Cherokee Briarwood")
  }

  if (truckcode == "R") return ("Grand Cherokee (WK)")
  if (truckcode == "G") return ("Commander (XK)")
  
  if (truckcode == "T"){
    if (year_char < 2007 ) return ("Cherokee - rear, LHD")
    return ("Compass, peredneprivodny, LHD")
  }

  if (truckcode == "W") return ("Grand Cherokee (WJ) - 4WD")
  if (truckcode == "2"){
  	if (year_char < 2001 ) return ("Grand Cherokee (WJ) - rear")
    return ("Grand Cherokee (WJ) - 4WD")
  }
  
  if (truckcode == "7"){
    if (year_char < 2007 ) return ("Grand Cherokee (WJ) - rear, RHD")
    return ("Compass, 4x4, RHD")
  }

  if (truckcode == "8") return ("Grand Cherokee (WJ) - 4WD, RHD")
  if (truckcode == "X"){
    if (year_char < 2001 ) return ("Grand Cherokee (ZJ) - rear")
    return ("Grand Cherokee (WJ) - rear")
  }
  if (truckcode == "Y") return ("Wrangler")
  if (truckcode == "Z") return ("Grand Cherokee - 4WD, LHD")
  
  if (truckcode == "S"){
    if (year_char < 2005 ) return ("Grand Wagoneer")
    return ("Grand Cherokee (WK)")
  }

  // If before 1989
  if (truckcode == "13") return ("Wagoneer/SJ MPV 4 Door Wagon")
  if (truckcode == "14") return ("Wagoneer/SJ MPV 4 Door Wagon")
  if (truckcode == "15") return ("GRAND WAGONEER/SJ")
  if (truckcode == "16") return ("Cherokee/SJ MPV 2 Door Wagon")
  if (truckcode == "17") return ("Cherokee/SJ MPV 2 Door Wagon WT")
  if (truckcode == "18") return ("Cherokee/SJ MPV 4 Door Wagon")
  if (truckcode == "19") return ("Cherokee/SJ MPV 4 Door Wagon WT")
  if (truckcode == "25") return ("J10 TRUCK 119 WHEELBASE")
  if (truckcode == "26") return ("J10 TRUCK 131 WHEELBASE")
  if (truckcode == "27") return ("J20 TRUCK 131 WHEELBASE")
  if (truckcode == "63") return ("Polnoprivodny COMANCHE `BOX 6 (standard body)")
  if (truckcode == "64") return ("Zadneprivodny COMANCHE 6`BOX (standard body)")
  if (truckcode == "65") return ("Polnoprivodny COMANCHE 7`BOX (long body)")
  if (truckcode == "66") return ("COMANCHE rear-7 `BOX (long body)")
  if (truckcode == "73") return ("CHEROKEE (XJ) - rear, 2 - door")
  if (truckcode == "74") return ("CHEROKEE (XJ) - rear, 4 - door")
  if (truckcode == "75") return ("CHEROKEE (XJ) - 4WD, 4 - door")
  if (truckcode == "77") return ("CHEROKEE (XJ) - 4WD, 2 - door ")
  if (truckcode == "78") return ("CHEROKEE (XJ) - 4WD, 4 - door")
  if (truckcode == "79") return ("CHEROKEE (XJ) - 4WD, 4 - door")
  if (truckcode == "81") return ("WRANGLER")
  if (truckcode == "85") return ("CJ-5")
  if (truckcode == "86") return ("CJ-6")
  if (truckcode == "87") return ("CJ-7")
  if (truckcode == "88") return ("SJ-8, SCRAMBLER")

  return ("Incorrect value on 5th digit...")
}

// 6th Digit - Series
function GetSeries (seriescode, model, year_char) {
if (model == "Y" || model == "A") {
//if Wrangler
  if (seriescode == "1") return ("Sport")
  if (seriescode == "2") return ("Base/SE")
  if (seriescode == "3"){ 
    if (year_char < 2002 ) return ("ISLANDER")
    return ("X")
  }
    if (seriescode == "4"){ 
    	if (year_char < 2000 ) return ("Sahara")
		//if (year_char > 2003 ) return ("Unlimited")

    return ("Sport")
  }
  if (seriescode == "5"){ 
    if (year_char < 2000 ) return ("Laredo")
    return ("Sahara")
  }
  if (seriescode == "6"){ 
    if (year_char < 2002 ) return ("Renegade")
    return ("Rubicon")
  }
  if (seriescode == "7") return ("Limited or Country")
}

if (model == "Z") {
//if Grand Cherokee ZJ
  if (seriescode == "4"){ 
  
    if (year_char < 1998 ) return ("Laredo")
    return ("TSI или Laredo Special Edition")
     
  }
  if (seriescode == "5") return ("Laredo")
    if (seriescode == "6") return ("Base")
  if (seriescode == "7") return ("Limited")
  if (seriescode == "8"){ 
  
    if (year_char < 1998 ) return ("Grand Wagoneer")
    return ("5.9 Limited")
     
  }

  if (seriescode == "A") return ("3 - Express GRAY (equipment for Europe)")
  if (seriescode == "B") return ("4 - Express GRAY (equipment for Europe)")
  if (seriescode == "N") return ("5 - RKPP Express (equipment for Europe)")
 }
if (model == "W" || model == "2") {
//if Grand Cherokee 99 years
  if (seriescode == "4") return ("Laredo")
  if (seriescode == "5"){ 
    if (year_char < 2000 ) return ("Laredo")
    return ("Limited")
  }
  if (seriescode == "6") return ("Limited")
}

if (model == "K" || model == "L" || model == "M") {
//if Liberty
  if (seriescode == "3") return ("Renegad")
  if (seriescode == "4") return ("Sport")
  if (seriescode == "5") return ("Limited")
  if (seriescode == "E") return ("5 - speed automatic gearbox (equipment for Europe)")

}


if (model == "X") {
//if Grand Cherokee ZJ or WJ 2WD
  if (seriescode == "4") return ("Laredo")
  if (seriescode == "5"){ 
    if (year_char < 1999 ) return ("Laredo")
    
    return ("Limited")
  }  if (seriescode == "6") return ("Base")
  if (seriescode == "7") return ("Limited")
  if (seriescode == "8"){ 
  
    if (year_char < 1998 ) return ("Grand Wagoneer")
    return ("5.9 Limited")
     
  }


  if (seriescode == "A") return ("3 - Express GRAY (equipment for Europe)")
  if (seriescode == "B") return ("4 - Express GRAY (equipment for Europe)")
  if (seriescode == "C") return ("5 - GRAY Express")
  if (seriescode == "E") return ("5 - speed GRAY (equipment for Europe)")
  if (seriescode == "N") return ("5 - RKPP Express (equipment for Europe)")
}
// end if Grand Cherokee 99 or Liberty

if (model == "R" || model == "S" ) {
	//if Grand Cherokee WK
	  if (seriescode == "4") return ("Laredo")
	  if (seriescode == "5") return ("Limited")
	  if (seriescode == "7") return ("SRT 8")

}
//if rest - Cherokee
  if (seriescode == "1") return ("Sport")
  if (seriescode == "2") return ("SE")
  if (seriescode == "3") return ("PIONEER")
  if (seriescode == "4") return ("Sport")
  if (seriescode == "5"){ 
  if (year_char < 2000 ) return ("Laredo")
  if (year_char == 2000 ) return ("Classic")
   return ("Limited")
  }
  if (seriescode == "6") return ("Sport or Classic")
  if (seriescode == "7"){ 
  
    if (year_char < 1998 ) return ("Limited or Country")
    return ("Limited")
     
  }
  if (seriescode == "8") return ("Basic Series")
  if (seriescode == "A") return ("3 - Express GRAY (Europe)")
  if (seriescode == "B") return ("4 - Express GRAY (Europe)")
  if (seriescode == "N") return ("5 - speed RKPP (Europe)")

  return ("Incorrect value on 6th digit...")
}

function GetBody (bodycode, year_char) {

  if (bodycode == "6") return ("2 - door pick-up truck")
  
  if (bodycode == "7"){ 
  
    if (year_char < 2007 ) return ("4-door")
    return ("4-door")
     
  }

  if (bodycode == "8") return ("4-door")
  
  if (bodycode == "4"){ 
  
    if (year_char < 2007 ) return ("Open, elongated")
    return ("Open")
     
  }

  if (bodycode == "9"){ 
  
    if (year_char < 2007 ) return ("Open")
    return ("Open, elongated")
     
  }


  return ("No value returned...")
}
// Eighth Digit - Engine
function GetEngine (enginecode, year_char, model) {

  
  if (enginecode == "1"){
   if (year_char < 2007) return ("2.4 litre, 4 Cylinder, Multi-Injection")
   return ("3.8 litre, V6")
 }
  if (enginecode == "3") return ("6.1 litre, V8")
  if (enginecode == "4") return ("3.1 litre, 5 Cylinder, Turbo")
  if (enginecode == "K") return ("3.7 litre, V6")
  if (enginecode == "C") return ("4.2 litre, 6 Cylinder, Carburettor")
  if (enginecode == "D") return ("2.5 litre, 4 Cylinder")
  if (enginecode == "E") return ("2,5 litre, I-4, Central Injection")
  if (enginecode == "J") return ("4.7 litre, V8, HO")
  if (enginecode == "G") return ("2,5 litre, I-4, Central Injection")
  if (enginecode == "L") return ("4.0 litre, 6 Cylinder")
  if (enginecode == "S") return ("4.0 litre, 6 Cylinder, HO")
  if (enginecode == "T") return ("4.2 litre, 6 Cylinder")
  if (enginecode == "V") return ("4.0 litre, 6 Cylinder, Multi-Injection, Leaded Gasoline")
  
  if (enginecode == "Y"){
   if (year_char < 2007) return ("5.2 litre, V8 , Multi-Injection")
   return ("2.0 litre, 4 Cylinder, Diesel")
 }

  if (enginecode == "W"){
   if (year_char < 2000) return ("2.8 litre, V6, carburettor")
   return ("2.4 litre, 4 Cylinder, Fuel Injection")
 }

  if (enginecode == "Z") return ("5.9 litre, V8, Multi Injection")
  if (enginecode == "A"){
   if (year_char < 2002) return ("4.2 litre, 6 Cylinder")
   return ("2.7 litre, 5 Cylinder, Diesel, Mercedes")
 }
 
 if (enginecode == "2"){
   if (year_char < 2005) return ("2.7 litre, 5 Cylinder, Diesel, Mercedes")
   return ("5.7 litre, V8")
 }

 if (enginecode == "B"){
   if (year_char < 1984) return ("2.5 litre, 4 Cylinder, GM Motor Company")
   return ("Diesel Engine, 2.1 litre, 4 Cylinder, Reno")
 }
if (enginecode == "5") return ("2.8 litre, 4 Cylinder, Diesel, VM Motor")
if (enginecode == "7"){
   if (year_char < 2000) return ("5.9 litre, V8, Multi Injection")
   return ("2.5 litre, 4 Cylinder, 16 Valve, Turbo")
 }

  if (enginecode == "P"){
   if (year_char < 1987 ) return ("Diesel Engine, 2.1 litre, 4 Cylinder, Renault")
   if (year_char < 1991 ) return ("2.5 litre, 4 Cylinder, Central Injection")
   return ("2.5 litre, cylinder, 4 Cylinder, Multi-injection")
  }
  if (enginecode == "H"){
    if (year_char < 1986 ) return ("5.0 litre, V8 ")
    if (year_char < 1991 ) return ("2.5 litre, 4 Cylinder, Central injection")
    return ("2.5 litre, 4 Cylinder, Distributed Injection, Leaded Gasoline")
  }
  if (enginecode == "F"){
    if (year_char < 1987 ) return ("Diesel Engine, 2.5 litre , Isuzu")
    return ("2.5 litre, 4 Cylinder, (1BBL) - Carburettor")
  }
  if (enginecode == "M") {
       //If 1989 or 1990
		if (year_char == 1989 || year_char == 1990) return ("4.2 litre, I-6, Carburettor")
		
		// If 1987 or 1988
		if (year_char == 1987 || year_char == 1988 ) return ("4.0 litre, I-6, EFI ")
		//If the rest of
		return ("2.5 litre, 4 Cylinder, Diesel, VM Motors")
	}
if (enginecode == "U") {
       //if the CJ-7
		if (model == "87" ) return ("4.0 litre, I-6, Carburettor")
		return ("2.5 litre, 4 Cylinder, Carburettor")
	}
if (enginecode == "N"){
   if (year_char < 1999 ) return ("5.9 litre, V8")
   return ("4.7 litre, V8, Multi Injection")
}

  return ("No value returned...")
}
//10th Digit Year
function GetYear (yearcode) {
  if (yearcode == "9") { return ("2009") }
  if (yearcode == "8") { return ("2008") }
  if (yearcode == "7") { return ("2007") }
  if (yearcode == "6") { return ("2006") }
  if (yearcode == "5") { return ("2005") }
  if (yearcode == "4") { return ("2004") }
  if (yearcode == "3") { return ("2003") }
  if (yearcode == "2") { return ("2002") }
  if (yearcode == "1") { return ("2001") }
  if (yearcode == "Y") { return ("2000") }
  if (yearcode == "X") { return ("1999") }
  if (yearcode == "W") { return ("1998") }
  if (yearcode == "V") { return ("1997") }
  if (yearcode == "T") { return ("1996") }
  if (yearcode == "S") { return ("1995") }
  if (yearcode == "R") { return ("1994") }
  if (yearcode == "P") { return ("1993") }
  if (yearcode == "N") { return ("1992") }
  if (yearcode == "M") { return ("1991") }
  if (yearcode == "L") { return ("1990") }
  if (yearcode == "K") { return ("1989") }
  if (yearcode == "J") { return ("1988") }
  if (yearcode == "H") { return ("1987") }
  if (yearcode == "G") { return ("1986") }
  if (yearcode == "F") { return ("1985") }
  if (yearcode == "E") { return ("1984") }
  if (yearcode == "D") { return ("1983") }
  if (yearcode == "C") { return ("1982") }
  if (yearcode == "B") { return ("1981") }
  if (yearcode == "A") { return ("1980") }

  return ("Incorrect value to 10th digit...")
}
// 11th symbol
function GetPlant (code) {

  if (code == "A") { return ("Auburn Hills") }
  if (code == "B") { return ("Brampton Plant (Bramalea, Ontario)") }
  if (code == "C") { return ("Detroit (Jefferson North)") }
  if (code == "D") { return ("Belvidere Assembly") }
  if (code == "J") { return ("Brampton Plant (Bramalea, Ontario)") }
  if (code == "L") { return ("Toledo, Ohio") }
  if (code == "P") { return ("Toledo, Ohio") }
  if (code == "E") { return ("Beijing Jeep Corp Ltd") }
  if (code == "T") { return ("Toledo, Ohio") }
  if (code == "W") { return ("Toledo, Ohio, USA ") }
  if (code == "Y") { return ("Steyr, Austria") }


  return ("Incorrect value to 11th digit...")
}



function Decode (form) {

  var temp = ""
  var count = 0
  vin = vin.toUpperCase()

  if (vin == "") {
      alert("Please enter your 17 character VIN code")
      return 0
      }

  if (vin.length != 17) {
      alert("The code should consist of 17 characters")
      return 0
      }
// Determine - car produced before 1989 or after
   var year = GetYear(GetChar(10))
   if (year > 1988){

//  ************************************************
      // get country
      var country = GetCountry(GetChar(1))
      //get make
      var make = GetMake(GetChar(2))
      // get truck
      var truck = GetTruck(GetChar(5), year)
      //get Series
      var series = GetSeries(GetChar(6),GetChar(5), year)
      // get Body
      var body = GetBody(GetChar(7), year)
      // get Engine 
      var engine = GetEngine(GetChar(8),year, GetChar(5))
      // get year
      // get plant
      var plant = GetPlant(GetChar(11))
      // get ser_num
      var ser_num = vin.substring(11,17)  
      var check_result = "Has passed check"
      check_result = CheckControl(check_result)
      //  *****************  Display answer  ************************
    var
	text ="Verified:"+ " "           + check_result + "\n"
	text +="VIN code:"+ "\n"         + vin + "\n"
    text +="Manufacturer:"+ "\n"     + make + "\n"
    text +="Model:"+ "\n"            + truck +"\n"
	text +="Series:"+ "\n"           + series +"\n"
	text +="Body:"+ "\n"             + body + "\n"
	text +="Engine Type:"+ "\n"      + engine + "\n"
	text +="Plant:"+ "\n"            + plant + "\n"
	text +="Country:"+ "\n"          + country + "\n"
	text +="Model Year:"+ "\n"       + year + "\n"
	text +="Serial Number:"+ "\n"    + ser_num + "\n"

form.value=text

}
else
{
 // get country
var country = GetCountry(GetChar(1))
//get Make
var make = GetMake(GetChar(2))
// get Truck
var truck_num = vin.substring(5,7)
var truck = GetTruck(truck_num, year)
// get Engine 
var engine = GetEngine(GetChar(4),year, truck_num)
//get Series
var series = GetTrans(GetChar(5))
// get Year
//More - as usual     
// get plant
var plant = GetPlant(GetChar(11))
// get ser_num
var ser_num = vin.substring(11,17)  
var check_result = "Has passed check"
check_result = CheckControl(check_result)

//  *****************  Display answer  ************************
    var
	text = "Verified:"+ " "         + check_result + "\n"
	text +="VIN Code"+ "\n"         + vin + "\n"
    text +="Manufacturer:"+ "\n"    + make + "\n"
    text +="Model:"+ "\n"           + truck +"\n"
	text +="Series:"+ "\n"          + series +"\n"
	text +="Engine:"+ "\n"          + engine + "\n"
	text +="Plant:"+ "\n"           + plant + "\n"
	text +="Country:"+ "\n"         + country + "\n"
	text +="Model year:"+ "\n"      + year + "\n"
	text +="Serial Number:"+ "\n"   + ser_num + "\n"
	
	

document.getElementById('answer').innerHTML = text

}

return 1

}



