function reasonOptions(){

	if(!rma.return_reason[0].checked && !rma.return_reason[1].checked && !rma.return_reason[2].checked){
		alert("Please choose a return reason.");
	}else if(rma.return_reason[1].checked){
		alert("These options are not available for return reason #2.");
}else if(rma.return_reason[2].checked){
		alert("These options are not available for return reason #3.");
}	
	
}

function resetOptions(){
	rma.return_reason_option[0].checked = false;
	rma.return_reason_option[1].checked = false;
}	


function isBlank(s)
{
	for (var i =0; i< s.length; i++)
	{
		var c=s.charAt(i);
		if ((c !=' ') && (c !='\n') && (c != '\t')) return false;
	}
	return true;
}

function isChecked(s) {
	if (!s.checked){ 
	return true;
	}
}

function validateForm(form) {

	var order_number;
	var invoice_date;
	var address;
	var city;
	var state;
	var phone_number;
	var email_address;
	var first_item;
	var first_item_code;
	var first_item_quantity;
	var read_policy;
	var name;
	

	name=form.name.value;
	order_number=form.order_number.value;
	invoice_date=form.invoice_date.value;
	address=form.address.value;
	city=form.city.value;
	state=form.state.value;
	phone_number=form.phone_number.value;
	email_address=form.email_address.value;
	first_item=form.first_item.value;
	first_item_code=form.first_item_code.value;
	first_item_quantity=form.first_item_quantity.value;
	read_policy=form.read_policy;
	
	var success = true;
	var errorMessage = "";
		
	
	if (isBlank(name))
	{
		errorMessage+= 'Enter your name.\r\n';
		success = false;
	}

	if (isBlank(order_number))
	{
		errorMessage+= 'Enter the order number.\r\n';
		success = false;
	}

	if (isBlank(invoice_date))
	{
		errorMessage+= 'Enter the invoice date.\r\n';
		success = false;
	}
	
	if (isBlank(address))
	{
		errorMessage+= 'Enter your address.\r\n';
		success = false;
	}
	
	if (isBlank(city))
	{
		errorMessage+= 'Enter your city.\r\n';
		success = false;
	}
	
	if (isBlank(state))
	{
		errorMessage+= 'Enter your state.\r\n';
		success = false;
	}
	
	if (isBlank(phone_number))
	{
		errorMessage+= 'Enter your phone number.\r\n';
		success = false;
	}
	
	if (isBlank(email_address))
	{
		errorMessage+= 'Enter your email address.\r\n';
		success = false;
	}			

	if (isBlank(first_item))
	{
		errorMessage+= '\r\nEnter at least one item to be returned.\r\n';
		success = false;
	}		
	
	if (isBlank(first_item_code))
	{
		errorMessage+= 'Enter return item merchandise code.\r\n';
		success = false;
	}		
	
	if (isBlank(first_item_quantity))
	{
		errorMessage+= 'Enter return item(s) quantity.\r\n';
		success = false;
	}			
	 
	if (!form.return_reason[0].checked && !form.return_reason[1].checked && !form.return_reason[2].checked)
	{
		errorMessage+= '\r\nChoose a return reason.\r\n';
		success = false;
	}		
	
	
	if (isChecked(read_policy))
	{
		errorMessage+= '\r\nMake sure you have read and understand the return policy of VitaMaker.com';
		success = false;
	}		
	//************************************
	//****** PRESENT ERROR MESSAGE *******
	//************************************	
	if(!success) {
		errorMessage = "There were some problems with your input, please check the following:\r\n\r\n" + errorMessage;
		alert(errorMessage);
	}
	
	//******************
	//***** RETURN *****
	//******************	
	return success;
}

