
function check_login(login_status, customer_status)
{
	if (login_flag == 0)
	{
	    if (login_status == 1)
	    {
    	    window.location = inc_level + "home.asp";
    	}
    	else if (login_status == 0 || login_status == -1)
    	{
	        /* - moved this script to my.js to make use of jQuery
			document.getElementById("login_id").style.display = "inline";
	        document.getElementById("logout_id").style.display = "none";
	        document.getElementById("webreports_id").style.display = "none";
			document.getElementById("salesatlas_id").style.display = "none";
	        document.getElementById("updateaccount_id").style.display = "none";
			*/
    	}
	}
	else
	{
	    if (login_status == -1)
	    {
    	    window.location = inc_level + "home.asp";
    	}
    	else if (login_status == 0 || login_status == 1)
    	{
	        /* - moved this script to my.js to make use of jQuery
			document.getElementById("login_id").style.display = "none";
	        document.getElementById("logout_id").style.display = "inline";
	        document.getElementById("webreports_id").style.display = "inline";
	        document.getElementById("salesatlas_id").style.display = "inline";
	        document.getElementById("updateaccount_id").style.display = "inline";
			*/
	    }
	}
}

function login_click()
{
    document.getElementById("login_form").action = "home.asp?f=login";
    document.getElementById("login_form").submit();
}

function logout_click()
{
    window.location = inc_level + "home.asp?f=logout";
}

function enable_register()
{
    if (document.getElementById("termsAgreement").checked == false)
        document.getElementById("btnCustomerInfo").disabled = true;
    else
        document.getElementById("btnCustomerInfo").disabled = false;
}

function newaccount_click()
{
    if (CheckElements() == 0)
    {
        document.getElementById("customerInfo_form").action = "home.asp?f=newaccount";
        document.getElementById("customerInfo_form").submit();
    }
}

function updateaccount_click()
{
    if (CheckElements() == 0)
    {
        document.getElementById("customerInfo_form").action = "home.asp?f=updateaccount";
        document.getElementById("customerInfo_form").submit();
    }
}

function requestpresentation_click()
{
    if (CheckElements() == 0)
    {
        document.getElementById("customerInfo_form").action = "home.asp?f=requestpresentation";
        document.getElementById("customerInfo_form").submit();
    }
}

function contactus_click()
{
    if (CheckElements() == 0)
    {
        document.getElementById("customerInfo_form").action = "home.asp?f=contactus";
        document.getElementById("customerInfo_form").submit();
    }
}

function CheckElements()
{
    var EmptyFields
    EmptyFields = 0

    //if (GetElementLength("firstName") == 0)
    //    EmptyFields = 1;
    //else if (GetElementLength("lastName") == 0)
    //    EmptyFields = 1;
    //else if (GetElementLength("companyName") == 0)
    //{
    //    if (customer_type == 1)
    //        EmptyFields = 1;
    //}
    
    bus_phone_1 = GetElementValue("bus_phone1", 1)
    bus_phone_2 = GetElementValue("bus_phone2", 1)
    bus_phone_3 = GetElementValue("bus_phone3", 1)
    if(bus_phone_1.length != 3 || bus_phone_2.length != 3 || bus_phone_3.length != 4 || isNaN(bus_phone_1) || isNaN(bus_phone_2) || isNaN(bus_phone_3))
    {
        SetElementValue("bus_phone1", "");
        SetElementValue("bus_phone2", "");
        SetElementValue("bus_phone3", "");
    //    EmptyFields = 1;
    }

    cell_phone_1 = GetElementValue("cell_phone1", 1)
    cell_phone_2 = GetElementValue("cell_phone2", 1)
    cell_phone_3 = GetElementValue("cell_phone3", 1)
    if(cell_phone_1.length != 3 || cell_phone_2.length != 3 || cell_phone_3.length != 4 || isNaN(cell_phone_1) || isNaN(cell_phone_2) || isNaN(cell_phone_3))
    {
        SetElementValue("cell_phone1", "");
        SetElementValue("cell_phone2", "");
        SetElementValue("cell_phone3", "");
        //EmptyFields = 1;
    }

    emailStr = GetElementValue("email", 1);
    SetElementValue("email", emailStr);
    
    if (emailStr.length == 0)
        EmptyFields = 1;

    if (EmptyFields == 1)
    {
        if (document.getElementById("requiredFields") != null)
            document.getElementById("requiredFields").style.display = "block";
    }
    return EmptyFields
}

function GetElementValue(ElementName, RemoveSpaces)
{
    var ElementValue;
    ElementValue = ""

    if (document.getElementById(ElementName) != null)
    {
        ElementValue = document.getElementById(ElementName).value;
        if (RemoveSpaces == 1) ElementValue = ElementValue.replace(/ /g, "");
    }

    return ElementValue;
}

function SetElementValue(ElementName, ElementValue)
{
    var ElementExists;
    ElementExists = 0;
    
    if (document.getElementById(ElementName) != null)
    {
        document.getElementById(ElementName).value = ElementValue;
        ElementExists = 1;
    }

    return ElementExists;
}

function GetElementLength(ElementName)
{
    var CheckElement;
    CheckElement = -1;

    if (document.getElementById(ElementName) != null)
    {
        ElementValue = document.getElementById(ElementName).value;
        ElementValue = ElementValue.replace(/ /g, "");
        CheckElement = ElementValue.length;
    }

    return CheckElement;
}

