s = '<div class="consult border">';
s +=	'<h5>快速咨询</h5>';
s +=	'<form name="" action="" method="post" id="consultForm">';
s +=		'<input type="input" name="username" size="14" value="称呼"  class="consultUserName"/>';
s +=		'<select name="sex" class="consultSex"><option value="1">先生</option><option value="0">女士</option></select>';
s +=		'<input type="input" class="consultList" name="phone" size="14" value="电话" />';
s +=		'<input type="text" class="consultList" name="email"  size="14" value="邮箱" />';
s +=		'<select name="category" class="consultList">{category}</select>';
s +=		'<textarea name="content" rows="5" class="consultList" >问题</textarea>';
s +=		'<input type="button" name="submitconsult" class="consultList" value="提交" />';
s +='	</form>';
s +='</div>';
aCategory = Array('注册香港公司','注册海外离岸公司','会计服务','商标注册','银行开户','商务秘书服务','贸易咨询','意见和建议','其它');
sOptionTemplate = '<option value="{sValue}">{sText}</option>';
iLen = aCategory.length;
s1 = '';
for(var i=0;i<iLen;i++){
	s1 += sOptionTemplate.replace(/{sValue}|{sText}/g,aCategory[i]);
}
s = s.replace('{category}',s1);

document.write(s);

bPass = false;

var oValidator={
	isEmail:function(s){
		if(!s) return false;
		var oRe = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/gi;
		return this.test(s,oRe);
	},
	isPhone:function(s){
		if(!s) return false;
		var oRe = /(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/gi
		return this.test(s,oRe);
	},
	test:function(s,sPattern){
		if(!sPattern) return false;
		return sPattern.test(s);
	}
};
String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*)$/g,'');};

$('consultForm').submitconsult.onclick=function(){
	bPass = true;
	fnChangeAlarm($('consultForm').username,true);
	fnChangeAlarm($('consultForm').phone,true);
	fnChangeAlarm($('consultForm').email,true);
	fnChangeAlarm($('consultForm').content,true);

	if($('consultForm').username.value=='' || $('consultForm').username.value == '称呼' || $('consultForm').username.value == '称呼不能为空'){
		$('consultForm').username.value = '称呼不能为空';
		fnChangeAlarm($('consultForm').username,false);
		bPass = false;
	}
	if($('consultForm').phone.value=='' || $('consultForm').phone.value == '电话' || $('consultForm').phone.value == '电话不正确'){
		$('consultForm').phone.value ='电话不正确';
		fnChangeAlarm($('consultForm').phone,false);
		bPass = false;
	}else if(!oValidator.isPhone($('consultForm').phone.value)){
//		$('consultForm').phone.value ='电话不正确';
		fnChangeAlarm($('consultForm').phone,false);
		bPass = false;
	}
	if($('consultForm').email.value=='' || $('consultForm').email.value == '邮箱' || $('consultForm').email.value == '邮箱格式不正确'){
		$('consultForm').email.value ='邮箱格式不正确';
		fnChangeAlarm($('consultForm').email,false);
		bPass = false;
	}else if(!oValidator.isEmail($('consultForm').email.value)){
		fnChangeAlarm($('consultForm').email,false);
		bPass = false;
	}
	if($('consultForm').content.value=='' || $('consultForm').content.value == '问题' || $('consultForm').content.value == '问题不能为空'){
		$('consultForm').content.value ='问题不能为空';
		fnChangeAlarm($('consultForm').content,false);
		bPass = false;
	}
	if(bPass){
		$('consultForm').action='/consult/consult.php';
		$('consultForm').submit();
	}
};
$('consultForm').username.onclick=function(){if(this.value=='称呼不能为空'||this.value=='称呼') this.value = '';};
$('consultForm').username.onblur=function(){this.value = this.value.trim();if(this.value==''&&!bPass){this.value = '称呼不能为空'; fnChangeAlarm(this,false);}else if(this.value != '称呼不能为空' && this.value != '称呼' ) fnChangeAlarm(this,true);};
$('consultForm').phone.onclick=function(){if(this.value=='电话不正确'||this.value=='电话') this.value = '';};
$('consultForm').phone.onblur=function(){this.value = this.value.trim();if(this.value==''&&!bPass){this.value = '电话不正确';  fnChangeAlarm(this,false);}else if(oValidator.isPhone(this.value)){fnChangeAlarm(this,true);}else{fnChangeAlarm(this,false);}};
$('consultForm').email.onclick=function(){if(this.value=='邮箱格式不正确'||this.value=='邮箱') this.value = '';};
$('consultForm').email.onblur=function(){this.value = this.value.trim();if(this.value==''&&!bPass){this.value = '邮箱格式不正确'; fnChangeAlarm(this,false);} else if(oValidator.isEmail(this.value)){fnChangeAlarm(this,true);}else{fnChangeAlarm(this,false);}};
$('consultForm').content.onclick=function(){if(this.value=='问题不能为空'||this.value=='问题') this.value = '';};
$('consultForm').content.onblur=function(){this.value = this.value.trim();if(this.value==''&&!bPass){this.value = '问题不能为空'; fnChangeAlarm(this,false);} else fnChangeAlarm(this,true);};

function fnChangeAlarm(o,TrueError){
	if(TrueError){
		fnChangeTrue(o);
	}else{
		fnChangeError(o);
	}
}

function fnChangeTrue(o){
	if(!o) return;
//	o.style.borderColor = '#808080';
	o.style.background = 'url("/images/true.gif") 96% center no-repeat';	
}
function fnChangeError(o){
	if(!o) return;
//	o.style.borderColor = '#be0000';
	o.style.background = 'url("/images/error1.gif") 96% center no-repeat';
}


//var Http = new Object;
//Http.bXmlHttpSupport = function(return(typeof(XMLHttpRequest=='object' || window.ActiveXObject)););
//Http.XMLHttpRequest()=function(
//	if(this.bXmlHttpSupport){
//		var aSignatures = ['MSXML2.XMLHTTP.5.0','MXSML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
//		for(var i =0;i<aSignatures.length;i++){
//			try{
//				return(new ActiveXObject(aSignatures[i]));
//			}catch(oError){
//				//
//				throw new Error('MSXML is not installed on ypur system.');
//			}
//		}
//	}
//);
//Http.addParam=function(sUrl,sParamName,sValue){
//	return sParams=sUrl+sUrl.indexOf('?')==-1?'?':'&'+encodeURIComponent(sParamName)+'='+encodeURIComponent(sValue);
//}
//Http.post=function(sUrl,sParams,fnCallBack){
//	if(this.bXmlHttpSupport){
//		var oRequest = new XMLHttpRequest();
//		oRequest.open('post',sUrl,true);
//		oRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//		oRequest.onreadystatechange = function(){
//			if(oRequest.readyState == 4){
//				fnCallback(oRequest.responseText);
//			}
//		}
//		oRequest.send(sParams);
//	}else{
//		// your browerss doesn,t support HTTP requests.
//	}
//}


