function allspace(instring)
{
	var checkchar="0";
	
	for (i=0; i<instring.length; i++)
	{
	var temp=instring.charAt(i);
	if (temp != " ")
	{
	checkchar="1";
	}
	}
	
	if (checkchar == "0")
	return true;
	
	else
	return false;
}

function out_of_stock()
{
	alert("Sorry! This product is out of stock!")
}

function CheckDate(InString)
{
  var checkOK = "0123456789/";
  var checkStr = InString;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
 }

  if (!allValid)
  {
    return true;
  }
}

function call_login()
{
	alert("Please login First")
}

function type_invalid()
{
	alert("For Full Members Only")
}

function detect_chi()
{
	support_chi=("¤¤".length==1)
	
	if (support_chi == 1)
	return true
	
	else
	return false
}

function isEmpty(InString)
{
  if (InString == null || InString == "")
  {
    return true
  }
  return false
}


function CheckNum(InString)
{
  var checkOK = "0123456789";
  var checkStr = InString;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
 }

  if (!allValid)
  {
    return true;
  }
}

function CheckEmail(InString)
{ 
  if ((InString.indexOf("@") != -1) && (InString.indexOf(".") != -1))
    return false
 else
   return true
}


function CheckTel(InString)
{
  var checkOK = "0123456789-() ";
  var checkStr = InString;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
 }

  if (!allValid)
  {
    return true;
  }
}



function FieldChecking(theForm)
{
<!-- check name  -->
  var radio_selection="";
  if (isEmpty(theForm.first.value))
  {
    alert("Name field error, Please input again");
    theForm.first.focus();
    return (false);
  }

	if ((CheckEmail(theForm.email.value)) || (isEmpty(theForm.email.value)))
	{
	  alert("Email field error, Please input again");
   	  theForm.email.focus()		
	  return false
 	}

<!-- check address  -->
  if (isEmpty(theForm.add.value))
  {
    alert("Addressl error, Please input again");
    theForm.add.focus();
    return (false);
  }


<!-- check zip  -->
  var checkOK4 = "0123456789- ";
  var checkStr4 = theForm.zip.value;
  var allValid4 = true;
  for (i = 0;  i < checkStr4.length;  i++)
  {
    ch = checkStr4.charAt(i);
    for (j = 0;  j < checkOK4.length;  j++)
      if (ch == checkOK4.charAt(j))
        break;
    if (j == checkOK4.length)
    {
      allValid4 = false;
      break;
    }
 }

  if (!allValid4)
  {
    if (!theForm.zip.value=="")
	{
	    alert("Please enter only digit characters in the Zip field.");
	    theForm.zip.focus();
  	    return (false);
	}
   else
   	 return (true);
  }

<!-- check telephone  -->
 if ((CheckTel(theForm.tel.value)) || (isEmpty(theForm.tel.value)))
 {
    alert("Telephone Number error, Please input again");
    theForm.tel.focus();
    return (false);
  }

<!-- Check  delivery information -->

<!-- check zip  -->
  var del_checkOK4 = "0123456789- ";
  var del_checkStr4 = theForm.delivery_zip.value;
  var del_allValid4 = true;
  for (i = 0;  i < del_checkStr4.length;  i++)
  {
    ch = del_checkStr4.charAt(i);
    for (j = 0;  j < del_checkOK4.length;  j++)
      if (ch == del_checkOK4.charAt(j))
        break;
    if (j == del_checkOK4.length)
    {
      del_allValid4 = false;
      break;
    }
 }

  if (!del_allValid4)
  {
    if (!theForm.delivery_zip.value=="")
	{
	    alert("Please enter only digit characters in the Zip field.");
	    theForm.delivery_zip.focus();
  	    return (false);
	}
   else 
	   return (true);
  }

<!-- check telephone  -->
  var del_checkOK = "0123456789- ";
  var del_checkStr = theForm.delivery_tel.value;
  var del_allValid = true;
  for (i = 0;  i < del_checkStr.length;  i++)
  {
    ch = del_checkStr.charAt(i);
    for (j = 0;  j < del_checkOK.length;  j++)
      if (ch == del_checkOK.charAt(j))
        break;
    if (j == del_checkOK.length)
    {
      del_allValid = false;
      break;
    }
 }

  if (!del_allValid)
  {
    if (!theForm.delivery_tel.value=="")
	{
	    alert("Telephone Number error, Please input again");
	    theForm.delivery_tel.focus();
  	    return (false);
	}
  else
  	  return (true);
  }
  


<!--  check if any delivery info has been filled -->
  if (theForm.delivery_first.value !="" )
  {
        if (theForm.delivery_tel.value =="")	  
	{
	    alert("Telephone Number error, Please input again");
	    theForm.delivery_tel.focus();
	    return (false);
	}
       
        if (theForm.delivery_add.value =="" )
  	{
	    alert("Address error, Please input again");
	    theForm.delivery_add.focus();
	    return (false);
	}
  }

  if (theForm.delivery_tel.value !="" )
  {
        if (theForm.delivery_first.value =="")	  
	{
	   alert("Name error, Please input again");
	    theForm.delivery_first.focus();
	    return (false);
	}

        if (theForm.delivery_add.value =="" )
	  {
  	   alert("Address error, Please input again");
	    theForm.delivery_add.focus();
	    return (false);
	}
  }

  if (theForm.delivery_add.value !="" )
  {
        if (theForm.delivery_tel.value =="")	  
	{
	    alert("Telephone Number error, Please input again");
	    theForm.delivery_tel.focus();
	    return (false);
	}

        if (theForm.delivery_first.value =="" )
	  {
	   alert("Name error, Please input again");
	    theForm.delivery_first.focus();
	    return (false);
	}
  }
}
