function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}

function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function regMatch(obj,reg)
	{
	  obj.value=reg.test(obj.value)? obj.value.match(reg,obj.value):'0';
	}

//reg.asp

function regjs()
{
   if(checkspace(document.reginfo.username.value)) {
	document.reginfo.username.focus();
    alert("Sorry Please Confirm your username is correct!");
	return false;
  }
 
    if(checkspace(document.reginfo.username.value) || document.reginfo.username.value.length < 4) {
	document.reginfo.username.focus();
    alert("Sorry Please Confirm your username is correct!");
	return false;
  }
    if(checkspace(document.reginfo.password.value) || document.reginfo.password.value.length < 6) {
	document.reginfo.password.focus();
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }
    if(document.reginfo.password.value != document.reginfo.password1.value) {
	document.reginfo.password.focus();
	document.reginfo.password.value = '';
	document.reginfo.password1.value = '';
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }

 if(checkspace(document.reginfo.question.value)) {
	document.reginfo.question.focus();
    alert("Sorry Please Confirm your question is correct!");
	return false;
  }
  
  if(checkspace(document.reginfo.answer.value)) {
	document.reginfo.answer.focus();
    alert("Sorry Please Confirm your Answer is correct!");
	return false;
  }

if(checkspace(document.reginfo.firstname.value)) {
	document.reginfo.firstname.focus();
    alert("Sorry Please Confirm your firstname is correct!");
	return false;
  }
  if(checkspace(document.reginfo.lastname.value)) {
	document.reginfo.lastname.focus();
    alert("Sorry Please Confirm your lastname is correct!");
	return false;
  }

if(document.reginfo.email.value.length!=0)
  {
    if (document.reginfo.email.value.charAt(0)=="." ||        
         document.reginfo.email.value.charAt(0)=="@"||       
         document.reginfo.email.value.indexOf('@', 0) == -1 || 
         document.reginfo.email.value.indexOf('.', 0) == -1 || 
         document.reginfo.email.value.lastIndexOf("@")==document.reginfo.email.value.length-1 || 
         document.reginfo.email.value.lastIndexOf(".")==document.reginfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.reginfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.reginfo.email.focus();
   return false;
   }
  
}

//feedback.asp
function feedbackjs()
{
   if(checkspace(document.finfo.name.value)) {
	document.finfo.name.focus();
    alert("Sorry Please Confirm your name is correct!");
	return false;
  }

if(document.finfo.email.value.length!=0)
  {
    if (document.finfo.email.value.charAt(0)=="." ||        
         document.finfo.email.value.charAt(0)=="@"||       
         document.finfo.email.value.indexOf('@', 0) == -1 || 
         document.finfo.email.value.indexOf('.', 0) == -1 || 
         document.finfo.email.value.lastIndexOf("@")==document.finfo.email.value.length-1 || 
         document.finfo.email.value.lastIndexOf(".")==document.finfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.finfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.finfo.email.focus();
   return false;
   }

if(checkspace(document.finfo.title.value)) {
	document.finfo.title.focus();
    alert("Sorry Please Confirm your title is correct!");
	return false;
  }

}

//step.asp
function stepjs()
{
if(checkspace(document.stepinfo.firstname.value)) {
	document.stepinfo.firstname.focus();
    alert("Sorry Please Confirm your firstname is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.lastname.value)) {
	document.stepinfo.lastname.focus();
    alert("Sorry Please Confirm your lastname is correct!");
	return false;
  }

if(document.stepinfo.email.value.length!=0)
  {
    if (document.stepinfo.email.value.charAt(0)=="." ||        
         document.stepinfo.email.value.charAt(0)=="@"||       
         document.stepinfo.email.value.indexOf('@', 0) == -1 || 
         document.stepinfo.email.value.indexOf('.', 0) == -1 || 
         document.stepinfo.email.value.lastIndexOf("@")==document.stepinfo.email.value.length-1 || 
         document.stepinfo.email.value.lastIndexOf(".")==document.stepinfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.stepinfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.stepinfo.email.focus();
   return false;
   }

if(checkspace(document.stepinfo.call.value)) {
	document.stepinfo.call.focus();
    alert("Sorry Please Confirm your call is correct!");
	return false;
  }
//  if(checkspace(document.stepinfo.contact.value)) {
//	document.stepinfo.contact.focus();
//    alert("Sorry Please Confirm your contact is correct!");
//	return false;
//  }
  if(checkspace(document.stepinfo.country.value)) {
	document.stepinfo.country.focus();
    alert("Sorry Please Confirm your country is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.province.value)) {
	document.stepinfo.province.focus();
    alert("Sorry Please Confirm your province is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.city.value)) {
	document.stepinfo.city.focus();
    alert("Sorry Please Confirm your city is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.address.value)) {
	document.stepinfo.address.focus();
    alert("Sorry Please Confirm your address is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.postcode.value)) {
	document.stepinfo.postcode.focus();
    alert("Sorry Please Confirm your postcode is correct!");
	return false;
  }
    if(document.stepinfo.remarks.value.length > 200 ) {
	document.stepinfo.remarks.focus();
    alert("Not more than 200 characters!");
	return false;
  }

}

function formpassjs()
{
    if(document.formpass.password.value != document.formpass.password1.value) {
	document.formpass.password.focus();
	document.formpass.password.value = '';
	document.formpass.password1.value = '';
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }
}

function forminfojs()
{
if(checkspace(document.forminfo.firstname.value)) {
	document.forminfo.firstname.focus();
    alert("Sorry Please Confirm your firstname is correct!");
	return false;
  }
  if(checkspace(document.forminfo.lastname.value)) {
	document.forminfo.lastname.focus();
    alert("Sorry Please Confirm your lastname is correct!");
	return false;
  }

if(document.forminfo.email.value.length!=0)
  {
    if (document.forminfo.email.value.charAt(0)=="." ||        
         document.forminfo.email.value.charAt(0)=="@"||       
         document.forminfo.email.value.indexOf('@', 0) == -1 || 
         document.forminfo.email.value.indexOf('.', 0) == -1 || 
         document.forminfo.email.value.lastIndexOf("@")==document.forminfo.email.value.length-1 || 
         document.forminfo.email.value.lastIndexOf(".")==document.forminfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.forminfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.forminfo.email.focus();
   return false;
   }
  
}

function messageaddjs()
{
   if(checkspace(document.messageadd.title.value)) {
	document.messageadd.title.focus();
    alert("Sorry Please Confirm your title is correct!");
	return false;
  }

   if(document.messageadd.content.value.length > 400 ) {
	document.messageadd.content.focus();
    alert("Not more than 400 characters!");
	return false;
  }
}

function getpassjs1()
{
	if(checkspace(document.formgetpass1.userid.value)) {
	document.formgetpass1.userid.focus();
    alert("Sorry Please Confirm your userid is correct!");
	return false;
  }

}
function getpassjs2()
{
	if(checkspace(document.formgetpass2.Answer.value)) {
	document.formgetpass2.Answer.focus();
    alert("Sorry Please Confirm your Answer is correct!");
	return false;
  }

}
function getpassjs3()
{
	if(checkspace(document.formgetpass3.password.value)) {
	document.formgetpass3.password.focus();
    alert("Sorry Please Confirm your password is correct!");
	return false;
  }
    if(document.formgetpass3.password.value != document.formgetpass3.password1.value) {
	document.formgetpass3.password.focus();
	document.formgetpass3.password.value = '';
	document.formgetpass3.password1.value = '';
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }

}

function addmailjs()
{
if(document.addmailinfo.email.value.length!=0)
  {
    if (document.addmailinfo.email.value.charAt(0)=="." ||        
         document.addmailinfo.email.value.charAt(0)=="@"||       
         document.addmailinfo.email.value.indexOf('@', 0) == -1 || 
         document.addmailinfo.email.value.indexOf('.', 0) == -1 || 
         document.addmailinfo.email.value.lastIndexOf("@")==document.addmailinfo.email.value.length-1 || 
         document.addmailinfo.email.value.lastIndexOf(".")==document.addmailinfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.addmailinfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.addmailinfo.email.focus();
   return false;
   }
}
function FormRequest(_method,_url,_async,_target){
	var oThis = this;
	var value = null;
	var text = null;
	
	var _form = document.getElementById("myAjaxRequestForm");
	if(_form){
		_form.removeNode(true);
	}
	
	_form = document.createElement("form");
	document.body.appendChild(_form);
	
	_form.method = _method;
	_form.action = _url;
	_form.target = _target;
	
	currentRequest = oThis;
	//input参数传递
	this.setParameter = function(name,value) {
		var _input = document.createElement("input");
		_input.name=name;
		_input.value=value;
		_input.type="hidden";
		_form.appendChild(_input);
	}
		
	//url参数传递
	this.send = function(v){
		if(v==null || v==""){
			_form.submit();

		}else{
			var parts = v.split('&');
			for(var i=0;i<parts.length;i++){
				var part = parts[i].split('=');
				var name = part[0];
				var value = part[1];
				var _input = document.createElement("input");
				_input.name=name;
				_input.value=value;
				_input.type="hidden";
				_form.appendChild(_input);
			}
			_form.submit();
		}
	}

}

function GoForm(url,querystring,_form)
{var r = new FormRequest("POST",url,false,_form);
if(_form=="" || _form==null){_form="_self";}
if(querystring.substring(0,1)=="?"){
querystring=querystring.substring(1,querystring.length);}
var tmpValues = querystring.split("&");
for(var i = 0; i < tmpValues.length; i++)
{
var tmpValue = tmpValues[i].split("=");
r.setParameter(tmpValue[0],tmpValue[1])
}
r.send("");}
function addFav() {
try{window.external.AddFavorite(window.location.protocol+'://'+window.location.host, document.title);return;}catch(e){}
try{window.sidebar.addPanel(document.title,window.location.protocol+'://'+window.location.host, "");return;}catch(e){}
try{window.external.AddFavorite(window.location.protocol+'://'+window.location.host, document.title);return;}catch(e){}
}
