function checkDSLForm()
{
    var phoneArea      = document.forms[0].elements["phoneArea"].value;
    var phonePre       = document.forms[0].elements["phonePre"].value;
    var phoneLast      = document.forms[0].elements["phoneLast"].value;
    var address        = document.forms[0].elements["address"].value;
    var city           = document.forms[0].elements["city"].value;
    var zip            = document.forms[0].elements["zip"].value;
    var email          = document.forms[0].elements["email"].value;     

    var pre = "Please enter a valid ";
    var alphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    var nums   = "0123456789";

    if (phoneArea.length < 3 || !goodString(phoneArea,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[0].elements['phoneArea'].focus();
    }
    else if (phonePre.length < 3 || !goodString(phonePre,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[0].elements['phonePre'].focus();
    }
    else if (phoneLast.length < 4 || !goodString(phoneLast,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[0].elements['phoneLast'].focus();
    }
    else if (address.length < 2)
    {
        alert(pre + "Address.");
        document.forms[0].elements['address'].focus();
    }
    else if (city.length < 2)
    {
        alert(pre + "City.");
        document.forms[0].elements['city'].focus();
    }
    else if (document.forms[0].elements['stateID'].selectedIndex == 0)
    {
        alert("Please select a valid State.");
        document.forms[0].elements['stateID'].focus();
    }
    else if (zip.length < 5 || !goodString(zip, nums + ".- "))
    {
        alert(pre + "Zip Code.");
        document.forms[0].elements['zip'].focus();
    }
    else if ((email.length < 2) || ((email.indexOf('@') == -1) || (email.substr(email.indexOf('@') + 1).indexOf('.') == -1))) 
    {
        alert(pre + "Email.");
        document.forms[0].elements['email'].focus();
    }   
    else {
        openThankYouWindow('dslForm');	
    }
}

function checkT1Form()
{
    var phoneArea      = document.forms[0].elements["phoneArea"].value;
    var phonePre       = document.forms[0].elements["phonePre"].value;
    var phoneLast      = document.forms[0].elements["phoneLast"].value;
    var address        = document.forms[0].elements["address"].value;
    var city           = document.forms[0].elements["city"].value;
    var zip            = document.forms[0].elements["zip"].value;
    var email          = document.forms[0].elements["email"].value;     
    
    var pre = "Please enter a valid ";
    var alphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    var nums   = "0123456789";

    if (phoneArea.length < 3 || !goodString(phoneArea,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[0].elements['phoneArea'].focus();
    }
    else if (phonePre.length < 3 || !goodString(phonePre,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[0].elements['phonePre'].focus();
    }
    else if (phoneLast.length < 4 || !goodString(phoneLast,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[0].elements['phoneLast'].focus();
    }
    else if (address.length < 2)
    {
        alert(pre + "Address.");
        document.forms[0].elements['address'].focus();
    }
    else if (city.length < 2)
    {
        alert(pre + "City.");
        document.forms[0].elements['city'].focus();
    }
    else if (document.forms[0].elements['stateID'].selectedIndex == 0)
    {
        alert("Please select a valid State.");
        document.forms[0].elements['stateID'].focus();
    }
    else if (zip.length < 5 || !goodString(zip, nums + ".- "))
    {
        alert(pre + "Zip Code.");
        document.forms[0].elements['zip'].focus();
    }
    else if ((email.length < 2) || ((email.indexOf('@') == -1) || (email.substr(email.indexOf('@') + 1).indexOf('.') == -1))) 
    {
        alert(pre + "Email.");
        document.forms[0].elements['email'].focus();
    }       
    else {
	openThankYouWindow('T1Form');
    }
}

function checkDS3T1Form()
{
    var phoneArea2      = document.forms[1].elements["phoneArea2"].value;
    var phonePre2       = document.forms[1].elements["phonePre2"].value;
    var phoneLast2      = document.forms[1].elements["phoneLast2"].value;
    var address2        = document.forms[1].elements["address2"].value;
    var city2           = document.forms[1].elements["city2"].value;
    var zip2            = document.forms[1].elements["zip2"].value;
    var email2          = document.forms[1].elements["email2"].value; 

    var name2          = document.forms[1].elements["name2"].value;
    var contactPhone   = document.forms[1].elements["contactPhone"].value;    

    var pre = "Please enter a valid ";
    var alphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    var nums   = "0123456789";

    if (phoneArea2.length < 3 || !goodString(phoneArea2,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[1].elements['phoneArea2'].focus();
    }
    else if (phonePre2.length < 3 || !goodString(phonePre2,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[1].elements['phonePre2'].focus();
    }
    else if (phoneLast2.length < 4 || !goodString(phoneLast2,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[1].elements['phoneLast2'].focus();
    }
    else if (address2.length < 2)
    {
        alert(pre + "Address.");
        document.forms[1].elements['address2'].focus();
    }
    else if (city2.length < 2)
    {
        alert(pre + "City.");
        document.forms[1].elements['city2'].focus();
    }
    else if (document.forms[1].elements['stateID2'].selectedIndex == 0)
    {
        alert("Please select a valid State.");
        document.forms[1].elements['stateID2'].focus();
    }
    else if (zip2.length < 5 || !goodString(zip2, nums + ".- "))
    {
        alert(pre + "Zip Code.");
        document.forms[1].elements['zip2'].focus();
    }
    else if ((email2.length < 2) || ((email2.indexOf('@') == -1) || (email2.substr(email2.indexOf('@') + 1).indexOf('.') == -1))) 
    {
        alert(pre + "Email.");
        document.forms[1].elements['email2'].focus();
    }
    else if (name2.length < 2 || !goodString(name2, alphas + "- "))
    {
        alert(pre + "First and Last Name.");
        document.forms[1].elements['name2'].focus();
    }
    else if (contactPhone.length < 7 || !goodString(contactPhone,nums + "/\-() "))
    {
        alert(pre + "Phone Number.");
        document.forms[1].elements['contactPhone'].focus();
    }   
    else
    {
        openThankYouWindow('DS3Form');
    }
}

function openThankYouWindow(qualType) {

 window.open('connect-thanks.jsp','OrderDetail','width=730, height=160, scrollbars=yes');
        document.forms[qualType].submit();

}

function goodString(OurString,goodChars) {
    for(x=0;x<OurString.length;x++) {
        if(goodChars.indexOf(OurString.charAt(x),0) == -1)
            return false;
        }

    return true;
}
