/**
 * This function will check the brief listing form to ensure all data is provided
 */
function check_brief_listings_form(form)
{
    // if the event type is not selected
	if (form.event_type.selectedIndex == 0)
	{
	    // alert, focus, and get out
		alert('Please choose an event type');
		form.event_type.focus();
		return false;
	}
	
	// if the event date is not set
	if (form.event_date.value == '')
	{
	    // alert, focus and get out
	    alert('Please set an event date');
	    form.event_date.focus();
	    return false;
	}
	
	// if the event name is not set
	if (form.name.value == '')
	{
	    // alert, focus and get out
	    alert('Please specify the name of the event');
	    form.name.focus();
	    return false;
	}
	
	// if the event leader is not set
	if (form.event_leader.value == '')
	{
	    // alert, focus and get out
	    alert('Please provide the name of the event leader');
	    form.event_leader.focus();
	    return false;
	}
	
	// if the event location is not set
	if (form.event_location.value == '')
	{
	    alert('Please provide the event location');
	    form.event_location.focus();
	    return false;
	}
	
	// if the company name is not set
	if (form.company_name.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your company name');
		form.company_name.focus();
		return false;
	}
	
	// if the contact name is not set
	if (form.contact_name.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your contact name');
		form.contact_name.focus();
		return false;
	}
	
	// if the contact title is not set
	if (form.contact_title.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your contact title');
		form.contact_title.focus();
		return false;
	}
	
	// if the address is not set
	if (form.address.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your address');
		form.address.focus();
		return false;
	}
	
	// if the city is not set
	if (form.city.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your city');
		form.city.focus();
		return false;
	}
	
	// if the state/province is not set
	if (form.state_province.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your state or province');
		form.state_province.focus();
		return false;
	}
	
	// if the zip code is not set
	if (form.zip_code.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your zip code');
		form.zip_code.focus();
		return false;
	}
	
	// if the country is not set
	if (form.country.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your country');
		form.country.focus();
		return false;
	}
	
	// if the phone number is not set
	if (form.phone_number.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your phone number');
		form.phone_number.focus();
		return false;
	}
	
	// if email is not set
	if (form.email.value == '')
	{
	    // alert, focus and get out
	    alert('Please provide your email address');
	    form.email.focus();
	    return false;
	}
	
	// if the event start date is not set
	if (form.start_date.value == '')
	{
	    // alert, focus and get out
	    alert('Please provide the event start date');
	    form.start_date.focus();
	    return false;
	}
	
	// if the end date is not set
	if (form.end_date.value == '')
	{
	    // alert, focus and get out
	    alert('Please provide the event stop date');
	    form.end_date.focus();
	    return false;
	}
}

function check_detailed_listing_form(form)
{
    // if the event date is not set
    if (form.event_date.value == '')
    {
        // alert, focus and get out
        alert('Please select an event date');
        form.event_date.focus();
        return false;
    }
    
    // if the end date is not set
    if (form.end_date.value == '')
    {
        // alert, focus and get out
        alert('Please provide the ending date of your event');
        form.end_date.focus();
        return false;
    }
    
    // if the event type is not set
    if (form.event_type.selectedIndex == 0)
	{
		alert('Please choose an event type');
		form.event_type.focus();
		return false;
	}
	
	// if the event period is not set
	if (form.event_period.selectedIndex == 0)
	{
	    // alert, focus and get out
	    alert('Please select an event frequency');
	    form.event_period.focus();
	    return false;
	}
	
	// if the industry is not set
	if (form.industry.value == '')
	{
	    // alert, focus and get our
		alert('Please provide the type of industry for your event');
		form.industry.focus();
		return false;
	}
	
	// if the primary address number is not set
	if (form.primary_location_street_number.value == '')
	{
	    // alert, focus and get out
		alert('Please provide the address number of the event location');
		form.primary_location_street_number.focus();
		return false;
	}
	
	// if the stret name is not set,
	if (form.primary_location_street_name.value == '')
	{
	    // alert focus and get out
		alert('Please provide the street name of the event location');
		form.primary_location_street_name.focus();
		return false;
	}
	
	// if the primary location city is not set
	if (form.primary_location_city.value == '')
	{
	    // alert focus and get out
		alert('Please provide the city of the event location');
		form.primary_location_city.focus();
		return false;
	}
	
	// if the primary state is not set
	if (form.primary_location_state.value == '')
	{
	    // alert, focus and get out
		alert('Please provide the state (or province) of the event location');
		form.primary_location_state.focus();
		return false;
	}
	
	// if the zip code is not set
	if (form.primary_location_zipcode.value == '')
	{
	    // alert, focus and get out
		alert('Please provide the zipcode of the event location');
		form.primary_location_zipcode.focus();
		return false;
	}
	
	// if the pricing range is not selected
	if (form.pricing_range.selectedIndex == 0)
	{
	    // alert, focus and get out
		alert('Please select the pricing range of your event');
		form.pricing_range.focus();
		return false;
	}
	
	// if the sponsor is not set
	if (form.event_sponsor.value == '')
	{
	    // alert, focus and get out
		alert('Please provide the event sponsor name');
		form.event_sponsor.focus();
		return false;
	}
	
	// if the event name is not set
	if (form.event_name.value == '')
	{   
	    // alert, focus and get out
		alert('Please specify the name of the event');
		form.event_name.focus();
		return false;
	}
	
	// if the event leader is not set
	if (form.primary_leader.value == '')
	{
	    // alert, focus and get out
		alert('Please specify the name of the event leader');
		form.primary_leader.focus();
		return false;
	}
	
	// if the event description is not set
	if (form.event_description.value == '')
	{
	    // alert, focus and get out
		alert('Please provide a description for the event');
		form.event_description.focus();
		return false;
	}
	
	// if the event leader is not specified
	if (form.primary_leader_email.value == '')
	{
	    // alert, focus and get out
		alert('Please specify the contact email for the event leader');
		form.primary_leader_email.focus();
		return false;
	}
	
	// if the primary leader company name is not set
	if (form.company_name.value == '')
	{
	    // alert, focus and get out
		alert('Please provide your company name');
		form.company_name.focus();
		return false;
	}
	
	// if the phone number of the primary leader is not set
	if (form.phone_number.value == '')
	{
		alert('Please provide the event leader phone number');
		form.contact_name.focus();
		return false;
	}
	
	// if the sponsor contact name is not set
	if (form.sponsor_contact_name.value == '')
	{
		alert('Please the Event Host Contact Name');
		form.sponsor_contact_name.focus();
		return false;
	}
	
	// if the event host email is not set
	if (form.sponsor_email.value == '')
	{
		alert('Please provide the event host contact email');
		form.sponsor_email.focus();
		return false;
	}
	
	// if the host company name is not set
	if (form.sponsor_company_name.value == '')
	{
		alert('Please provide the event host company name');
		form.sponsor_company_name.focus();
		return false;
	}
	
	// if the event host phone number is not set
	if (form.sponsor_telephone.value == '')
	{
		alert('Please provide the event host phone number');
		form.sponsor_telephone.focus();
		return false;
	}
}

function showAssociation(checkboxId, bHasStates)
{
    var checkbox = document.getElementById(checkboxId + '_checkbox');
    
    if (checkbox.checked)
    {
        if (bHasStates)
        {
            document.getElementById(checkboxId + '_state_list').disabled = false;
        }
        document.getElementById(checkboxId + '_membership').style.display = '';
        document.getElementById(checkboxId + '_memberid').disabled = false;
        document.getElementById(checkboxId + '_expiration_cell').style.display = '';
        document.getElementById(checkboxId + '_expiration').disabled = false;
    }
    else
    {
        if (bHasStates)
        {
            document.getElementById(checkboxId + '_state_list').disabled = true;
            document.getElementById(checkboxId + '_state_list').selectedIndex = 0;
        }
        document.getElementById(checkboxId + '_membership').style.display = 'none';
        document.getElementById(checkboxId + '_memberid').value = '';
        document.getElementById(checkboxId + '_memberid').disabled = true;
        document.getElementById(checkboxId + '_expiration_cell').style.display = 'none';
        document.getElementById(checkboxId + '_expiration').disabled = true;
        document.getElementById(checkboxId + '_expiration').value = '';
    }
}

function check_range_form(form)
{
	if (form.start_date.value == '')
	{
		alert('Please provide a start date');
		form.start_date.focus();
		return false;
	}
	
	if (form.end_date.value == '')
	{
		alert('Please provide an end date');
		form.end_date.focus();
		return false;
	}
	
	if (form.event_leader.value == '')
	{
		alert('Please provide the name of the event leader');
		form.event_leader.focus();
		return false;
	}
	
	if (form.event_location.value == '')
	{
		alert('Please provide an event location');
		form.event_location.focus();
		return false;
	}
	return true;
}

function check_bad_characters(sField, sFieldDescription)
{
    theField = eval('document.registration_form.' + sField);
    
    if (theField.value.indexOf(' ') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain any spaces');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('-') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the minus sign');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('*') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the asterisk character');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('@') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the "@" symbol');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('|') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the "|" symbol.');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf(';') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the character ";"');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('!') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the exclamation point');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('#') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the pound symbol');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('$') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the dollar sign');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('(') != -1 |
        theField.value.indexOf(')') != -1)
        {
            alert('Your ' + sFieldDescription + ' cannot contain parantheses');
            theField.focus();
            return false;
        }
        
    if (theField.value.indexOf('<') != -1 |
        theField.value.indexOf('>') != -1)
        {
            alert('Your ' + sFieldDescription + ' cannot contain the symbols "<" or ">"');
            theField.focus();
            return false;
        }
        
    if (theField.value.indexOf('/') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the character "/"');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('\\') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the character "\\"');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('"') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain double quotes');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf("'") != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain single quotes');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('`') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the character "`"');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('~') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the character "~"');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('{') != -1 |
        theField.value.indexOf('}') != -1)
        {
            alert('Your ' + sFieldDescription + ' cannot contain curly braces');
            theField.focus();
            return false;
        }
        
    if (theField.value.indexOf('[') != -1 |
        theField.value.indexOf(']') != -1)
        {
            alert('Your ' + sFieldDescription + ' cannot contain square brackets');
            theField.focus();
            return false;
        }
        
    if (theField.value.indexOf('=') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the equal sign');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('+') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the plus sign');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('&') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain ampersands');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('^') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the "^" symbol');
        theField.focus();
        return false;
    }

    if (theField.value.indexOf('%') != -1)
    {
        alert('Your ' + sFieldDescription + ' cannot contain the percentage symbol');
        theField.focus();
        return false;
    }
    
    return true;
}

function check_registration_form(form)
{
    if (form.username.value == '')
    {
        alert('Please provide your username');
        form.username.focus();
        return false;
    }
    else
    {
        if (!check_bad_characters('username', 'username'))
        {
            return false;
        }
    }
    
    if (form.email.value == '')
    {
        alert('Please provide your email address');
        form.email.focus();
        return false;
    }
    
    if (form.password.value == '')
    {
        alert('Please provide a password');
        form.password.focus();
        return false;
    }
    else
    {
        if (!check_bad_characters('password', 'password'))
        {
            return false;
        }
        
        if (form.confirm_password.value == '')
        {
            alert('Your password confirmation cannot be blank');
            form.confirm_password.focus();
            return false;
        }
        else
        {
            if (!check_bad_characters('confirm_password', 'password confirmation'))
            {
                return false;
            }
            
            if (form.password.value != form.confirm_password.value)
            {
                alert('Your password and password confirmation are not the same!');
                form.password.value = '';
                form.confirm_password.value = '';
                form.password.focus();
                return false;
            }
        }
    }
    
    if (form.member_type.selectedIndex == 0)
    {
        alert('Please select a member type');
        form.member_type.focus();
        return false;
    }
    
    if (form.age.selectedIndex == 0)
    {
        alert('Please select your age range.');
        form.age.focus();
        return false;
    }
    
    if (form.gender.selectedIndex == 0)
    {
        alert('Please select your gender');
        form.gender.focus();
        return false;
    }
    
    if (form.firstname.value == '')
    {
        alert('Please provide your first name');
        form.firstname.focus();
        return false;
    }
    
    if (form.lastname.value == '')
    {
        alert('Please provide your last name');
        form.lastname.focus();
        return false;
    }
    /*
    
    if (form.address1.value == '')
    {
        alert('Please provide your address');
        form.address1.focus();
        return false;
    }
    
    if (form.city.value == '')
    {
        alert('Please provide your city');
        form.city.focus();
        return false;
    }
    
    if (form.state_province.value == '')
    {
        alert('Please provide your State or Province');
        form.state_province.focus();
        return false;
    }
    
    if (form.zipcode.value == '')
    {
        alert('Please provide your Zip / Postal Code');
        form.zipcode.focus();
        return false;
    }
    
    if (form.country.selectedIndex == 0)
    {
        alert('Please provide your country');
        form.country.focus();
        return false;
    }
    
    */
    
    if (!form.privacy_policy.checked)
    {
        alert('You must read the privacy policy in order to be able to register');
        form.privacy_policy.focus();
        return false;
    }
    
    if (!form.terms_conditions.checked)
    {
        alert('Your must read the terms and conditions in order to be able to register');
        form.terms_conditions.focus();
        return false;
    }
    
    if (!form.receive_website_email[0].checked &
        !form.receive_website_email[1].checked)
    {
        alert('Please specify if you want to receive email updates or not');
        form.receive_website_email[0].focus();
        return false;
    }
    
    if (form.code.value == '')
    {
        alert('Please provide the security code to send your registration information');
        form.code.focus();
        return false;
    }
    
    return true;
}
