﻿var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
//change up the menu
switch (sPage) {
    case '':
        document.getElementById('home').style.color = "#4672aa";
        break;
    case 'index.php':
        document.getElementById('home').style.color = "#4672aa";
        break;
    case 'debt-help-company.php':
        document.getElementById('company').style.color = "#4672aa";
        break;
    case 'get-out-of-debt-results.php':
        document.getElementById('results').style.color = "#4672aa";
        break;
    case 'debt-removal-plan.php':
        document.getElementById('plan').style.color = "#4672aa";
        break;
    case 'get-out-of-debt-solution.php':
        document.getElementById('solution').style.color = "#4672aa";
        break;
    case 'contact-us-for-debt-solutions.php':
        document.getElementById('contact').style.color = "#4672aa";
        break;                                
    default:
}

//this sets the background image of the home page...
if (sPage == '' || sPage == 'index.php') {
    // Set up the image files to be used.
    var theImages = new Array() // do not change this
    // To add more image files, continue with the
    // pattern below, adding to the array.

    theImages[0] = 'images/cloud_bg.jpg'
    theImages[1] = 'images/cloud_bg2.jpg'
    theImages[2] = 'images/cloud_bg3.jpg'
    theImages[3] = 'images/cloud_bg4.jpg'

    // do not edit anything below this line

    var j = 0
    var p = theImages.length;
    var preBuffer = new Array()
    for (i = 0; i < p; i++) {
        preBuffer[i] = new Image()
        preBuffer[i].src = theImages[i]
    }
    var whichImage = Math.round(Math.random() * (p - 1));
    document.getElementById("top").style.backgroundImage = 'url(' + theImages[whichImage] + ')';
}
////////////////////////////////////////////////

//form verification//
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.firstname.value == "")
  {
    alert("Please enter a value for the First name field.");
    theForm.firstname.focus();
    return (false);
  }

  if (theForm.lastname.value == "")
  {
    alert("Please enter a value for the Last name field.");
    theForm.lastname.focus();
    return (false);
  }

  if (theForm.state.value == "")
  {
    alert("Please enter a value for the \"state\" field.");
    theForm.state.focus();
    return (false);
  }

  if (theForm.phone_areacode.value == "")
  {
    alert("Please enter a value for the \"phone_areacode\" field.");
    theForm.phone_areacode.focus();
    return (false);
  }

  if (theForm.phone_prefix.value == "")
  {
    alert("Please enter a value for the \"phone_prefix\" field.");
    theForm.phone_prefix.focus();
    return (false);
  }

  if (theForm.phone_prefix.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"phone_prefix\" field.");
    theForm.phone_prefix.focus();
    return (false);
  }


  if (theForm.phone_suffix.value == "")
  {
    alert("Please enter a value for the \"phone_suffix\" field.");
    theForm.phone_suffix.focus();
    return (false);
  }

  if (theForm.phone_suffix.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"phone_suffix\" field.");
    theForm.phone_suffix.focus();
    return (false);
  }

  return (true);
}
/////////////////////end form verification//////////////////////////////
