﻿function checkLoginForm()
{
    if (document.LogInForm.txtUsername.value == "")
    {
        alert("Please, enter your username.");
        document.LogInForm.txtUsername.focus();
        return false;
    }
    
    if (document.LogInForm.txtPassword.value == "")
    {
        alert("Please, enter your password.");
        document.LogInForm.txtPassword.value.focus();
        return false;
    }
    
    return true;
}

function checkRegFormStep1()
{
    var emailValidator = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    
    if (document.SignUpForm.txtUserName.value == "")
    {
        alert("Please, enter username.");
        document.SignUpForm.txtUserName.focus();
        return false;
    }
    
    if (document.SignUpForm.txtUserName.value.length < 3)
    {
        alert("Your username is too short. Your username should be more than 3 characters.");
        document.SignUpForm.txtUserName.focus();
        return false;
    }    
    
    if (document.SignUpForm.txtUserName.value.length > 20)
    {
        alert("Your username is too long. Your username should be less than 20 characters.");
        document.SignUpForm.txtUserName.focus();
        return false;
    }      
    
    if (document.SignUpForm.txtPassword.value == "")
    {
        alert("Please, enter password.");
        document.SignUpForm.txtPassword.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPassword.value.length < 8)
    {
        alert("Your password is too short. Your password should be more than 8 characters.");
        document.SignUpForm.txtPassword.focus();
        return false;
    }   
    
    if (document.SignUpForm.txtConfirmPassword.value == "")
    {
        alert("Please, enter confirm password.");
        document.SignUpForm.txtConfirmPassword.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPassword.value != document.SignUpForm.txtConfirmPassword.value)
    {
        alert("Your password and confirm password must be the same.");
        document.SignUpForm.txtConfirmPassword.value = "";
        document.SignUpForm.txtConfirmPassword.focus();
        return false;
    }
    
    if (document.SignUpForm.txtFirstName.value == "")
    {
        alert("Please, enter first name.");
        document.SignUpForm.txtFirstName.focus();
        return false;
    }
    
    if (document.SignUpForm.txtFirstName.value.length > 150)
    {
        alert("First name is too long. First name should be less than 150 characters.");
        document.SignUpForm.txtFirstName.focus();
        return false;
    }
    
    if (document.SignUpForm.txtLastName.value == "")
    {
        alert("Please, enter last name.");
        document.SignUpForm.txtLastName.focus();
        return false;
    }
    
    if (document.SignUpForm.txtLastName.value.length > 150)
    {
        alert("Last name is too long. Last name should be less than 150 characters.");
        document.SignUpForm.txtLastName.focus();
        return false;
    }

    if (document.SignUpForm.txtEmail.value == "")
    {
        alert("Please, enter your contact e-mail address.");
        document.SignUpForm.txtEmail.focus();
        return false;
    }
    
    if (document.SignUpForm.txtEmail.value.length > 50)
    {
        alert("Your e-mail address is too long. Your e-mail address should be less than 50 characters.");
        document.SignUpForm.txtEmail.focus();
        return false;
    }    
    
    if (emailValidator.test(document.SignUpForm.txtEmail.value) == false) 
    {
	    alert("Please, enter valid e-mail address.");
	    document.SignUpForm.txtEmail.focus();
	    return false;
    }

    return true;
}

function checkRegFormStep2()
{
    var emailValidator = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
     
    if (document.SignUpForm.txtCompName.value == "")
    {
        alert("Please, enter business name.");
        document.SignUpForm.txtCompName.focus();
        return false;
    }
    
    if (document.SignUpForm.txtCompName.value.length > 50)
    {
        alert("Your business name is too long. Your business name should be less than 50 characters.");
        document.SignUpForm.txtCompName.focus();
        return false;
    }
    
    if (document.SignUpForm.lstSite.value == "0" || document.SignUpForm.lstSite.value.length == 0)
    {
        alert("Please, select a site.");
        document.SignUpForm.lstSite.focus();
        return false;
    }
    
    if (document.SignUpForm.lstCategory.value == "0" || document.SignUpForm.lstCategory.value.length == 0)
    {
        alert("Please, select a category.");
        document.SignUpForm.lstCategory.focus();
        return false;
    }
    
    if (document.SignUpForm.txtAddr1.value == "")
    {
        alert("Please, enter street address.");
        document.SignUpForm.txtAddr1.focus();
        return false;
    }
    
    if (document.SignUpForm.txtAddr1.value.length > 100)
    {
        alert("Your street address 1 is too long. Your street address 1 should be less than 100 characters.");
        document.SignUpForm.txtAddr1.focus();
        return false;
    }
    
    if (document.SignUpForm.txtAddr2.value.length > 100)
    {
        alert("Your street address 2 is too long. Your street address 2 should be less than 100 characters.");
        document.SignUpForm.txtAddr2.focus();
        return false;
    }       
    
    if (document.SignUpForm.txtCity.value == "")
    {
        alert("Please, enter city name.");
        document.SignUpForm.txtCity.focus();
        return false;
    }  
    
    if (document.SignUpForm.txtCity.value.length > 50)
    {
        alert("Your city name is too long. Your city name should be less than 50 characters.");
        document.SignUpForm.txtCity.focus();
        return false;
    }
    
    if (document.SignUpForm.txtStateRegionProvince.value.length > 100)
    {
        alert("State/Region/Province is too long. State/Region/Province should be less than 100 characters.");
        document.SignUpForm.txtStateRegionProvince.focus();
        return false;
    }
    
    if (document.SignUpForm.lstCountry.value == "0" || document.SignUpForm.lstCountry.value.length == 0)
    {
        alert("Please, select a country.");
        document.SignUpForm.lstCountry.focus();
        return false;
    }
    
    if (document.SignUpForm.txtZipPostal.value.length > 10)
    {
        alert("Zip/Postal Code is too long. Zip/Postal Code should be less than 10 characters.");
        document.SignUpForm.txtZipPostal.focus();
        return false;
    }
    
    if (document.SignUpForm.txtHomePg.value.length > 100)
    {
        alert("Mobile Home Page is too long. Mobile Home Page should be less than 100 characters.");
        document.SignUpForm.txtHomePg.focus();
        return false;
    }
    
//    if (document.SignUpForm.txtCompanyEmail.value == "")
//    {
//        alert("Please, enter business e-mail address.");
//        document.SignUpForm.txtCompanyEmail.focus();
//        return false;
//    }    
//    
//    if (document.SignUpForm.txtCompanyEmail.value.length > 100)
//    {
//        alert("Business e-mail address is too long. Business e-mail address should be less than 100 characters.");
//        document.SignUpForm.txtCompanyEmail.focus();
//        return false;
//    }    
//    
//    if (emailValidator.test(document.SignUpForm.txtCompanyEmail.value) == false) 
//    {
//	    alert("Please, enter valid business e-mail address.");
//	    document.SignUpForm.txtCompanyEmail.focus();
//	    return false;
//    }
    
    if (document.SignUpForm.txtPhoneNum.value == "")
    {
        alert("Please, enter phone number.");
        document.SignUpForm.txtPhoneNum.focus();
        return false;
    } 
    
    if (document.SignUpForm.txtPhoneNum.value.length > 20)
    {
        alert("Phone number is too long. Phone number should be less than 20 characters.");
        document.SignUpForm.txtPhoneNum.focus();
        return false;
    }
    
    if (document.SignUpForm.txtFaxNum.value.length > 20)
    {
        alert("Fax number is too long. Fax number should be less than 20 characters.");
        document.SignUpForm.txtFaxNum.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPic1Desc.value.length > 500)
    {
        alert("Picture #1 description is too long. Picture #1 description should be less than 500 characters.");
        document.SignUpForm.txtPic1Desc.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPic2Desc.value.length > 500)
    {
        alert("Picture #2 description is too long. Picture #2 description should be less than 500 characters.");
        document.SignUpForm.txtPic2Desc.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPic3Desc.value.length > 500)
    {
        alert("Picture #3 description is too long. Picture #3 description should be less than 500 characters.");
        document.SignUpForm.txtPic3Desc.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPic4Desc.value.length > 500)
    {
        alert("Picture #4 description is too long. Picture #4 description should be less than 500 characters.");
        document.SignUpForm.txtPic4Desc.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPic5Desc.value.length > 500)
    {
        alert("Picture #5 description is too long. Picture #5 description should be less than 500 characters.");
        document.SignUpForm.txtPic5Desc.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPic6Desc.value.length > 500)
    {
        alert("Picture #6 description is too long. Picture #6 description should be less than 500 characters.");
        document.SignUpForm.txtPic6Desc.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPic7Desc.value.length > 500)
    {
        alert("Picture #7 description is too long. Picture #7 description should be less than 500 characters.");
        document.SignUpForm.txtPic7Desc.focus();
        return false;
    }
    
    if (document.SignUpForm.txtDescription.value == "")
    {
        alert("Please, enter brief description.");
        document.SignUpForm.txtDescription.focus();
        return false;
    }
    
    if (document.SignUpForm.txtDescription.value.length > 500)
    {
        alert("Your description is too long. Your description should be less than 500 characters.");
        document.SignUpForm.txtDescription.focus();
        return false;
    }
    
    if (document.SignUpForm.txtPromo.value.length > 20)
    {
        alert("Promo is too long. Promo should be less than 20 characters.");
        document.SignUpForm.txtPromo.focus();
        return false;
    }
    
    if (document.SignUpForm.txtMisc1.value.length > 500)
    {
        alert("Misc1 is too long. Misc1 should be less than 500 characters.");
        document.SignUpForm.txtMisc1.focus();
        return false;
    }
    
    if (document.SignUpForm.txtMisc2.value.length > 500)
    {
        alert("Misc2 is too long. Misc2 should be less than 500 characters.");
        document.SignUpForm.txtMisc2.focus();
        return false;
    }
    
    return true;
}

function createWindow(cUrl,cName,cFeatures)	{
	var xWin = window.open(cUrl,cName,cFeatures)
}