function showForm(formId) {
    // Hide all forms
    const forms = document.querySelectorAll('.form');
    forms.forEach(form => form.classList.add('hidden'));
    
    // Show the selected form
    const selectedForm = document.getElementById(formId);
    selectedForm.classList.remove('hidden');
  }
  
  // By default, show the buyer form
  document.getElementById('buyer-form').classList.remove('hidden');
 
  // successfully registered and redirect to login page//
  
  // Get the seller signup form
const sellerSignupForm = document.querySelector('.signup-form');

// Handle seller registration
sellerSignupForm.addEventListener('submit', (event) => {
    event.preventDefault(); // Prevent form submission

    // Get form values
    const name = document.getElementById('seller-name').value.trim();
    const email = document.getElementById('seller-email').value.trim();
    const password = document.getElementById('seller-password').value;
    const businessName = document.getElementById('seller-business-name').value.trim();
    const contact = document.getElementById('seller-contact').value.trim();
    const address = document.getElementById('seller-address').value.trim();

    // Check if the email is already registered
    const users = JSON.parse(localStorage.getItem('users')) || {};
    if (users[email]) {
        alert('Email is already registered. Please use a different email.');
        return;
    }

    // Save seller details to localStorage
    users[email] = {
        name,
        password,
        businessName,
        contact,
        address,
        userType: 'Seller'
    };
    localStorage.setItem('users', JSON.stringify(users));

    // Redirect to the login page
    alert('Registration successful! Redirecting to the login page...');
    window.location.href = 'login.html'; // Redirect to the login page
});
