//create file by fevan 2008-08-15
window._isIE = (navigator.appName == "Microsoft Internet Explorer");
if(window._isIE) {
	if(navigator.userAgent.indexOf("Opera")>-1) window._isIE = null;
	if(navigator.userAgent.indexOf("Windows NT 6.0")>-1) window._isVista = true;
	else window._isVista = false;
}
else {
	if(navigator.userAgent.indexOf("Gecko")==-1) window._isIE = null;
}
function $(_sId){
	return document.getElementById(_sId) || document.getElementsByName(_sId)[0] || "";
}
function $C(_cTag){
	return document.createElement(_cTag)
}
function create_xmlhttp(){
	var a=null;try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{a=
	new ActiveXObject("Microsoft.XMLHTTP")}catch(c){a=null}}if(!a&&typeof XMLHttpRequest!="undefined")a=new XMLHttpRequest;
	return a;
}
String.prototype.trim = function(){
	return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
//去除左空格
String.prototype.lTrim = function(){
    return this.replace(/(^[\s]*)/g, "");
}
//去除右空格
String.prototype.rTrim = function(){
    return this.replace(/([\s]*$)/g, "");
}
//Url地址验证
String.prototype.isUrl = function(){
	var pattern = /^(http(s)?:\/\/)?[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
	return pattern.test(this);
}
//Http验证
String.prototype.isHttp = function(){
	var pattern = /^(([A-Za-z0-9]+.)|([A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9].))+[A-Za-z]{2,6}$/;
	//var pattern = /^[A-Za-z0-9\-]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
	return pattern.test(this);
}
//手机验证
String.prototype.isMobile = function(){
	var pattern = /^(\+[0-9]{2}\.)?1[358]{1}\d{9}$/;
	return pattern.test(this);
}
//传真
String.prototype.isFax = function(){
	var pattern = /^(\+[0-9]{2}\.)?[0]?\d{10}$/;
	return pattern.test(this);
}
//固定电话
String.prototype.isVoice = function(){
	var pattern = /^0[1-9]{2,3}\-\d{7,8}$/;
	return pattern.test(this);
}
//电子邮件验证
String.prototype.isEmail = function()
{
	var pattern = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	return pattern.test(this);
}
//域名检查
String.prototype.isDomain = function(){
	var pattern = /^(([a-z0-9]+)|([a-z0-9][a-z0-9-]+))+(\.[a-z]{2,})?\.[a-z]{2,6}$/;
	//	/^(([a-z0-9]+.)|([a-z0-9][a-z0-9-]+[a-z0-9].))+[a-z]{2,6}$/;
	return pattern.test(this);
}
//日期验证
String.prototype.isDateTime = function(){
	var pattern = /^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/;
	return pattern.test(this);
}
String.prototype.isDate = function(){
	var pattern = /^\d{4}\-[0-1][0-9]\-[0-3][0-9]$/;
	return pattern.test(this);
}
//整数验证
String.prototype.isInteger = function(){
	var pattern = /^[-\+]?\d+$/;
	return pattern.test(this);
}
//数字验证
String.prototype.isNumber = function(){
	return !isNaN(this);
}
//验证是否为空
String.prototype.isNullOrEmpty = function(){
	if(typeof(this)==undefined || this=="") return true;
	var tempStr = this.trim();
	return tempStr=="";
}
//中文验证
String.prototype.isChineseChar = function (){
	var pattern = /^[\u4e00-\u9fa5]/;
	return pattern.test(this);
}
//是否为合法用户标识 字母数字或下划线 (首字母必须为英文字母,最少六位,最多16位)
String.prototype.isLegalIdentityInput4to16 = function (){
	var pattern = /^\w{4,16}$/;
	return pattern.test(this);
}
String.prototype.isLegalIdentityInput6to16 = function (){
	var pattern = /^\w{6,16}$/;
	return pattern.test(this);
}
//英文验证
String.prototype.isEnglishChar = function (){
	var pattern = /^[a-zA-Z0-9_]{0,}$/;
	return pattern.test(this);
}
//身份证
String.prototype.isIDCard = function (){
	var pattern = /^\d{14}(\d{1}|\d{4}|(\d{3}[xy]))$/;
	return pattern.test(this);
}
//营业执照号码
String.prototype.isBusinessNumber = function (){
	var pattern = /^\d{13,15}$/;
	return pattern.test(this);
}
String.prototype.isphoneNum = function (){
	var pattern =/^([0-9]{3}-?[0-9]{8})|([0-9]{4}-?[0-9]{7})$/;
	return pattern.test(this);
}
//IP地址验证
String.prototype.isIP = function (){
	var pattern =/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.([1-9][0-9]?|1\d\d|2[0-4]\d|25[0-4])$/;
	return pattern.test(this);
}
//表单验证类(String扩展类) end//
