<!-- hide script from old browsers

function ChangeRowColor(Row,Active)
{
	if (Active)
	{
		Row.style.backgroundColor = '#7DF873';
	}
	else
	{
		Row.style.backgroundColor = '#FFFFFF';
	}
}

function ShowMachines()
{
	var target = 'machines';
	var url = 'inventory_list.php';
	var params = 'type=' + escape(document.getElementById('Type').value) + '&make=' + escape(document.getElementById('Make').value) + '&status=' + escape(document.getElementById('Status').value);

	new Ajax.Updater(target,url,{asynchronous:true, method: 'post', parameters: params});
}

function InfoRequest(Machine_ID)
{
	var target = 'main';
	var url = 'info_request.php';
	var params = 'machine_id=' + escape(Machine_ID);

	new Ajax.Updater(target,url,{asynchronous:true, method: 'post', parameters: params});
}

function validateRequest()
{ 
	if ( document.Info_Request.custname.value == "" )
	{
		alert ( "You must enter your name." );
		document.Info_Request.custname.focus();
		return false;
	}
	else if ( document.Info_Request.email.value == "" )
	{
		alert ( "You must enter your email address." );
		document.Info_Request.email.focus();
		return false;
	}
	else if ( !isValidEmail(document.Info_Request.email.value) )
	{
		alert ( "You must enter a valid email address." );
		document.Info_Request.email.focus();
		return false;
	}
	else if ( document.Info_Request.phone.value == "" )
	{
		alert ( "You must enter your phone number." );
		document.Info_Request.phone.focus();
		return false;
	}
	else if ( !isValidPhone(document.Info_Request.phone.value) )
	{
		alert ( "You must enter a valid phone number." );
		document.Info_Request.phone.focus();
		return false;
	}
	else if ( !ContactMethodSelected() )
	{
		alert ( "Please indicate how you would like us to contact you." );
		return false;
	}
	else if ( document.Info_Request.comments.value == "" )
	{
		alert ( "Please enter some comments." );
		document.Info_Request.comments.focus();
		return false;
	}
	else
	{
		return true;
	}
}

//function to check valid email address
//copied from http://www.designplace.org/scripts.php?page=1&c_id=22 and modified
function isValidEmail(strEmail)
{
	validRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	// search email text for regular exp matches
	if (strEmail.search(validRegExp) == -1) 
	{
		return false;
	} 
	else
	{
		return true;
	}
}

//function to check valid phone number
function isValidPhone(strPhone)
{
	strPhone = strPhone.replace(/\D/g,'');	//remove all but digits

	if ( strPhone.charAt(0) == '1' || strPhone.charAt(0) == '0' )	//see if it starts with a 0 or 1 and if it does, remove the first digit
	{
		strPhone = strPhone.substr(1);
	}

	if ( strPhone.length != 10 )	//if we do not have 10 digits remaining
	{
		return false;
	}
	else
	{
		return true;
	}
}

//function to check that a contact method is selected
function ContactMethodSelected()
{
	for(var i=0; i<document.Info_Request.preferred_contact_method.length; i++)
	{
		if(document.Info_Request.preferred_contact_method[i].checked)
		{
			return true;
		}
	}
}

function validateEmail()
{
	if ( validateRequest() )
	{
		if ( document.Info_Request.subject.value == "" )
		{
			alert ( "You must enter a subject for your email." );
			document.Info_Request.subject.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	else //The other function displayed an alert and told this function NO so we can just say NO (return False)
	{
		return false;
	}
}

// end hiding script from old browsers -->

