/******************************************************************************/
 
/* 
 * getting the value of a radio button is a little different than other 
 * form fields. we can't just do "radiobutton.value" so i wrote this function
 * to help. using this function we can do "get_radio_value(radiobutton)" to
 * get the value
 */
function get_radio_value(radio) 
{ 
    for (var i=0; i < radio.length; i++) 
    { 
        if (radio[i].checked) 
        { 
            return radio[i].value; 
        } 
    } 
} 

/* 
 * Check to see if the email address follows the pattern 'something@something.'
 */
function is_valid_email(input) 
{
	/* If the string contains an @ after the first character 
     * AND a . after the third character, return true */
	if ((input.indexOf("@") > 0) && (input.indexOf(".") > 2))
	{
		return true;
	}
	else
	{
		return false;
	}	 	 
}

/* 
 * Check to see if the phone number contains numbers
 */
function is_valid_phone(input) 
{
	if (input.match(/[0-9]/))
	{
		return true;
	}
	else
	{
		return false;
	}	 	 
}

/******************************************************************************/



/* 
 *  Validate the user input for the Request a Quote form
 */
function validate_request_quote_form(form)
{
	/* If first name is empty show alert */
	if (form.elements["xfirst name"].value == "") 
	{ 
		alert("Please fill in your first name"); 
		form.elements["xfirst name"].focus();
 
		return false; 
	} 
	
	/* If last name is empty show alert */
	if (form.elements["xlast name"].value == "") 
	{ 
		alert("Please fill in your last name"); 
		form.elements["xlast name"].focus(); 
                
		return false; 
	} 

	/* If email is invalid show alert */
	if (!is_valid_email(form.elements["email"].value)) 
	{ 
		alert("Please fill in your email address so that we may contact you."); 
		form.elements["email"].focus();
 
		return false; 
    
	}
	
	return true;
}


/* 
 * Validate the user input for the Contact Us form
 */
function validate_contact_us_form(form)
{
	/* If first name is empty show alert */
	if (form.elements["xfirst name"].value == "") 
	{ 
		alert("Please fill in your first name"); 
		form.elements["xfirst name"].focus();
 
		return false; 
	} 
	
	/* If last name is empty show alert */
	if (form.elements["xlast name"].value == "") 
	{ 
		alert("Please fill in your last name"); 
		form.elements["xlast name"].focus(); 
                
		return false; 
	} 
	
	/* If email is invalid show alert */
	if (!is_valid_email(form.elements["email"].value)) 
	{ 
		alert("Please fill in your email address so that we may contact you."); 
		form.elements["email"].focus(); 
                
		return false; 
    } 
	
	return true;
}


/* 
 * Validate the user input for the Order Tracking form
 */
function validate_order_tracking_form(form)
{
	/* If first name is empty show alert */
	if (form.elements["xfirst name"].value == "") 
	{ 
		alert("Please fill in your first name"); 
		form.elements["xfirst name"].focus();
 
		return false; 
	} 
	
	/* If last name is empty show alert */
	if (form.elements["xlast name"].value == "") 
	{ 
		alert("Please fill in your last name"); 
		form.elements["xlast name"].focus(); 
                
		return false; 
	} 
	
	/* If email is invalid show alert */
	if (!is_valid_email(form.elements["email"].value)) 
	{ 
		alert("Please fill in your email address so that we may contact you."); 
		form.elements["email"].focus(); 
                
		return false; 
    } 
	
	return true;
}


/* 
 * Validate the user input for the Return Request form
 */
function validate_return_request_form(form)
{
	/* If first name is empty show alert */
	if (form.elements["xfirst name"].value == "") 
	{ 
		alert("Please fill in your first name"); 
		form.elements["xfirst name"].focus();
 
		return false; 
	} 
	
	/* If last name is empty show alert */
	if (form.elements["xlast name"].value == "") 
	{ 
		alert("Please fill in your last name"); 
		form.elements["xlast name"].focus(); 
                
		return false; 
	} 
	
	/* If email is invalid show alert */
	if (!is_valid_email(form.elements["email"].value)) 
	{ 
		alert("Please fill in your email address so that we may contact you."); 
		form.elements["email"].focus(); 
                
		return false; 
    } 
	
	return true;
}


	function preview_finish(small_image)
	{
		/* Get new image URL based on small image URL */
		var new_image_url = small_image.src.substring(0,52) 
		                  + 'Big' + small_image.src.substring(52) ;
				
		/* Get big image tag */
		var big_image = document.getElementById('BigFinish');
		
		/* Set big image URL */
		big_image.src = new_image_url;
	}





