function DiscountTypeGeneralDollar_AdminShowActivationDateClearTrigger()
{
	var curdate = new Date();
	var month = curdate.getMonth()+1;
	var year = curdate.getYear();
	var day = curdate.getDate();

	// pad day with zeros
	if(Math.abs(day) < 10)
		day = '0'+Math.abs(day);
	else
		day = Math.abs(day);

	// pad month with zeros
	if(Math.abs(day) < 10)
		day = '0'+Math.abs(day);
	else
		day = Math.abs(day);
//alert(document.getElementById('activation_date').value + ', ' + year + '' + month + '' + day);
	if(document.getElementById('discount_general_dollar_activation_date').value != year + '' + month + '' + day)
		document.getElementById('discount_general_dollar_activation_date_clear_display').style.display = 'inline';
}
function DiscountTypeGeneralDollar_AdminShowExpirationDateClearTrigger()
{
	document.getElementById('discount_general_dollar_expiration_date_clear_display').style.display = 'inline';
}

function DiscountTypeGeneralDollar_AdminGenerateDiscountCodes()
{
	var qty = document.getElementById('discount_general_dollar_generate_qty').value;
	var dollar_value = document.getElementById('discount_general_dollar_generate_dollar_value').value;
	var min_subtotal = document.getElementById('discount_general_dollar_generate_min_subtotal').value;
	var activation_date = document.getElementById('discount_general_dollar_activation_date').value;
	var expiration_date = document.getElementById('discount_general_dollar_expiration_date').value;
	var is_extended = document.getElementById('discount_general_dollar_generate_is_extended').checked;

	var error_string = '';

	// check input
	if(!DiscountTypeGeneralDollar_IsValidGenerateQuantity(qty))
	{
		error_string += '<div>Invalid Quantity to generate</div>';
	}
	if(!DiscountTypeGeneralDollar_IsValidDollarAmount(dollar_value))
	{
		error_string += '<div>Invalid Dollar Value</div>';
	}
	if(!DiscountTypeGeneralDollar_IsValidDollarAmount(min_subtotal))
	{
		error_string += '<div>Invalid Dollar Value</div>';
	}
	document.getElementById('discount_general_dollar_error_box').style.display = 'none';
	if(error_string)
	{
		document.getElementById('discount_general_dollar_error_box_body').innerHTML = error_string;
		document.getElementById('discount_general_dollar_error_box').style.display = 'block';
	}
	
/*
	alert(
	document.getElementById('discount_general_dollar_generate_qty').value + ', ' +
	document.getElementById('discount_general_dollar_generate_dollar_value').value + ', ' +
	document.getElementById('discount_general_dollar_generate_min_subtotal').value + ', ' +
	document.getElementById('discount_general_dollar_activation_date').value + ', ' +
	document.getElementById('discount_general_dollar_expiration_date').value + ', ' +
	document.getElementById('discount_general_dollar_generate_is_extended').checked);
*/
}

function DiscountTypeGeneralDollar_IsValidGenerateQuantity(quantity_value)
{
	var valid_char_string = "1234567890";
	
	
	if(quantity_value.length < 1 || quantity_value.length > 6)
		return false;
	else
	{
		// make sure there are only numbers
		for(var i=0; i<quantity_value.length; i++)
		{
			if(valid_char_string.indexOf(quantity_value.charAt(i)) == -1)
			{
				return false;
			}
		}
	}
	
	// make sure the value is actually greater than zero
	if(Number(quantity_value) < 1)
		return false;
	
	return true;
}

function DiscountTypeGeneralDollar_IsValidDollarAmount(dollar_value)
{
	var valid_char_string = "1234567890.";
	
	
	if(dollar_value.length < 1 || dollar_value.length > 10)
		return false;
	else
	{
		// make sure there are only numbers and decimal points
		for(var i=0; i<dollar_value.length; i++)
		{
			if(valid_char_string.indexOf(dollar_value.charAt(i)) == -1)
			{
				return false;
			}
		}
	
		// make sure there is only one decimal place
		if(dollar_value.indexOf('.') != dollar_value.lastIndexOf('.'))
			return false;
	}
	return true;
}