
function _CF_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
	input_object.focus();
       	return false;	
    }

function _CF_hasValue(obj, obj_type)
    {
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
    	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_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_checkphone(object_value)
    {
    if (object_value.length == 0)
        return true;
		
    //if (object_value.length != 12)
    //    return false;
	// check if first 3 characters represent a valid area code
    //if (!_CF_checknumber(object_value.substring(0,3)))
	//	return false;
    //else
	//if (!_CF_numberrange((eval(object_value.substring(0,3))), 100, 1000))
	//	return false;
	// check if area code/exchange separator is either a'-' or ' '
	//if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
    //    return false
	// check if  characters 5 - 7 represent a valid exchange
    //if (!_CF_checknumber(object_value.substring(4,7)))
	//	return false;
    //else
	//if (!_CF_numberrange((eval(object_value.substring(4,7))), 100, 1000))
	//	return false;
	
	// check if exchange/number separator is either a'-' or ' '
	//if (object_value.charAt(7) != "-" && object_value.charAt(7) != " ")
    //    return false;
	// make sure last for digits are a valid integer
	//if (object_value.charAt(8) == "-" || object_value.charAt(8) == "+")
    //   return false;
	//else
	//{
	//	return (_CF_checkinteger(object_value.substring(8,12)));
	//}
    }

function _CF_checkzip(object_value)
    {
    if (object_value.length == 0)
        return true;
		
    if (object_value.length != 5 && object_value.length != 10)
        return false;
	// make sure first 5 digits are a valid integer
	if (object_value.charAt(0) == "-" || object_value.charAt(0) == "+")
        return false;
	if (!_CF_checkinteger(object_value.substring(0,5)))
		return false;
	if (object_value.length == 5)
		return true;
	
	// make sure
	// check if separator is either a'-' or ' '
	if (object_value.charAt(5) != "-" && object_value.charAt(5) != " ")
        return false;
	// check if last 4 digits are a valid integer
	if (object_value.charAt(6) == "-" || object_value.charAt(6) == "+")
        return false;
	return (_CF_checkinteger(object_value.substring(6,10)));
    }

	
function NotValidEmail( Fld, Msg, Msg2, Empty, FldLen )
{
	EmailVal = Fld.value;
	var listchar = " ~!#$%^&*()+=|\\?<>:;'{}[]`/,‘";
	var filter = /^.+@.+\..{2,3}$/

	if ( EmailVal.length <= 0 )
	{
		alert(Empty);
		Fld.focus();
		return true;
	}
	
	for (i=0; i<listchar.length; i++) 
	{
		if (EmailVal.indexOf( listchar.substr(i, 1) ) >= 0)
		{
			sstatus = Msg+'" '+ listchar.substr(i, 1) +'"';
			alert(sstatus);
			Fld.focus();
			Fld.select();
			return true;
		}
	}

	if (!filter.test(EmailVal))
	{
		alert( Msg2 )
		Fld.focus();
		return true;
	}
	
	if ( EmailVal.length > FldLen )
	{
		alert( "The value you entered must be " + FldLen + " character or less." );
		Fld.focus();
		return true;
	}
}	
	
	
function _CF_checkCFForm_1(_CF_this)
    {
    if  (!_CF_hasValue(_CF_this.Lastname, "TEXT")) 
        {
		
        if  (!_CF_onError(_CF_this, _CF_this.Lastname, _CF_this.Lastname.value, "Please enter your Last name."))
            {
            return false; 
            }
        }
    
    if  (!_CF_hasValue(_CF_this.Firstname, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Firstname, _CF_this.Firstname.value, "Please enter your First name."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Middlename, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Middlename, _CF_this.Middlename.value, "Please enter your Middle name."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Nickname, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Nickname, _CF_this.Nickname.value, "Please enter your Nickname."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Batchyear, "SELECT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Batchyear, _CF_this.Batchyear.value, "Please indicate your Batch Year."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Batchletter, "SELECT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Batchletter, _CF_this.Batchletter.value, "Please indicate your Batch letter, choose none if you don't have one."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Status, "SELECT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Status, _CF_this.Status.value, "Please choose your Civil status."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Birthday, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Birthday, _CF_this.Birthday.value, "Please enter your Date of birth."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Birthplace, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Birthplace, _CF_this.Birthplace.value, "Please enter your Place of birth."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Wifename, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Wifename, _CF_this.Wifename.value, "Please enter the complete name of your wife."))
            {
            return false; 
            }
        }

	if  (!_CF_hasValue(_CF_this.Undergrad_Degree.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Undergrad_Degree, _CF_this.Undergrad_Degree.value, "Please enter your UnderGraduate degree."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Undergrad_Major.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Undergrad_Major, _CF_this.Undergrad_Major.value, "Please enter your UnderGraduate major."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Undergrad_School.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Undergrad_School, _CF_this.Undergrad_School.value, "Please enter your UnderGraduate school."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Undergrad_Graduation.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Undergrad_Graduation, _CF_this.Undergrad_Graduation.value, "Please enter your UnderGraduate year of graduation."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Postgrad_Degree.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Postgrad_Degree, _CF_this.Postgrad_Degree.value, "Please enter your PostGraduate degree."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Postgrad_Major.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Postgrad_Major, _CF_this.Postgrad_Major.value, "Please enter your PostGraduate major."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Postgrad_School.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Postgrad_School, _CF_this.Postgrad_School.value, "Please enter your PostGraduate school."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Postgrad_Graduation.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Postgrad_Graduation, _CF_this.Postgrad_Graduation.value, "Please enter your PostGraduate year of graduation."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Home_Address.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Home_Address, _CF_this.Home_Address.value, "Please enter your Home address."))
            {
            return false; 
            }
        }
    if  (!_CF_hasValue(_CF_this.Home_Phone, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Home_Phone, _CF_this.Home_Phone.value, "Please enter your Home phone number."))
            {
            return false; 
            }
        }

    if  (!_CF_checknumber(_CF_this.Home_Phone.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Home_Phone, _CF_this.Home_Phone.value, "Please enter a valid Home phone number."))
            {
            return false; 
            }
        }
    if  (!_CF_hasValue(_CF_this.Mobile_Phone, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Mobile_Phone, _CF_this.Mobile_Phone.value, "Please enter your Mobile phone number."))
            {
            return false; 
            }
        }

    if  (!_CF_checknumber(_CF_this.Mobile_Phone.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Mobile_Phone, _CF_this.Mobile_Phone.value, "Please enter a valid Mobile phone number."))
            {
            return false; 
            }
        }
    if  (!_CF_hasValue(_CF_this.Home_Fax, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Home_Fax, _CF_this.Home_Fax.value, "Please enter your Home fax number."))
            {
            return false; 
            }
        }

    if  (!_CF_checknumber(_CF_this.Home_Fax.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Home_Fax, _CF_this.Home_Fax.value, "Please enter a valid Fax number."))
            {
            return false; 
            }
        }			
    if( NotValidEmail( _CF_this.Email, "The email address contains an invalid character.", "Please enter your personal email address.", "Please enter a valid email address." ) )
	{
		return false;	
	}
	if  (!_CF_hasValue(_CF_this.Website.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Website, _CF_this.Website.value, "Please enter your website or webpage address."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Current_Employment.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Current_Employment, _CF_this.Current_Employment.value, "Please enter your current employment or the name of your office or business."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Position.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Position, _CF_this.Position.value, "Please enter your Position or designation."))
            {
            return false; 
            }
        }
	if  (!_CF_hasValue(_CF_this.Office_Address.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Office_Address, _CF_this.Office_Address.value, "Please enter your Office address."))
            {
            return false; 
            }
        }							
	if  (!_CF_hasValue(_CF_this.Office_Address.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Office_Address, _CF_this.Office_Address.value, "Please enter your Office address."))
            {
            return false; 
            }
        }		
    if  (!_CF_hasValue(_CF_this.Office_Phone, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Office_Phone, _CF_this.Office_Phone.value, "Please enter your Office phone number."))
            {
            return false; 
            }
        }

    if  (!_CF_checknumber(_CF_this.Office_Phone.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Office_Phone, _CF_this.Office_Phone.value, "Please enter a valid Office phone number."))
            {
            return false; 
            }
        }
    if  (!_CF_hasValue(_CF_this.Office_Fax, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Office_Fax, _CF_this.Office_Fax.value, "Please enter your Office fax number."))
            {
            return false; 
            }
        }

    if  (!_CF_checknumber(_CF_this.Office_Fax.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Office_Fax, _CF_this.Office_Fax.value, "Please enter a valid Office fax number."))
            {
            return false; 
            }
        }
    if( NotValidOffice_Email( _CF_this.Office_Email, "The email address contains an invalid character.", "Please enter your Office email address.", "Please enter a valid email address." ) )
	{
		return false;	
	}
	if  (!_CF_hasValue(_CF_this.Office_Website.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Office_Website, _CF_this.Office_Website.value, "Please enter your Office website or webpage address."))
            {
            return false; 
            }
        }
    if  (!_CF_hasValue(_CF_this.Date_today, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Date_today, _CF_this.Date_today.value, "Please enter the Date today."))
            {
            return false; 
            }
        }

    if  (!_CF_checknumber(_CF_this.Date_today.value))
        {
        if  (!_CF_onError(_CF_this, _CF_this.Date_today, _CF_this.Date_today.value, "Please enter a valid Date."))
            {
            return false; 
            }
        }										

function RadioHasValue(obj,msg)
{
  var i;
  for(i=0;i<obj.length;i++)
    if(obj[i].checked)return true;

  return false;
}
}


