	function checkForm(frm)
	{
		// put any for validation here.
		// if validation fails, pop up an alert and return false.
		if (frm.allowClick.value == 0)
		{
			return false;
		}
		
		if (frm.SecurityCode.value == '')
		{
		    alert('Please re-type the security code displayed.');
		    return false;
		}
		
		if (!frm.agree.checked)
		{
		    alert('Please check the box to indicate that you have read and agree to the terms and condition');
		    return false;
		}
		
		// if validation fails, pop up an alert and return false.
		//if (!confirmPass(frm))
		//{
			// confirm pass uses it's own popup
		//	return false;
		//}
		
		// frm.submitbtn.value = 'Processing...'
		return true;
	}

	function confirmPass(frm)
	{
		// put any for validation here.
		// if validation fails, pop up an alert and return false.
		if (frm.Password.value.length < 5)
		{
			alert('Password must be at least 5 characters long');
			return false;
		}
		if (frm.Password.value != frm.PasswordConfirm.value)
		{
			alert('Password and confirmation do not match.');
			return false;
		}
		return true;
	}

	function copyBilling(frm)
	{
	    if (frm.use_billing.checked)
	    {
		    frm.ship_to_company.value = frm.company.value;
		    frm.ship_to_address_1.value = frm.address_1.value;
		    frm.ship_to_address_2.value = frm.address_2.value;
		    frm.ship_to_city.value = frm.city.value;
		    frm.ship_to_state.selectedIndex = frm.state.selectedIndex;
		    frm.ship_to_zip.value = frm.zip.value;
		    frm.ship_to_country.selectedIndex = frm.country.selectedIndex;
		    frm.ship_to_phone.value = frm.phone.value;
		}
		
		return true;
	}

// ****  promo ajax **** //


function onSuccess(request)
{
	var result = request.responseText.parseJSON();
	if (result.is_discounted)
	{
	    $('promo').innerHTML = "Applied";
	    $('promo_line').style.display='';
	    $('promo_amount').innerHTML = "-$" + result.discount_amount;
	    $('total_amount').innerHTML = "$" + result.adjusted_amount;
	}
	else
	{
	    $('promo').innerHTML = "";
	    $('promo_line').style.display='none';
	    $('promo_amount').innerHTML = "-$ " + result.discount_amount;
	    $('total_amount').innerHTML = "$ " + result.adjusted_amount;
	}
	
    $('remainder_amount').innerHTML = "$ " + result.trial_remainder_amount;

}

function onFail()
{
	$('promo').innerHTML = "ERROR";
}

function applyCode(trial)
{
    //document.getElementById('apply').value="...";
	$('promo').innerHTML = "<img src='skins/default/artwork/ico_loading.gif' alt='...' style='margin-left: 35px;'/>";

	var url = 'signup_code.php';
	var pars = 'code=' + $F('PromoCode') + '&rnd=' + Math.random();
	if (trial)
	{
	    pars += '&trial=1';
	}

	var myAjax = new Ajax.Request( 
		url, 
		{ 
			method: 'get', 
			parameters: pars, 
			onComplete: onSuccess,
			onFail: onFail,
			asynchronous: true
		}
	); 

}
