<!-- Begin


	

/* --------------------------------------------
	GENERAL
   --------------------------------------------
*/

var varSection = 0;


/************************************************
 bool ValidateEmail(string input)
 Return true or false
 if the email is valid or not.
 checks for @ and .
**************************************************/
function ValidateEmail(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0);
 if(s.indexOf)
 {
  at_character=s.indexOf('@');
  if(at_character<=0 || at_character+4>s.length)
   return false;
 }
 if(s.length<6)
  return false;
 else
  return true;
}
 
/************************************************
 bool ValidatePhone(string input)
 Return true or false
 if the phone number is valid or not.
 acepts - and + symbols
**************************************************/
function ValidatePhone(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("[-+0-9]+","gi"))>=0);
 if(s.length<5)
  return false;
 else
  return true;
}
 

/************************************************
 bool ValidateZip(string input)
 Return true or false
 if the zip is valid or not.
 acepts leters and numbers
**************************************************/
function ValidateZip(theinput)
{
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("[a-zA-Z0-9]+","gi"))>=0);
 if(s.length<3)
  return false;
 else
  return true;
}
 

/************************************************
 bool ValidateNumber(string input)
 Return true or false
 if the number is valid or not.
 acepts only digits
**************************************************/
function ValidateNumber(theinput){
 var s=theinput;
 return s.match(/^\d+$/);
}


/************************************************
 value getSelectedValue(string input)
 returns the value of the selected radio box

**************************************************/
function getSelectedValue(radioobject){
	var returnvalue = "";
	for(i=0; i<radioobject.length; i++){
		if(radioobject[i].checked) 
			returnvalue = radioobject[i].value;
	}
	return returnvalue;
}
	
	
	
/******************************************************************
 ******************************************************************
 checkSamplesForm: check SamplesForm
 ******************************************************************
******************************************************************/
function checkSamplesForm(form){
	var error="";
	
	var $requestedone = false;

	for($i=0;$i<form.cr.length;$i++){
		if(form.cr[$i].checked==true){
			$requestedone = true;
			break;
		}
	}

	if(!$requestedone && form.crother.value==""){
		error+="    Select at least one Sample Item.\n";
	}
	if(form.fname.value=="" || form.fname.lenght<3){
		error+="    First Name\n";
	}
	if(form.lname.value=="" || form.lname.lenght<3){		
		error+="    Last Name\n";
	}
	if(form.company.value=="" || form.company.lenght<3){		
		error+="    Company\n";
	}
	if(form.st1.value=="" || form.st1.lenght<3){		
		error+="    Street\n";
	}
	if(form.city.value=="" || form.city.lenght<3){		
		error+="    City\n";
	}
	if(form.state.value=="" || form.state.lenght<3){		
		error+="    State\n";
	}
	if(form.zip.value=="" || form.zip.lenght<3){		
		error+="    Zip\n";
	}
	if(form.phone.value=="" || !ValidatePhone(form.phone.value)){		
		error+="    Phone\n";
	}
	if(form.email.value=="" || !ValidateEmail(form.email.value)){		
		error+="    Email\n";
	}
	
	if(error!="")
		alert("Error, Please Check: \n"+error);
	else {
		alert('Thank you for your samples request.  We will process your request as soon as possible.');
		form.submit();
	}
	
}
	

/******************************************************************
 ******************************************************************
 checkSamplesForm: check SamplesForm
 ******************************************************************
******************************************************************/
function checkRMAForm(form){
	var error="";
		
	if(varSection==0){
		alert("Please fill Section 1 or Section 2 and Section 3");
		return false;
	}

	if(varSection==1){ //section 1
		if(form.sec1_1.value=="" || form.sec1_1.value.lenght<5){
			error+="    Original Sales Order Number.\n";
		}
		if(form.sec1_2.value=="" || form.sec1_2.value.lenght<5){
			error+="    Date Shipped.\n";
		}
		if(error!=""){
			document.getElementById('section3').style.visibility='hidden';
			document.getElementById('section2').style.visibility='hidden';
			document.getElementById('section1').style.visibility='visible';
			window.location.href="#";
		}
	}
	
	if(varSection==2){ //section 2
		if(form.sec2_1.value=="" || form.sec2_1.value.lenght<5){
			error+="    Who was the original purchaser.\n";
		}
		if(form.sec2_2.value=="" || form.sec2_2.value.lenght<5){
			error+="    What was the purchase order number.\n";
		}
		if(form.sec2_3.value=="" || form.sec2_3.value.lenght<5){
			error+="    What is the job name.\n";
		}
		if(form.sec2_4.value=="" || !ValidateNumber(form.sec2_4.value)){
			error+="    Ship Month.\n";
		}
		if(form.sec2_5.value=="" || !ValidateNumber(form.sec2_5.value)){
			error+="    Ship Day.\n";
		}
		if(form.sec2_6.value=="" || !ValidateNumber(form.sec2_6.value)){
			error+="    Ship Year.\n";
		}
		if(error!=""){
			document.getElementById('section3').style.visibility='hidden';
			document.getElementById('section2').style.visibility='visible';
			document.getElementById('section1').style.visibility='hidden';
			window.location.href="#";
		}
	}
	
	
	if(form.sec3_1.value==-1)
		error+="    Action Code.\n";
	if(form.sec3_2.value=="" || !ValidateNumber(form.sec3_2.value))
		error+="    Quantity to be returned.\n";
	if(form.sec3_3.value=="")
		error+="    Purchase Order number.\n";
	if(form.sec3_5.value==-1)
		error+="    Is it under warranty?\n";	
	
	
	if(error!="")
		alert("Error, Please fix/answer the following: \n"+error);
	else {
		alert('Thank you for your RMA submission, you will hear back from us shortly.');
		form.submit();
	}
	
}

	
//  End -->	
