/* Code by David Droddy */
namePass=0;
phonePass=0;
emailPass=0;
function reUse(thisField,thatField,commonField)
	{
	if(thisField != '')
		{
		if (commonField=='Name' && namePass==0 || commonField=='Phone' && 
		phonePass==0 || commonField=='Email' && emailPass==0)
			{
			if (confirm('Would you also like to set the Contact ' + commonField + 
			' as ' + thisField + '?'))
				{
				thatField.value = thisField;
				}
			}
			if (commonField=='Name') {namePass=1}
			else if (commonField=='Phone') {phonePass=1}
			else {emailPass=1}
		}
	}

/* I don't believe the rest of this is necessary. 
	All validation is being generated by CF and is working. 
	Only the above is needed for User submissions to allow 
	for auto-fill of sponsor info--based on submitter info.*/

/*
function _CF_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;

	}



function _CF_hasValue(obj, obj_type)
    {
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
//HERE IS THE PROBLEM!!!!!!!!!!!!?
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj.options[i].selected)
			return true;
		}

       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{

		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{

        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}

       	return false;	
	}
	}



function _CF_checkdate(object_value)
    {
    //Returns true if value is a date format or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a date in the mm/dd/yyyy format
	isplit = object_value.indexOf('/');

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sMonth = object_value.substring(0, isplit);
	isplit = object_value.indexOf('/', isplit + 1);

	if (isplit == -1 || (isplit + 1 ) == object_value.length)
		return false;

    sDay = object_value.substring((sMonth.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!_CF_checkinteger(sMonth)) //check month
		return false;
	else
	if (!_CF_checkrange(sMonth, 1, 12)) //check month
		return false;
	else
	if (!_CF_checkinteger(sYear)) //check year
		return false;
	else
	if (!_CF_checkrange(sYear, 0, 9999)) //check year
		return false;
	else
	if (!_CF_checkinteger(sDay)) //check day
		return false;
	else
	if (!_CF_checkday(sYear, sMonth, sDay)) // check day
		return false;
	else
		return true;
    }



function _CF_checkday(checkYear, checkMonth, checkDay)
    {

	maxDay = 31;

	if (checkMonth == 4 || checkMonth == 6 ||
			checkMonth == 9 || checkMonth == 11)
		maxDay = 30;
	else
	if (checkMonth == 2)
	{
		if (checkYear % 4 > 0)
			maxDay =28;
		else
		if (checkYear % 100 == 0 && checkYear % 400 > 0)
			maxDay = 28;
		else
			maxDay = 29;
	}

	return _CF_checkrange(checkDay, 1, maxDay); //check day
    }



function _CF_checkinteger(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
	return _CF_checknumber(object_value);
    else
	return false;
    }



function _CF_numberrange(object_value, min_value, max_value)
    {
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
		return false;
	}

    // check maximum
    if (max_value != null)
	{
	if (object_value > max_value)
		return false;
	}
	
    //All tests passed, so...
    return true;
    }



function _CF_checknumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
    }



function _CF_checkrange(object_value, min_value, max_value)
    {
    //if value is in range then return true else return false

    if (object_value.length == 0)
        return true;


    if (!_CF_checknumber(object_value))
	{
	return false;
	}
    else
	{
	return (_CF_numberrange((eval(object_value)), min_value, max_value));
	}
	
    //All tests passed, so...
    return true;
    }


function  _CF_checkeventform(_CF_this)

    {

    if  (!_CF_hasValue(_CF_this.submitter_name, "TEXT" )) 

        {
		
        if  (!_CF_onError(_CF_this, _CF_this.submitter_name, _CF_this.submitter_name.value, 
			"Please enter a name in the submitter Name field."))
            {
			alert('start');
			_CF_this.submitter_name.focus();
			_CF_this.submitter_name.select();
            return false;
            }

        }


    if  (!_CF_hasValue(_CF_this.submitter_phone, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.submitter_phone, _CF_this.submitter_phone.value, "The Submitter Phone field is required.\nPlease enter a phone number in the Submitter Phone field."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.submitter_email, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.submitter_email, _CF_this.submitter_email.value, "Please enter an address in the Submitter Email field."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.title, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.title, _CF_this.title.value, "Please enter a Title in the Event Title field."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.event_date, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.event_date, _CF_this.event_date.value, "The Event Date is required.\nPlease enter the Event Date in the following format: mm/dd/yyyy"))

            {

            return false; 

            }

        }


    if  (!_CF_checkdate(_CF_this.event_date.value))

        {

        if  (!_CF_onError(_CF_this, _CF_this.event_date, _CF_this.event_date.value, "The Event Date is required.\nPlease enter the Event Date in the following format: mm/dd/yyyy"))

            {

            return false; 

            }

        }


 if  (!_CF_checkrange(_CF_this.start_hour.value, 1, 12)) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.start_hour, _CF_this.start_hour.value, "Please enter a number from 1-12 in the Event Start Time, Hour field."))

            {

            return false; 

            }

        }


    if  (!_CF_checkinteger(_CF_this.start_hour.value))

        {

        if  (!_CF_onError(_CF_this, _CF_this.start_hour, _CF_this.start_hour.value, "Please enter a number from 1-12 in the Event Start Time, Hour field."))

            {

            return false; 

            }

        }


 if  (!_CF_checkrange(_CF_this.start_minute.value, 0, 59)) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.start_minute, _CF_this.start_minute.value, "Please enter a number from 0-59 in the Event Start Time, Minutes field."))

            {

            return false; 

            }

        }


    if  (!_CF_checkinteger(_CF_this.start_minute.value))

        {

        if  (!_CF_onError(_CF_this, _CF_this.start_minute, _CF_this.start_minute.value, "Please enter a number from 0-59 in the Event Start Time, Minutes field."))

            {

            return false; 

            }

        }


 if  (!_CF_checkrange(_CF_this.end_hour.value, 1, 12)) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.end_hour, _CF_this.end_hour.value, "Please enter a number from 1-12 in the Event End Time, Hour field."))

            {

            return false; 

            }

        }


    if  (!_CF_checkinteger(_CF_this.end_hour.value))

        {

        if  (!_CF_onError(_CF_this, _CF_this.end_hour, _CF_this.end_hour.value, "Please enter a number from 1-12 in the Event End Time, Hour field."))

            {

            return false; 

            }

        }


 if  (!_CF_checkrange(_CF_this.end_minute.value, 0, 59)) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.end_minute, _CF_this.end_minute.value, "Please enter a number from 0-59 in the Event End Time minutes field."))

            {

            return false; 

            }

        }


    if  (!_CF_checkinteger(_CF_this.end_minute.value))

        {

        if  (!_CF_onError(_CF_this, _CF_this.end_minute, _CF_this.end_minute.value, "Please enter a number from 0-59 in the Event End Time minutes field."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.location, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.location, _CF_this.location.value, "The Event Location is required.\n Please enter a location in the Location field."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.contact_name, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.contact_name, _CF_this.contact_name.value, "The Contact Name is required.\n Please enter a name in the Contact Name field."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.contact_phone, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.contact_phone, _CF_this.contact_phone.value, "The Contact Phone is required. \nPleas enter a phone number in the Contact Phone field."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.contact_email, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.contact_email, _CF_this.contact_email.value, "The Contact Email is required. \nPlease enter an address in the Contact Email field."))

            {

            return false; 

            }

        }


    return true;

    }

*/
