// JavaScript Document
function IsNumeric(sText)

{
var ValidChars = "0123456789+-()";
var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
  
  function check_numeric(sText,field_name)

{
	var qty;
	qty=sText.value;
	//alert("asdfsadf");
	//alert(qty);
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;


		if(qty=="")
		IsNumber = true;
		
		else
	
		{
	 
				   for (i = 0; i < qty.length && IsNumber == true; i++) 
					{ 
					  Char = qty.charAt(i); 
					  if (ValidChars.indexOf(Char) == -1) 
							 {
							 IsNumber = false;
							 }
					  }
		}

				   if(!IsNumber)
				   {
				   alert("This field accept numeric value only");
				   sText.select();
				   sText.focus();
				   }
				
   
} 
 
function validateOrder ()
{	
	
	var checkEmail       = onlineorder.emailaddress.value;
	var numericTelephone = document.onlineorder.telephone.value;
	var numericFax       = document.onlineorder.faxno.value;
	var numericMobile    = document.onlineorder.mobileno.value;
	var numericReq		 = document.onlineorder.reqno.value;
	var verification_code = document.onlineorder.txt_verification.value;
	//var category		 = document.getElementById("category");
	//alert (category);
	

	
	if (document.onlineorder.companyname.value=="")
		{
			alert("Please write down your company name.");
			document.onlineorder.companyname.focus();
		}
		
	else if (document.onlineorder.fullname.value=="")
		{
			alert("Please write your full name.");
			document.onlineorder.fullname.focus();
		}
		
	else if (document.onlineorder.street.value=="")
		{
			alert("Please write your street name.");
			document.onlineorder.street.focus();
		}
		
	else if (document.onlineorder.city.value=="")
		{
			alert("Please write your city name.");
			document.onlineorder.city.focus();
		}

	else if (document.onlineorder.zipcode.value=="")
		{
			alert("Please write your zip code.");
			document.onlineorder.zipcode.focus();
		}

	else if (document.onlineorder.country.value=="NULL")
		{
			alert("Please choose your country.");
			document.onlineorder.country.focus();
		}

	else if ((document.onlineorder.telephone.value=="") && (document.onlineorder.mobileno.value==""))
		{
			alert("Please write your telephone number or mobile number.");
			document.onlineorder.telephone.focus();
		}
		
	else if (!IsNumeric(numericTelephone))
		{
			alert("Please enter valid telephone no");
			document.onlineorder.telephone.select();
		}
		



		
	else if (!IsNumeric(numericMobile))
		{
			alert("Please enter valid mobile no");
			document.onlineorder.mobileno.select();
		}
		
	else if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
		{
			alert("You have entered an invalid email address.")
			document.onlineorder.emailaddress.select();
			document.onlineorder.emailaddress.focus();
		} 
		
	
	else if (document.onlineorder.category.value=="NULL")
		{
			alert("Please select at least one category."); 
			document.onlineorder.category.focus();
		}
		
	else if (document.onlineorder.reqno.value=="")
		{
			alert("Please fill the required number.");
			document.onlineorder.reqno.focus();
		}
/*
	else if (!IsNumeric(numericReq))
		{
			alert("Please enter number");
			document.onlineorder.reqno.select();
		}
			*/		
		else if( (!IsNumeric(verification_code))  || (verification_code.length>6) || (verification_code==""))
		{
			alert("Please type validation code");
			document.onlineorder.txt_verification.focus();
		}
	else
		{
			if(document.onlineorder.attached.value=="")
			strconfirm=confirm('You are about to place new order. [ with NO Attachement]\nPress OK to continue>>');
			else
			strconfirm=confirm('You are about to place new order. [ with Attachement]\nPress OK to continue>>');
			if(strconfirm)
			document.onlineorder.submit();
			else
			return false;
		}
}