document.addEventListener("DOMContentLoaded", function () { // --- 1. THE DATA STRUCTURE --- // We store Heading, Text, and SVG for every state here. const stateData = { IDAHO: { description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Idaho with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", name: "Idaho", svg: ``, }, ALASKA: { description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Alaska with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", name: "Alaska", svg: ` `, }, HAWAII: { description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Hawaiʻi.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", name: "Hawaii", svg: ` `, }, "NEW MEXICO": { description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in New Mexico.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", name: "New Mexico", svg: ``, }, COLORADO: { name: "Colorado", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Colorado. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, WYOMING: { name: "Wyoming", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Wyoming with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, FLORIDA: { name: "Florida", description: "SimpleK12 modules may be used for professional development purposes only. We are not able to determine if this type of coursework is acceptable in Florida or your district for license renewal. Please reach out to your state or district for more information.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, "WEST VIRGINIA": { name: "West Virginia", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in West Virginia.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, DELAWARE: { name: "Delaware", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Delaware with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, "NEW JERSEY": { name: "New Jersey", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in New Jersey with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, "RHODE ISLAND": { name: "Rhode Island", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Rhode Island with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, CONNECTICUT: { name: "Connecticut", description: "SimpleK12 modules may be used for professional development purposes only. We are not able to determine if this type of coursework is acceptable in Connecticut or your district for license renewal. Please reach out to your state or district for more information.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, MASSACHUSETTS: { name: "Massachusetts", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Massachusetts with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, MAINE: { name: "Maine", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Maine. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, "NEW HAMPSHIRE": { name: "New Hampshire", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in New Hampshire. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, VERMONT: { name: "Vermont", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Vermont. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, "NEW YORK": { name: "New York", description: "SimpleK12 is an approved Continuing Teacher and Leader Education (CTLE) sponsor in New York. SimpleK12 is a DBA of InfoSource. You will find InfoSource listed as the approved sponsor on the NYSED website.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, PENNSYLVANIA: { name: "Pennsylvania", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Pennsylvania with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, MARYLAND: { name: "Maryland", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Maryland with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, VIRGINIA: { name: "Virginia", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Virginia with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, "NORTH CAROLINA": { name: "North Carolina", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in North Carolina. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, "SOUTH CAROLINA": { name: "South Carolina", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in South Carolina with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, GEORGIA: { name: "Georgia", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Georgia.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, ALABAMA: { name: "Alabama", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Alabama.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, MISSISSIPPI: { name: "Mississippi", description: "SimpleK12 modules may be used for professional development purposes only. We are not able to determine if this type of coursework is acceptable in Florida or your district for license renewal. Please reach out to your state or district for more information.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, LOUISIANA: { name: "Louisiana", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Louisiana.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, TEXAS: { name: "Texas", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Texas with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, OKLAHOMA: { name: "Oklahoma", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Oklahoma. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, KANSAS: { name: "Kansas", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Kansas. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, NEBRASKA: { name: "Nebraska", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Nebraska. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, "SOUTH DAKOTA": { name: "South Dakota", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in South Dakota. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, ARKANSAS: { name: "Arkansas", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Arkansas with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, MISSOURI: { name: "Missouri", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Missouri. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, IOWA: { name: "Iowa", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Iowa with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, TENNESSEE: { name: "Tennessee", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Tennessee. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, KENTUCKY: { name: "Kentucky", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Kentucky.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, OHIO: { name: "Ohio", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Ohio with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, INDIANA: { name: "Indiana", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Indiana. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, ILLINOIS: { name: "Illinois", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Illinois.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, MICHIGAN: { name: "Michigan", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Michigan.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, WISCONSIN: { name: "Wisconsin", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Wisconsin.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, MINNESOTA: { name: "Minnesota", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Minnesota. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, "NORTH DAKOTA": { name: "North Dakota", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in North Dakota.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, MONTANA: { name: "Montana", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Montana with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, ARIZONA: { name: "Arizona", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Arizona. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, UTAH: { name: "Utah", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Utah. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, NEVADA: { name: "Nevada", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Nevada with prior approval from the state or district.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Identify the courses, bundle, or micro-credential you'd like to enroll in and reach out to your state or district for approval prior to getting started.", svg: ``, }, CALIFORNIA: { name: "California", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in California.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, OREGON: { name: "Oregon", description: "SimpleK12 offers modules that may be accepted for teacher license renewal in Oregon. Acceptance is subject to state or district approval.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Enroll now in the courses, bundle, or micro-credential that align with your goals.", svg: ``, }, WASHINGTON: { name: "Washington", description: "SimpleK12 modules may be used for professional development purposes only and are not aligned with standard license renewal requirements in Washington.

Our courses present relevant, high-impact topics so you can bring fresh strategies into your classroom. Browse our catalog for topics that align with your personal growth goals.", svg: ``, }, }; const popupWrap = document.querySelector(".popup-wrap"); const popupTitle = document.getElementById("popup-state-name"); const popupDesc = document.getElementById("popup-state-desc"); const popupImg = document.getElementById("popup-state-img"); const closeBtn = document.getElementById("close-btn"); const searchInput = document.getElementById("state-search-input"); const searchResults = document.getElementById("state-search-results"); const mapTriggers = document.querySelectorAll(".map__state"); // --- 4. CORE FUNCTION: OPEN POPUP --- function openPopup(stateKey) { if (!stateKey) return; const currentData = stateData[stateKey]; const prettyName = currentData ? currentData.name : toTitleCase(stateKey); // A. Populate Title if (popupTitle) popupTitle.innerText = prettyName; // B. Populate Description (Updated Logic) if (popupDesc) { if (currentData && currentData.description) { // Use custom description if it exists (using innerHTML allows
tags) popupDesc.innerHTML = currentData.description; } else { // Fallback to default sentence popupDesc.innerText = defaultPara + " " + prettyName + "."; } } // C. Populate Image if (popupImg) { // Priority 1: Use SVG from Data Object if (currentData && currentData.svg && currentData.svg !== "") { popupImg.innerHTML = currentData.svg; } // Priority 2: Fallback to finding SVG inside the map link else { const mapLink = document.querySelector( `.map__state[state-name="${stateKey}"]` ); const embeddedSvg = mapLink ? mapLink.querySelector("svg") : null; if (embeddedSvg) { popupImg.innerHTML = ""; popupImg.appendChild(embeddedSvg.cloneNode(true)); } else { popupImg.innerHTML = ""; } } } // D. Show Popup if (popupWrap) { popupWrap.style.display = "flex"; } } // --- 5. MAP INTERACTION LOGIC --- mapTriggers.forEach((trigger) => { trigger.addEventListener("click", function (e) { e.preventDefault(); const stateKey = this.getAttribute("state-name"); openPopup(stateKey); }); }); // --- 6. SEARCH LOGIC --- if (searchInput && searchResults) { searchInput.addEventListener("input", function (e) { // 1. Get the value and convert to uppercase for case-insensitive matching const val = this.value.toUpperCase(); searchResults.innerHTML = ""; if (!val) { searchResults.style.display = "none"; return; } // 2. UPDATED FILTER LOGIC const matches = Object.keys(stateData).filter((key) => { // Get the full name of the state const stateName = stateData[key].name.toUpperCase(); // Use .startsWith() instead of .includes() // This ensures "A" finds "Arizona" but NOT "Kansas" return stateName.startsWith(val); }); if (matches.length > 0) { // (This part remains the same as your original code) searchResults.style.display = "block"; // Or 'flex' if you changed CSS matches.forEach((key) => { const div = document.createElement("div"); div.className = "state-search-item"; div.innerHTML = stateData[key].name; div.addEventListener("click", function () { openPopup(key); searchInput.value = ""; searchResults.style.display = "none"; }); searchResults.appendChild(div); }); } else { searchResults.style.display = "none"; } }); // (The rest of your click-away logic remains here) document.addEventListener("click", function (e) { if ( !searchInput.contains(e.target) && !searchResults.contains(e.target) ) { searchResults.style.display = "none"; } }); } // --- 7. CLOSE POPUP LOGIC --- if (popupWrap) { popupWrap.addEventListener("click", function (e) { if (e.target === this) { this.style.display = "none"; } }); } if (closeBtn) { closeBtn.addEventListener("click", function (e) { e.preventDefault(); if (popupWrap) { popupWrap.style.display = "none"; } }); } function toTitleCase(str) { return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } });