// JavaScript Document
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")
	{
    	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_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_checkcreditcard(object_value)
    {
	var white_space = " -";
	var creditcard_string="";
	var check_char;


    if (object_value.length == 0)
        return true;

	// squish out the white space
	for (var i = 0; i < object_value.length; i++)
	{
		check_char = white_space.indexOf(object_value.charAt(i))
		if (check_char < 0)
			creditcard_string += object_value.substring(i, (i + 1));
	}	

	// if all white space return error
    if (creditcard_string.length == 0)
        return false;
	 
	 	
	// make sure number is a valid integer
	if (creditcard_string.charAt(0) == "+")
        return false;

	if (!_CF_checkinteger(creditcard_string))
		return false;

    // now check mod10

	var doubledigit = creditcard_string.length % 2 == 1 ? false : true;
	var checkdigit = 0;
	var tempdigit;

	for (var i = 0; i < creditcard_string.length; i++)
	{
		tempdigit = eval(creditcard_string.charAt(i))

		if (doubledigit)
		{
			tempdigit *= 2;
			checkdigit += (tempdigit % 10);

			if ((tempdigit / 10) >= 1.0)
			{
				checkdigit++;
			}

			doubledigit = false;
		}
		else
		{
			checkdigit += tempdigit;
			doubledigit = true;
		}
	}	
	return (checkdigit % 10) == 0 ? true : false;

    }


function  _CF_checkform1(_CF_this)

    {

    if  (!_CF_hasValue(_CF_this.LName, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.LName, _CF_this.LName.value, "Last Name is Required."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.FName, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.FName, _CF_this.FName.value, "First Name is Required."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.City, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.City, _CF_this.City.value, "City is Required."))

            {

            return false; 

            }

        }



    if  (!_CF_hasValue(_CF_this.Zip, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.Zip, _CF_this.Zip.value, "Zip is Required."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.Phone, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.Phone, _CF_this.Phone.value, "Phone is Required."))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.email, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.email, _CF_this.email.value, "Please provide a Valid Email Address."))

            {

            return false; 

            }

        }

	var box = document.form1.ContractReceived.options;
var chosen_value = box[box.selectedIndex].value;
	if(chosen_value=="No"){
		alert("You must agree to the acceptance of the terms and conditions for wc-hosting before continuing.")
		return false;
		}
  


    return true;

    }
	
	
	
function CheckContract(){
	var box = document.form1.ContractReceived.options;
var chosen_value = box[box.selectedIndex].value;
	if(chosen_value=="No"){
		alert("You must agree to the acceptance of the terms and conditions for wc-hosting before continuing.")
		return false;
		}
	return true
	
	}
	
	
	function CheckforEmail(){
	var mybox = document.form1.Package.options;
var mychosen_value = mybox[mybox.selectedIndex].value;
	if(mychosen_value=="email"){
		document.form1.BillingFrequency.value = "Annually"
		}
	
	}
