CREATE TABLE `RV_brands` (
  `brands_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `brand_name` varchar(255) NOT NULL DEFAULT '',
  `model_code` varchar(50) NOT NULL DEFAULT '',
  `description` mediumtext NOT NULL,
  `option_labels` mediumtext NOT NULL,
  `option_type` mediumtext NOT NULL,
  `option_list` mediumtext NOT NULL,
  `manufacturer_id` int(4) NOT NULL DEFAULT '0',
  `class_id` int(4) NOT NULL DEFAULT '0',
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `couch_id` int(4) DEFAULT NULL,
  `multi_class` varchar(12) NOT NULL DEFAULT '0',
  `display_order` tinyint(2) DEFAULT '0',
  PRIMARY KEY (`brands_id`),
  KEY `manufacturer_id` (`manufacturer_id`,`class_id`,`display_order`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_chassis` (
  `chassis_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `chassis` varchar(100) NOT NULL DEFAULT '',
  `active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`chassis_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `RV_chassis` (`chassis_id`, `chassis`, `active`)
VALUES
	(1,'Dynomax',1),
	(2,'Freightliner',1),
	(3,'Gillig',1),
	(4,'Magnum',1),
	(5,'Newell',1),
	(6,'Peak',1),
	(7,'Roadmaster',1),
	(8,'Spartan',1),
	(9,'TravelRide',1);

CREATE TABLE `RV_classes` (
  `classes_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `class_name` varchar(255) NOT NULL DEFAULT '',
  `category` varchar(255) NOT NULL DEFAULT '',
  `class_order` int(4) NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`classes_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `RV_classes` (`classes_id`, `class_name`, `category`, `class_order`, `active`)
VALUES
	(1,'Class A','Motorhome',1,1),
	(2,'Class B','Motorhome',2,1),
	(3,'Class C','Motorhome',3,1),
	(4,'Fifth Wheel','Towable',6,1),
	(5,'Travel Trailer','Towable',7,1),
	(6,'Toy Hauler','Towable',8,1),
	(8,'Pop Up Camper','Towable',11,1),
	(9,'Truck Camper','Towable',12,1),
	(10,'Park Model','Park Model',14,1),
	(11,'Custom Class','Custom',15,1),
	(12,'','',4,1),
	(13,'','',13,1),
	(14,'Toy Hauler Fifth Wheel','Towable',9,1),
	(15,'Toy Hauler Travel Trailer','Towable',10,1),
	(16,'Destination Trailer','Towable',5,1);

CREATE TABLE `RV_file_categories` (
  `file_category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `file_type_id` int(11) NOT NULL DEFAULT '0',
  `category_name` varchar(100) NOT NULL DEFAULT '',
  `category_description` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`file_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_file_types` (
  `file_type_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `file_type` varchar(50) NOT NULL DEFAULT '',
  `library_only` int(1) NOT NULL DEFAULT '0',
  `static_file_type` varchar(50) NOT NULL DEFAULT '',
  `display_order` int(2) NOT NULL DEFAULT '0',
  PRIMARY KEY (`file_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `RV_file_types` (`file_type_id`, `file_type`, `library_only`, `static_file_type`, `display_order`)
VALUES
	(1,'Floor Plans',0,'floorplans',4),
	(2,'Exterior Images',0,'exterior',6),
	(3,'Interior Images',0,'interior',7),
	(4,'Brochures',0,'brochures',5),
	(5,'Videos',0,'videos',10),
	(7,'Special Features',0,'features',9),
	(8,'Hero Image',0,'hero',1),
	(9,'Matterport',0,'360',2),
	(10,'Product Logo',0,'logos',3),
	(11,'Construction Image',0,'construction',8),
	(12,'Creative Files',1,'creative',11),
	(13,'Decors',0,'decors',12);

CREATE TABLE `RV_files` (
  `file_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `applies_to_table` varchar(50) NOT NULL DEFAULT '',
  `applies_to_id` int(4) NOT NULL DEFAULT '0',
  `file_url` varchar(255) NOT NULL DEFAULT '',
  `file_type_id` int(4) NOT NULL DEFAULT '0',
  `file_category_id` INT(4)  NOT NULL  DEFAULT '0',
  `file_order` int(2) NOT NULL DEFAULT '0',
  PRIMARY KEY (`file_id`),
  KEY `applies_to_id` (`applies_to_id`,`file_type_id`),
  KEY `file_type_id` (`file_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_floor_plans` (
  `floor_plans_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `brand_id` int(4) NOT NULL DEFAULT '0',
  `floor_plan` varchar(150) NOT NULL DEFAULT '',
  `model_year` varchar(10) NOT NULL DEFAULT '',
  `specific_model_code` varchar(50) NOT NULL DEFAULT '',
  `specific_class_id` int(4) NOT NULL DEFAULT '0',
  `active` int(1) NOT NULL DEFAULT '1',
  `floor_plan_order` int(4) NOT NULL DEFAULT '0',
  `fpstatus` varchar(50) NOT NULL DEFAULT 'normal',
  `description` mediumtext NOT NULL,
  `option_labels` mediumtext NOT NULL,
  `option_type` mediumtext NOT NULL,
  `option_list` mediumtext NOT NULL,
  `gross_vehicle_weight_rating` varchar(250) NOT NULL DEFAULT '',
  `dry_weight` varchar(250) NOT NULL DEFAULT '',
  `hitch_weight` varchar(250) NOT NULL DEFAULT '',
  `carrying_capacity` varchar(250) NOT NULL DEFAULT '',
  `width` varchar(150) NOT NULL DEFAULT '',
  `height` varchar(150) NOT NULL DEFAULT '',
  `length` varchar(150) NOT NULL DEFAULT '',
  `square_feet` varchar(250) NOT NULL DEFAULT '',
  `sleeping_capacity` varchar(150) NOT NULL DEFAULT '',
  `axles` varchar(150) NOT NULL DEFAULT '',
  `tires` varchar(150) NOT NULL DEFAULT '',
  `shocks` varchar(250) NOT NULL DEFAULT '',
  `fresh_tank` varchar(250) NOT NULL DEFAULT '',
  `gray_tank` varchar(250) NOT NULL DEFAULT '',
  `black_tank` varchar(250) NOT NULL DEFAULT '',
  `water_heater` varchar(250) NOT NULL DEFAULT '',
  `furnace` varchar(250) NOT NULL DEFAULT '',
  `air_conditioner` varchar(250) NOT NULL DEFAULT '',
  `lp_tank_capacity` varchar(150) NOT NULL DEFAULT '',
  `refrigerator` varchar(150) NOT NULL DEFAULT '',
  `110v_electric` varchar(250) NOT NULL DEFAULT '',
  `converter` varchar(150) NOT NULL DEFAULT '',
  `rvalue_wall` varchar(150) NOT NULL DEFAULT '',
  `rvalue_floor` varchar(150) NOT NULL DEFAULT '',
  `rvalue_roof` varchar(150) NOT NULL DEFAULT '',
  `construction` varchar(200) NOT NULL DEFAULT '',
  `roof_material` varchar(150) NOT NULL DEFAULT '',
  `number_of_slides` varchar(250) NOT NULL DEFAULT '',
  `number_of_bunks` varchar(250) NOT NULL DEFAULT '',
  `slide_room_height` varchar(150) NOT NULL DEFAULT '',
  `bedroom_height` varchar(150) NOT NULL DEFAULT '',
  `awning_length` varchar(150) NOT NULL DEFAULT '',
  `cook_top` varchar(150) NOT NULL DEFAULT '',
  `traditional_oven` varchar(150) NOT NULL DEFAULT '',
  `convection_oven` varchar(150) NOT NULL DEFAULT '',
  `microwave_oven` varchar(150) NOT NULL DEFAULT '',
  `generator_prep` varchar(150) NOT NULL DEFAULT '',
  `generator` varchar(200) NOT NULL DEFAULT '',
  `generator_brand` varchar(150) NOT NULL DEFAULT '',
  `generator_kilowatts` varchar(250) NOT NULL DEFAULT '',
  `standard_bed_dimensions` varchar(150) NOT NULL DEFAULT '',
  `optional_bed_dimensions` varchar(150) NOT NULL DEFAULT '',
  `tow_measure_by` varchar(1) NOT NULL DEFAULT 'd',
  PRIMARY KEY (`floor_plans_id`),
  KEY `brand_id` (`brand_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_interiors` (
  `interior_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `interior_decor` varchar(100) NOT NULL DEFAULT '',
  `floor_plan_id` int(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`interior_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_library` (
  `library_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) NOT NULL DEFAULT '',
  `file_type` varchar(20) NOT NULL DEFAULT '',
  `extension` varchar(10) NOT NULL DEFAULT '',
  `file_uploaded` datetime NOT NULL,
  `manufacturer` varchar(100) NOT NULL DEFAULT '',
  `model` varchar(100) NOT NULL DEFAULT '',
  `model_year` varchar(10) NOT NULL DEFAULT '',
  `floor_plan` varchar(100) NOT NULL DEFAULT '',
  `original_file_name` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`library_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_manufacturers` (
  `manufacturers_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `manufacturer_name` varchar(255) NOT NULL DEFAULT '',
  `active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`manufacturers_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `RV_manufacturers` (`manufacturers_id`, `manufacturer_name`, `active`)
VALUES
	(1,'Heartland',1),
	(2,'Dutchmen',1),
	(3,'CrossRoads',1),
	(4,'Keystone',1),
	(5,'Adventure',1),
	(6,'Aerolite',1),
	(7,'Airstream',1),
	(8,'Born Free',1),
	(9,'Carriage',1),
	(10,'Chalet',1),
	(11,'Cikira',1),
	(12,'Coachmen',1),
	(16,'Damon',1),
	(17,'DoubleTree (DRV)',1),
	(18,'Dynamax',1),
	(19,'Entegra Coach',1),
	(20,'EverGreen',1),
	(23,'Featherlite Coaches',1),
	(25,'Forest River',1),
	(26,'Four Winds',1),
	(27,'Georgie Boy',1),
	(28,'Gulf Stream',1),
	(29,'Holiday Rambler',1),
	(30,'Hy-Line Enterprises',1),
	(32,'KZ',1),
	(33,'Lance',1),
	(34,'Marathon',1),
	(35,'Monaco',1),
	(36,'National',1),
	(37,'Newell Custom Coach',1),
	(38,'Newmar',1),
	(39,'Northstar',1),
	(40,'Northwood Manufacturing',1),
	(41,'Nu-Wa',1),
	(42,'Pacific Coachworks',1),
	(43,'Palomino',1),
	(44,'Parliament Coach',1),
	(45,'Pilgrim International',1),
	(46,'Play-Mor Trailers',1),
	(47,'R-Vision',1),
	(48,'Rage\'n Luxury Toy Haulers',1),
	(49,'Renegade Motorcoach',1),
	(50,'Revcon Motorcoach',1),
	(51,'Rexhall',1),
	(52,'Skyline',1),
	(53,'Starcraft',1),
	(54,'Sunnybrook',1),
	(55,'Thor',1),
	(56,'Tiffin Motorhomes',1),
	(57,'TrailManor',1),
	(58,'Travel Supreme',1),
	(59,'Travel Lite Campers',1),
	(60,'Winnebago',1),
	(61,'General Coach Canada',1),
	(62,'Glendale Recreational Vehicles',1),
	(63,'Okanagan',1),
	(64,'Pleasure Way',1),
	(65,'Roadtrek',1),
	(66,'Triple E',1),
	(67,'Adirondack',1),
	(68,'Airex',1),
	(69,'Alfa',1),
	(70,'Aliner',1),
	(71,'All American Sport',1),
	(72,'Allen Camper',1),
	(73,'Alpenlite',1),
	(74,'Alpha Ideal',1),
	(75,'Alpine',1),
	(76,'Aluminum Trailer Company',1),
	(77,'Ameri-Camp',1),
	(78,'American Coach',1),
	(79,'American Dream',1),
	(80,'American Freedom',1),
	(81,'American Hauler',1),
	(82,'American Star',1),
	(83,'American Travel Systems',1),
	(84,'Apache',1),
	(85,'Aspen',1),
	(86,'Athens Park Homes',1),
	(87,'Augusta',1),
	(88,'Auto Mate',1),
	(89,'Avion',1),
	(90,'Beaver',1),
	(91,'Bigfoot',1),
	(92,'Blue Bird',1),
	(93,'Bravo',1),
	(94,'Breckenridge',1),
	(95,'Bridgeview',1),
	(96,'Brill',1),
	(97,'Burro',1),
	(98,'Callen',1),
	(99,'Canterbury',1),
	(101,'Carson Trailer',1),
	(102,'Casita',1),
	(103,'Cavco',1),
	(105,'Champion',1),
	(106,'Chariot Eagle',1),
	(107,'Chinook',1),
	(109,'Coach House',1),
	(110,'Cobra',1),
	(111,'Coleman',1),
	(112,'Columbia Northwest',1),
	(113,'Cortez',1),
	(114,'Country Coach',1),
	(115,'Cozy Traveler',1),
	(117,'Cruiser',1),
	(118,'CT Coachworks',1),
	(119,'DRV',1),
	(121,'Diamond',1),
	(122,'Dolphin',1),
	(123,'Dune Sport',1),
	(124,'Dutch Park',1),
	(127,'E-Z Lite',1),
	(128,'Earthbound',1),
	(129,'Echo',1),
	(130,'Eclipse',1),
	(131,'El Dorado',1),
	(133,'Era Motor Homes',1),
	(134,'Establishment',1),
	(136,'Excel - Peterson',1),
	(137,'Exiss Trailers',1),
	(138,'Extreme Warrior',1),
	(139,'Extreme',1),
	(140,'FMC',1),
	(141,'Fairmont Homes',1),
	(142,'Fiber-Lite',1),
	(143,'Firan Motor Coach',1),
	(144,'Fireball',1),
	(145,'Fleetwood',1),
	(146,'Ford',1),
	(148,'Foretravel',1),
	(149,'Forks',1),
	(150,'Franklin',1),
	(151,'Frontier',1),
	(152,'GMC',1),
	(153,'General Coach',1),
	(155,'Glacier Bay',1),
	(157,'Grand Design',1),
	(158,'Grand Junction',1),
	(159,'Great West Vans',1),
	(161,'Hallmark',1),
	(162,'Harney Coach Works',1),
	(163,'Haulmark',1),
	(164,'Hawkins Motor Coach',1),
	(165,'Heritage Park Homes',1),
	(166,'Heritage',1),
	(167,'Hi-Lo',1),
	(168,'Holiday Coach',1),
	(169,'Homesteader',1),
	(170,'Honey Coach Works',1),
	(171,'Honorbuilt',1),
	(172,'Horizon',1),
	(173,'Host',1),
	(175,'Ice Castle',1),
	(176,'Instant Mobile House',1),
	(177,'Intermountain',1),
	(178,'International Serenity',1),
	(179,'Invader',1),
	(180,'Itasca',1),
	(181,'Jacobsen',1),
	(182,'Jayco',1),
	(183,'K-Z Manufacturing',1),
	(184,'Kaddy Kruiser',1),
	(186,'Kibbi',1),
	(412,'Aljo',1),
	(413,'Allegro',1),
	(414,'Aluma-Lite',1),
	(415,'American Eagle',1),
	(416,'American Tradition',1),
	(417,'Arctic Fox',1),
	(418,'Bounder',1),
	(419,'Cameo',1),
	(420,'Cardinal',1),
	(421,'Carri-Lite',1),
	(422,'Cedar Creek',1),
	(423,'Cherokee',1),
	(424,'Citation',1),
	(425,'Discovery',1),
	(426,'Dutch Star',1),
	(427,'Fiesta',1),
	(428,'Flagstaff',1),
	(429,'Flair-Fleetwood',1),
	(430,'Georgetown',1),
	(431,'Jamboree',1),
	(432,'Kit',1),
	(433,'Komfort',1),
	(434,'Kountry Star',1),
	(435,'Layton',1),
	(436,'Mallard',1),
	(437,'Mountain Aire',1),
	(438,'Nash',1),
	(439,'Nomad',1),
	(440,'Pace-Arrow',1),
	(441,'Pioneer',1),
	(442,'Pleasure-Way',1),
	(443,'Prowler',1),
	(444,'Rockwood',1),
	(445,'Safari',1),
	(446,'Salem',1),
	(447,'Sandpiper',1),
	(448,'Shasta',1),
	(449,'Sierra',1),
	(450,'Skamper',1),
	(451,'Southwind',1),
	(452,'Sportsmen',1),
	(453,'Sun-Lite',1),
	(454,'Sunline',1),
	(455,'Sunseeker',1),
	(456,'Surveyor',1),
	(457,'Tahoe',1),
	(458,'Terry',1),
	(459,'Thorustries',1),
	(460,'Tioga',1),
	(461,'Trail-Lite',1),
	(462,'Viking',1),
	(463,'Wanderer',1),
	(464,'Weekend Warrior',1),
	(465,'Wildcat',1),
	(466,'Wilderness',1),
	(467,'Wildwood',1),
	(468,'Recreation By Design',1);

CREATE TABLE `RV_option_categories` (
  `option_category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `category_name` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`option_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `RV_option_categories` (`option_category_id`, `category_name`)
VALUES
	(1,'Wireless Remote Control System'),
	(2,'Cabinetry'),
	(3,'Universal Docking Center'),
	(4,'Storage'),
	(5,'Bedroom'),
	(6,'Exterior'),
	(7,'Floor Construction'),
	(8,'Roof Construction'),
	(9,'Wall Construction'),
	(10,'Frame & Landing Gear'),
	(11,'Tire / Axles / Suspension'),
	(12,'Underbelly'),
	(13,'Plumbing'),
	(14,'Power'),
	(16,'Cooling'),
	(17,'Insulation Values'),
	(18,'Main Slide Rooms'),
	(19,'Protection & Safety'),
	(20,'Kitchen'),
	(21,'Bath Area'),
	(22,'Shower'),
	(23,'Commode Room'),
	(27,'Interior'),
	(28,'Appliances'),
	(29,'Heating & Cooling'),
	(30,'Special Build Options'),
	(31,'Living Room'),
	(34,'Entertainment & Connections'),
	(35,'Yeti Extreme Weather Package'),
	(36,'Full-Timer Package (Generator Prep Required)'),
	(37,'Window Features');

CREATE TABLE `RV_options` (
  `options_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `vehicle_option_id` int(4) NOT NULL DEFAULT '0',
  `vehicle_option_text` varchar(255) NOT NULL DEFAULT '',
  `applies_to_table` varchar(50) NOT NULL DEFAULT '',
  `applies_to_id` int(4) NOT NULL DEFAULT '0',
  `standard` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`options_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_packages` (
  `package_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `package_name` varchar(150) NOT NULL DEFAULT '',
  `brand_id` int(4) NOT NULL DEFAULT '0',
  `client_id` varchar(50) NOT NULL DEFAULT '',
  `dealer_id` int(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`package_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_pages` (
  `page_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `applies_to_table` varchar(30) NOT NULL DEFAULT '',
  `applies_to_id` int(11) NOT NULL DEFAULT '0',
  `section_order` int(2) NOT NULL DEFAULT '0',
  `section_default_display` int(1) NOT NULL DEFAULT '0',
  `section_header` varchar(100) NOT NULL DEFAULT '',
  `section_html` mediumtext NOT NULL,
  PRIMARY KEY (`page_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_pricing` (
  `pricing_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `pricing_method_id` int(4) NOT NULL DEFAULT '0',
  `price` float(8,2) NOT NULL DEFAULT '0.00',
  `applies_to_table` varchar(50) NOT NULL DEFAULT '',
  `applies_to_id` int(4) NOT NULL DEFAULT '0',
  `client_id` varchar(50) NOT NULL DEFAULT '',
  `dealer_id` int(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`pricing_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_pricing_methods` (
  `pricing_method_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `pricing_method` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`pricing_method_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `RV_pricing_methods` (`pricing_method_id`, `active`, `pricing_method`)
VALUES
	(1,1,'Retail'),
	(2,1,'Wholesale');

CREATE TABLE `RV_status` (
  `status_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `status_type` varchar(50) NOT NULL DEFAULT '',
  `status_order` int(4) NOT NULL,
  PRIMARY KEY (`status_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `RV_status` (`status_id`, `status_type`, `status_order`)
VALUES
	(1,'New',1),
	(2,'Used',2),
	(3,'Certified',3),
	(4,'Wholesale',4);

CREATE TABLE `RV_upgrades` (
  `upgrade_id` int(4) unsigned NOT NULL AUTO_INCREMENT,
  `upgrade_label` varchar(100) NOT NULL DEFAULT '',
  `upgrade_order` int(2) NOT NULL DEFAULT '0',
  `floor_plan_id` int(4) NOT NULL DEFAULT '0',
  `option_id` int(4) NOT NULL DEFAULT '0',
  `option_text` varchar(255) NOT NULL DEFAULT '',
  `package_id` int(4) NOT NULL DEFAULT '0',
  `included` tinyint(1) NOT NULL DEFAULT '0',
  `client_id` varchar(50) NOT NULL DEFAULT '',
  `dealer_id` int(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`upgrade_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RV_vin1` (
  `digit` varchar(1) NOT NULL DEFAULT '',
  `decode_value` varchar(100) NOT NULL DEFAULT '',
  `vin1_id` int(4) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`vin1_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin1` (`digit`, `decode_value`, `vin1_id`)
VALUES
	('1','United States',1),
	('2','Canada',2),
	('3','Mexico',3),
	('4','United States',4),
	('5','United States',5),
	('6','Australia',6),
	('9','Brazil',7),
	('J','Japan',8),
	('K','Korea',9),
	('L','China, Taiwan',10),
	('M','Thailand',11),
	('S','United Kingdom',12),
	('T','Hungary',13),
	('V','France',14),
	('W','Germany',15),
	('X','Russian Federation',16),
	('Y','Belgium, Sweden',17),
	('Z','Italy',18);

CREATE TABLE `RV_vin10` (
  `digit` varchar(1) NOT NULL DEFAULT '',
  `decode_value` varchar(10) NOT NULL DEFAULT '',
  `vin23` int(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin10` (`digit`, `decode_value`, `vin23`)
VALUES
	('G','1986',0),
	('H','1987',0),
	('J','1988',0),
	('K','1989',0),
	('L','1990',0),
	('M','1991',0),
	('N','1992',0),
	('P','1993',0),
	('R','1994',0),
	('S','1995',0),
	('T','1996',0),
	('V','1997',0),
	('W','1998',0),
	('X','1999',0),
	('Y','2000',0),
	('1','2001',0),
	('2','2002',0),
	('3','2003',0),
	('4','2004',0),
	('5','2005',0),
	('6','2006',0),
	('7','2007',0),
	('8','2008',0),
	('9','2009',0),
	('A','2010',0),
	('B','2011',0),
	('C','2012',0),
	('D','2013',0),
	('E','2014',0),
	('F','2015',0),
	('X','1999',1),
	('W','1998',1),
	('V','1997',1),
	('T','1996',1),
	('S','1995',1),
	('R','1994',1),
	('P','1993',1),
	('N','1992',1),
	('M','1991',1),
	('L','1990',1),
	('K','1989',1),
	('J','1988',1),
	('H','1987',1),
	('G','1986',1),
	('F','2015',1),
	('E','2014',1),
	('D','2013',1),
	('C','2012',1),
	('B','2011',1),
	('A','2010',1),
	('9','2009',1),
	('8','2008',1),
	('7','2007',1),
	('6','2006',1),
	('5','2005',1),
	('4','2004',1),
	('3','2003',1),
	('2','2002',1),
	('1','2001',1),
	('Y','2000',3),
	('X','1999',3),
	('W','1998',3),
	('V','1997',3),
	('T','1996',3),
	('S','1995',3),
	('R','1994',3),
	('P','1993',3),
	('N','1992',3),
	('M','1991',3),
	('L','1990',3),
	('K','1989',3),
	('J','1988',3),
	('H','1987',3),
	('G','1986',3),
	('F','2015',3),
	('E','2014',3),
	('D','2013',3),
	('C','2012',3),
	('B','2011',3),
	('A','2010',3),
	('9','2009',3),
	('8','2008',3),
	('7','2007',3),
	('6','2006',3),
	('5','2005',3),
	('4','2004',3),
	('3','2003',3),
	('2','2002',3),
	('1','2001',3),
	('Y','2000',7),
	('X','1999',7),
	('W','1998',7),
	('V','1997',7),
	('T','1996',7),
	('S','1995',7),
	('R','1994',7),
	('P','1993',7),
	('N','1992',7),
	('M','1991',7),
	('L','1990',7),
	('K','1989',7),
	('J','1988',7),
	('H','1987',7),
	('G','1986',7),
	('F','2015',7),
	('E','2014',7),
	('D','2013',7),
	('C','2012',7),
	('B','2011',7),
	('A','2010',7),
	('9','2009',7),
	('8','2008',7),
	('7','2007',7),
	('6','2006',7),
	('5','2005',7),
	('4','2004',7),
	('3','2003',7),
	('2','2002',7),
	('1','2001',7),
	('X','1999',5),
	('W','1998',5),
	('V','1997',5),
	('T','1996',5),
	('S','1995',5),
	('R','1994',5),
	('P','1993',5),
	('N','1992',5),
	('M','1991',5),
	('L','1990',5),
	('K','1989',5),
	('J','1988',5),
	('H','1987',5),
	('G','1986',5),
	('F','2015',5),
	('E','2014',5),
	('D','2013',5),
	('C','2012',5),
	('B','2011',5),
	('A','2010',5),
	('9','2009',5),
	('8','2008',5),
	('7','2007',5),
	('6','2006',5),
	('5','2005',5),
	('4','2004',5),
	('3','2003',5),
	('2','2002',5),
	('1','2001',5),
	('1','2001',8),
	('2','2002',8),
	('3','2003',8),
	('4','2004',8),
	('5','2005',8),
	('6','2006',8),
	('7','2007',8),
	('8','2008',8),
	('9','2009',8),
	('A','2010',8),
	('B','2011',8),
	('C','2012',8),
	('D','2013',8),
	('E','2014',8),
	('F','2015',8),
	('G','1986',8),
	('H','1987',8),
	('J','1988',8),
	('K','1989',8),
	('L','1990',8),
	('M','1991',8),
	('N','1992',8),
	('P','1993',8),
	('R','1994',8),
	('S','1995',8),
	('T','1996',8),
	('V','1997',8),
	('W','1998',8),
	('X','1999',8),
	('Y','2000',8),
	('T','1996',2),
	('S','1995',2),
	('R','1994',2),
	('P','1993',2),
	('N','1992',2),
	('M','1991',2),
	('L','1990',2),
	('K','1989',2),
	('J','1988',2),
	('H','1987',2),
	('G','1986',2),
	('F','2015',2),
	('E','2014',2),
	('D','2013',2),
	('C','2012',2),
	('B','2011',2),
	('A','2010',2),
	('9','2009',2),
	('8','2008',2),
	('7','2007',2),
	('6','2006',2),
	('5','2005',2),
	('4','2004',2),
	('3','2003',2),
	('2','2002',2),
	('1','2001',2),
	('Y','2000',25),
	('X','1999',25),
	('W','1998',25),
	('V','1997',25),
	('T','1996',25),
	('F','2015',25),
	('E','2014',25),
	('D','2013',25),
	('C','2012',25),
	('B','2011',25),
	('A','2010',25),
	('9','2009',25),
	('8','2008',25),
	('7','2007',25),
	('6','2006',25),
	('5','2005',25),
	('4','2004',25),
	('3','2003',25),
	('2','2002',25),
	('1','2001',25),
	('Y','2000',26),
	('X','1999',26),
	('W','1998',26),
	('V','1997',26),
	('T','1996',26),
	('S','1995',26),
	('R','1994',26),
	('P','1993',26),
	('N','1992',26),
	('M','1991',26),
	('L','1990',26),
	('K','1989',26),
	('J','1988',26),
	('H','1987',26),
	('G','1986',26),
	('F','2015',26),
	('E','2014',26),
	('D','2013',26),
	('C','2012',26),
	('B','2011',26),
	('A','2010',26),
	('9','2009',26),
	('8','2008',26),
	('7','2007',26),
	('6','2006',26),
	('5','2005',26),
	('4','2004',26),
	('3','2003',26),
	('2','2002',26),
	('1','2001',26);

CREATE TABLE `RV_vin11` (
  `digit` varchar(1) NOT NULL DEFAULT '',
  `decode_value` varchar(100) NOT NULL DEFAULT '',
  `vin23` int(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin11` (`digit`, `decode_value`, `vin23`)
VALUES
	('G','52277 DR 19, Elkhart, IN',25),
	('F','914 CR 1, Elkhart, IN',25),
	('F','914 CR 1, Elkhart, IN',1),
	('G','52277 DR 19, Elkhart, IN',1),
	('1','Coburg, OH',3),
	('2','Elkhart, IN',3),
	('3','Wakarusa, IN',3),
	('V','57475 CR 3, Elkhart IN',25),
	('L','Ocala, FL',5),
	('K','Fair Haven, VT',5),
	('J','Bristol, IN',5),
	('E','Woodland, CA',5),
	('A','Hemet, CA',5),
	('7','621 Washington Street, South Twin Falls, Idaho 83301',26),
	('6','10758 CR 2, Middlebury, IN 46540',26),
	('3','Canada',26),
	('5','1005 SR 9 N., LaGrange, IN 46571',26),
	('2','Kansas',26),
	('1','903 S. Main St., Middlebury, IN 46540',26);

CREATE TABLE `RV_vin23` (
  `digit` varchar(2) NOT NULL DEFAULT '',
  `decode_value` int(4) NOT NULL,
  `vin23_id` int(4) unsigned NOT NULL AUTO_INCREMENT,
  `vin4_alt_field_id` int(4) NOT NULL DEFAULT '0',
  `vin5_alt_field_id` int(4) NOT NULL DEFAULT '0',
  `vin6_alt_field_id` int(4) NOT NULL DEFAULT '0',
  `vin7_alt_field_id` int(4) NOT NULL DEFAULT '0',
  `vin8_alt_field_id` int(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`vin23_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin23` (`digit`, `decode_value`, `vin23_id`, `vin4_alt_field_id`, `vin5_alt_field_id`, `vin6_alt_field_id`, `vin7_alt_field_id`, `vin8_alt_field_id`)
VALUES
	('1Z',35,3,64,75,60,118,91),
	('H9',1,7,64,60,118,118,91),
	('SE',52,5,60,0,0,118,91),
	('X4',25,25,60,64,64,118,91),
	('SF',1,2,64,60,118,118,91),
	('SV',52,1,60,0,0,118,91),
	('UJ',182,26,60,63,0,91,118),
	('F9',151,27,60,64,118,118,91),
	('NL',28,28,0,0,0,0,0),
	('H0',167,29,0,0,0,0,0),
	('YD',4,30,0,0,0,0,0),
	('EA',145,42,0,0,0,0,0),
	('ED',145,41,0,0,0,0,0),
	('UB',54,40,0,0,0,0,0),
	('EF',145,34,0,0,0,0,0),
	('KE',119,39,0,0,0,0,0),
	('7C',2,36,0,0,0,0,0),
	('CZ',468,38,0,0,0,0,0),
	('EB',145,43,0,0,0,0,0),
	('EC',145,44,0,0,0,0,0),
	('EH',145,45,0,0,0,0,0),
	('1V',47,46,0,0,0,0,0),
	('6F',9,47,0,0,0,0,0),
	('GR',62,48,0,0,0,0,0),
	('V0',3,49,0,0,0,0,0);

CREATE TABLE `RV_vin4` (
  `digit` varchar(2) NOT NULL DEFAULT '',
  `decode_value` varchar(100) NOT NULL DEFAULT '',
  `vin23` int(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin4` (`digit`, `decode_value`, `vin23`)
VALUES
	('9','10',1),
	('3','4',1),
	('P','10',2),
	('N','16',2),
	('P','10',7),
	('2','5',1),
	('5','F4F-Series',3),
	('3','RSR',3),
	('4','RR8R, RR8S, RR10R, or RR10S R-Series',3),
	('2','RR4R A/E-Series Stacked Rail',3),
	('1','S-Series Monocoque',3),
	('B','2',7),
	('9','10',5),
	('3','4',5),
	('2','5',5),
	('B','2',2),
	('S','18',2),
	('T','5',25),
	('F','4',25),
	('G','9',26),
	('C','4',26),
	('B','5',26),
	('A','8',26);

CREATE TABLE `RV_vin5` (
  `digit` varchar(2) NOT NULL DEFAULT '',
  `decode_value` varchar(100) NOT NULL DEFAULT '',
  `vin23` int(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin5` (`digit`, `decode_value`, `vin23`)
VALUES
	('A','15.2 Litre C15/6-Cylinder/Diesel',3),
	('8','14.0 Litre 60-Series/6-Cyl/Diesel',3),
	('9','8.8 Litre C9/6-Cylinder/Diesel/9.3 Litre C9/6-Cyl/EPA 07 Diesel',3),
	('7','15.0 Litre ISX/6-Cylinder/Diesel',3),
	('5','7.2 Litre C7/6-Cylinder/Diesel',3),
	('4','10.8 Litre ISM/6-Cylinder/Diesel',3),
	('3','8.8 Litre ISL/6-Cylinder/Diesel / 8.9 Litre ISL/6-Cyl/EPA 07 Diesel',3),
	('2','8.3 Litre ISC/6-Cylinder/Diesel',3),
	('1','5.9 Litre ISB/6-Cylinder/Diesel',3),
	('0','12.5 Litre C13/6-Cylinder/Diesel',3),
	('B','6.7 Litre ISB/6-Cyl/EPA 07 Diesel',3),
	('F','Fifth Wheel',8),
	('T','Travel Trailer',8),
	('G','4',7),
	('B','5',7),
	('G','4',2),
	('B','5',2),
	('WC','56',25),
	('CA','57',25),
	('J','Jayco',26);

CREATE TABLE `RV_vin6` (
  `digit` varchar(1) NOT NULL DEFAULT '',
  `decode_value` varchar(100) NOT NULL DEFAULT '',
  `vin23` int(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin6` (`digit`, `decode_value`, `vin23`)
VALUES
	('9','Bus/26,001 to 33,000 (class 7)',3),
	('8','Bus/19,501 to 26,000 (class 6)',3),
	('7','Bus/10,001 to 19,500 (classes 3-6)',3),
	('5','Motorhome/33,001 and over (class 8)',3),
	('6','Bus/10,000 and under (classes A-H)',3),
	('4','Motorhome/26,001 to 33,000 (class 7)',3),
	('3','Motorhome/19,501 to 26,000 (class 6)',3),
	('2','Motorhome/10,001 to 19,500 (classes 3-6)',3),
	('1','Motorhome/10,000 and under (classes A-H)',3),
	('A','Bus/33,001 and over (class 8)',3);

CREATE TABLE `RV_vin7` (
  `digit` varchar(1) NOT NULL DEFAULT '',
  `decode_value` varchar(100) NOT NULL DEFAULT '',
  `vin23` int(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin7` (`digit`, `decode_value`, `vin23`)
VALUES
	('A','24\'',25),
	('F','14\' - 15\'',5),
	('E','12\' - 13\'',5),
	('D','10\' - 11\'',5),
	('C','8\' - 9\'',5),
	('6','36\' 7\"',7),
	('8','301\" to 330\"',3),
	('7','281\" to 300\"',3),
	('6','251\" to 280\"',3),
	('5','231\" to 250\"',3),
	('4','216\" to 230\"',3),
	('3','201\" to 215\"',3),
	('2','151\" to 200\"',3),
	('1','100\" to 150\"',3),
	('B','6\' - 7\'',5),
	('B','26\'',25),
	('C','27\'',25),
	('D','28\'',25),
	('E','29\'',25),
	('F','30\'',25),
	('9','No Axles',26),
	('3','3 Axles',26),
	('2','2 Axles',26),
	('1','1 Axle',26);

CREATE TABLE `RV_vin8` (
  `digit` varchar(1) NOT NULL DEFAULT '',
  `decode_value` varchar(100) NOT NULL DEFAULT '',
  `vin23` int(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `RV_vin8` (`digit`, `decode_value`, `vin23`)
VALUES
	('0','None',0),
	('1','1 Axle',0),
	('2','2 Axles',0),
	('3','3 Axles',0),
	('4','4 Axles',0),
	('5','5 Axles',0),
	('4','4 Axles',1),
	('3','3 Axles',1),
	('2','2 Axles',1),
	('1','1 Axle',1),
	('0','None',1),
	('2','Single - Tandem/Air over Hydraulic',3),
	('1','Single - Tandem/Air',3),
	('3','Single - Tandem/Hydraulic',3),
	('4','Single - Single/Air',3),
	('5','Single - Single/Air over Hydraulic',3),
	('6','Single - Single/Hydraulic',3),
	('5','5 Axles',7),
	('4','4 Axles',7),
	('3','3 Axles',7),
	('2','2 Axles',7),
	('1','1 Axle',7),
	('0','None',7),
	('3','3 Axles',25),
	('4','4 Axles',5),
	('3','3 Axles',5),
	('2','2 Axles',5),
	('1','1 Axle',5),
	('0','None',5),
	('0','None',8),
	('1','1 Axle',8),
	('2','2 Axles',8),
	('3','3 Axles',8),
	('4','4 Axles',8),
	('5','5 Axles',8),
	('2','2 Axles',25),
	('1','1 Axle',25),
	('0','None',25),
	('1','1 Axle',2),
	('0','None',2),
	('M','26 ft. to less than 28 ft.',26),
	('L','24 ft. to less than 26 ft.',26),
	('K','22 ft. to less than 24 ft.',26),
	('J','20 ft. to less than 22 ft.',26),
	('H','18 ft. to less than 20 ft.',26),
	('G','16 ft. to less than 18 ft.',26),
	('F','14 ft. to less than 16 ft.',26),
	('E','12 ft. to less than 14 ft.',26),
	('D','10 ft. to less than 12 ft.',26),
	('C','8 ft. to less than 10 ft.',26),
	('B','6ft. to less than 8 ft.',26),
	('A','Less than 6 ft.',26),
	('N','28 ft. to less than 30 ft.',26),
	('P','30 ft. to less than 32 ft.',26),
	('R','32 ft. and greater',26);
