package com.afi.autoquote.model.parsers
{
    import com.afi.autoquote.model.TextModel;
    import com.afi.autoquote.views.vo.text.*;
    
    // Parses copydeck.xml into a TextModel
    public class CopyDeckParser
    {
        private static var model:TextModel;
        
        public static function parse(xml:XML, model:TextModel):void {
            CopyDeckParser.model = model;
            
            var sections:XMLList            = xml.section;
            var intro:XMLList               = sections.(@name == "Intro");
            var userInfo:XMLList            = sections.(@name == "UserInformation");
            var addSelectVehicles:XMLList   = sections.(@name == "AddSelectVehicles");
            var vehicleInfo:XMLList         = sections.(@name == "VehicleInformation");
            var addSelectDrivers:XMLList    = sections.(@name == "AddSelectDrivers");
            var driverInfo:XMLList          = sections.(@name == "DriverInformation");
            var discounts:XMLList           = sections.(@name == "Discounts");
            var contactInfo:XMLList         = sections.(@name == "ContactInfo");
            var chooseCoverage:XMLList      = sections.(@name == "ChooseCoverage");
            var compareCoverage:XMLList     = sections.(@name == "CompareCoverage");
            var driverEmployment:XMLList    = sections.(@name == "DriverEmployment");
            var addTitleholders:XMLList     = sections.(@name == "AddTitleHolders");
            var help:XMLList                = sections.(@name == "Help");
            
            parseIntro(intro);
            parseUserInfo(userInfo);
            parseAddSelectVehicles(addSelectVehicles);
            parseVehicleInfo(vehicleInfo);
            parseAddSelectDrivers(addSelectDrivers);
            parseDriverInfo(driverInfo);
            parseDiscounts(discounts);
            parseContactInfo(contactInfo);
            parseChooseCoverage(chooseCoverage);
            parseCompareCoverage(compareCoverage);
            parseDriverEmployment(driverEmployment);
            parseAddTitleholders(addTitleholders);
            parseHelp(help);
        }
        
        private static function parseIntro(xml:XMLList):void {
            var vo:IntroTextVO = model.intro;
                vo.title = xml.title;
                vo.intro = xml.intro;
                vo.advanceBtnLbl = xml.advanceBtnLbl;
        }
        
        private static function parseUserInfo(xml:XMLList):void {
            var vo:UserInformationTextVO = model.userInfoText;
                vo.title = xml.title;
                vo.firstName = xml.firstName;
                vo.lastName = xml.lastName;
                vo.address = xml.address;
                vo.city = xml.city;
                vo.state = xml.state;
                vo.dateOfBirth = xml.dateOfBirth;
                vo.middleInitial = xml.middleInitial;
                vo.zipCode = xml.zipCode;
        }
        
        private static function parseAddSelectVehicles(xml:XMLList):void {
            var vo:AddSelectVehiclesTextVO = model.addSelectVehiclesText;
                vo.title = xml.title;
                vo.formHeaderTitle = xml.formHeaderTitle;
                vo.addVehicleBtnLbl = xml.addVehicleBtnLbl;
                vo.addVehicleModalTitle = xml.addVehicleModalTitle;
                vo.addVehicleModalEnterVIN = xml.addVehicleModalEnterVIN;
                vo.addVehicleModalVINFieldLbl = xml.addVehicleModalVINFieldLbl;
                vo.addVehicleModalAddBtnLbl = xml.addVehicleModalAddBtnLbl;
        }
        
        private static function parseVehicleInfo(xml:XMLList):void {
            var vo:VehicleInformationTextVO = model.vehicleInfoText;
                vo.annualMileage = xml.annualMileage;
                vo.keptAtHome = xml.keptAtHome;
                vo.editAddressBtnLbl = xml.editAddressBtnLbl;
                vo.ownershipStatus = xml.ownershipStatus;
                vo.hasLienholder = xml.hasLienholder;
                vo.isCustomized = xml.isCustomized;
        }
        
        private static function parseAddSelectDrivers(xml:XMLList):void {
            var vo:AddSelectDriversTextVO = model.addSelectDriversText;
                vo.title = xml.title;
                vo.formHeaderTitle = xml.formHeaderTitle;
                vo.editDriversBtnLbl = xml.editDriversBtnLbl;
                vo.editNonDriversBtnLbl = xml.editNonDriversBtnLbl;
                vo.felonyConviction = xml.felonyConviction;
                vo.driversListTitle = xml.driversListTitle;
                vo.nonDriversListTitle = xml.nonDriversListTitle;
                vo.drivingAgeOrOlder = xml.drivingAgeOrOlder;
        }
        
        private static function parseDriverInfo(xml:XMLList):void {
            var vo:DriverInformationTextVO = model.driverInformationText;
                vo.driver = xml.driver;
                vo.licenseState = xml.licenseState;
                vo.licenseNumber = xml.licenseNumber;
                vo.licenseDate = xml.licenseDate;
                vo.experience = xml.experience;
                vo.past5Years = xml.pastFiveYears;
                vo.accidentClaimOrLoss = xml.accidentClaimOrLoss;
                vo.trafficViolationOrTicket = xml.trafficViolationorTicket;
                vo.otherConviction = xml.otherConviction;
                vo.sr22 = xml.sr22;
        }
        
        private static function parseDiscounts(xml:XMLList):void {
            var vo:DiscountTextVO = model.discountText;
                vo.title = xml.title;
                vo.formHeaderTitle = xml.formHeaderTitle;
                vo.multipleVehicle = xml.multipleVehicle;
                vo.goodDriver = xml.goodDriver;
                vo.goodStudent = xml.goodStudent;
                vo.airBag = xml.airBag;
                vo.additionalDiscounts = xml.additionalDiscounts;
        }
        
        private static function parseContactInfo(xml:XMLList):void {
            var vo:ContactInfoTextVO = model.contactInfoText;
                vo.title = xml.title;
                vo.formHeaderTitle = xml.formHeaderTitle;
                vo.emailAddress = xml.emailAddress;
                vo.otherContactInfo = xml.otherContactInfo;
                vo.verifyAddress = xml.verifyAddress;
                vo.editEmail = xml.editEmail;
        }
        
        private static function parseChooseCoverage(xml:XMLList):void {
            var vo:ChooseCoverageTextVO = model.chooseCoverageText;
                vo.title = xml.title;
                vo.customizeBtnLbl = xml.customizeBtnLbl;
                vo.compareBtnLbl = xml.compareBtnLbl;
                vo.gridHeaderCoverage = xml.gridHeaderCoverage;
                vo.gridHeaderLimits = xml.gridHeaderLimits;
                vo.gridHeaderPremium = xml.gridHeaderPremium;
                vo.applyOnlineBtnLbl = xml.applyOnlineBtnLbl;
                vo.perMonth = xml.perMonth;
                vo.selectYourVehicles = xml.selectYourVehicles;
                vo.basic = xml.basic;
                vo.bodilyInjuryLiability = xml.bodilyInjuryLiability;
        }
        
        private static function parseCompareCoverage(xml:XMLList):void {
            var vo:CompareCoverageTextVO = model.compareCoverageText;
                vo.title = xml.title;
        }
        
        private static function parseDriverEmployment(xml:XMLList):void {
            var vo:DriverEmploymentTextVO = model.driverEmploymentText;
                vo.title = xml.title;
                vo.formHeaderTitle = xml.formHeaderTitle;
                vo.driver = xml.driver;
                vo.nonDriver = xml.nonDriver;
                vo.employmentStatus = xml.employmentStatus;
                vo.childrenUnder16 = xml.childrenUnderSixteen;
        }
        
        private static function parseAddTitleholders(xml:XMLList):void {
            var vo:AddTitleholdersTextVO = model.addTitleholdersText;
                vo.title = xml.title;
                vo.formHeaderTitle = xml.formHeaderTitle;
                vo.unrepairedDamage = xml.unrepairedDamage;
                vo.selectUnrepaired = xml.selectUnrepaired;
        }
        
        private static function parseHelp(xml:XMLList):void {
            HelpTextVO.whyDoWeAsk = xml.whyDoWeAsk;
            HelpTextVO.whyDoWeAskTooltip = xml.whyDoWeAskTooltip;
            HelpTextVO.whatDoesCustomizedMean = xml.whatDoesCustomizedMean;
        }
    }
}