function CheckForm(theForm){
   var SearchKey = theForm.SearchKey.value;
   if(SearchKey == ""){
      alert("Please input search key!");
      theForm.SearchKey.focus();
      return  (false);
   }
}

var newWindow = null
function OpenWindow(htmurl,widths,heights)
{
   if (! newWindow || newWindow.closed)
   {
      var paramet = 'toolbar=no,resizable=no,scrollbars=no,width='+ widths + ',height=' + heights;
      newWindow = window.open(htmurl,"newWin",paramet);
   }
   else
   {
      newWindow.focus();
   }
}

function CheckData(theForm)
{
   var Name = theForm.Name.value;
   if (Name == "")
   {
      alert("Please input your name!");
      theForm.Name.focus();
      return (false);
   }

   var Tel = theForm.Tel.value;
   if (Tel != "")
   {
      var Tel_rule = "0123456789-";
	  if (!accord(Tel_rule,Tel)||Tel.length < 7)
	  {
         alert("Phone code error!");
         theForm.Tel.focus();
         return (false);
      }
   }

   var Message = theForm.Message.value;
   if (Message.length == "")
   {
      alert("Please input leave word.");
      theForm.Message.focus();
      return (false);
   }
   if (Message.length > 3500)
   {
      alert("Your message can't more than 3500 character.");
      theForm.Message.focus();
       return (false);
   }

   var radios = theForm.Portrait
   var radioItems = 0;
   for(var len= 0; len < radios.length; len++)
      if(radios[len].checked)
      {
         radioItems++;
      }
      if (radioItems == 0)
      {
         alert("Please choose head portrait!");
         theForm.Portrait[0].focus();
         return (false);
      }

   if ( confirm("Are you confirm submit?"))
   {
      return (true);
   }
   else
   {
      return (false);
   }

}

function accord(rule,datas)
{
   var checkOKpass = rule;
   var checkStrpass = datas;
   var allValidpass = true;
   for (i = 0;  i < checkStrpass.length;  i++)
   {
      ch = checkStrpass.charAt(i);
      for (j = 0;  j < checkOKpass.length;  j++)
         if (ch == checkOKpass.charAt(j))
         break;
         if (j == checkOKpass.length)
         {
            allValidpass = false;
            break;
         }
   }
   return allValidpass;
}

function debar(rule,datas) 
{
   var checkOKpass = rule;
   var checkStrpass = datas;
   for (i = 0; i < checkStrpass.length; i++)
   {
      ch = checkStrpass.charAt(i);
      for (j = 0; j < checkOKpass.length; j++)
	  {
         if (ch == checkOKpass.charAt(j)) 
			return true;
         if (j == checkOKpass.length)
            break; 
      }
   }
   return false;
}

function onlynumber(){
if (!((event.keyCode>44 && event.keyCode<58)))
   event.keyCode=0;
}