/**
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to zhiming0824@163.com so we can send you a copy immediately.
 *
 * @copyright  Copyright (c) 2009-2012 Zhi Ming CN Inc.
 * @license    New BSD License
 * @lastBy     $LastChangedBy: zhiming $
 * @lastDate   $LastChangedDate: 2010-02-04 10:40:58 +0800 (周四, 04 二月 2010) $
 * @version    $Id: validate.func.js 307 2010-02-04 02:40:58Z zhiming $
 * @author     ZhiMing<zhiming0824@163.com> QQ:250484464
 */

(function ($){{
$.extend({
IsUndefined : function (domElement) {
return typeof domElement == 'undefined' ? true : false;
},
IsNull		: function (obj) {
return obj == null ? true : false;
},
IsSelected	: function (selectObj, sIndex) {
sIndex = $.IsUndefined(sIndex) ? 0 : parseInt(sIndex);
return selectObj.selectedIndex != sIndex ? true : false;
},
IsChecked	: function (nodeList) {
var vStatus = false, len = nodeList.length;
for(var i=0; i<len ;i++) {
if(nodeList[i].checked == true) {
vStatus = true;
}
}
return vStatus;
},
in_array	: function (needle, array) {
var status = false, arrayLen = array.length;
for(var i=0; i<arrayLen; i++) {
if(array[i] == needle) {
status = true;
break;
}
}
return status;
},
IsNumeric	: function (numeric) {
return /^\d+(\d*|\.\d+)$/.test(numeric);
},
IsTelephone	: function (string) {
return /^\d[\d\-]+\d$/.test(string);
},
IsEmpty		: function (string) {
return this.trim(string) ? false : true;
},
IsEmail		: function (string) {
return /^\w+@[\w.]+$/.test(string);
},
IsInteger	: function (numeric) {
return /^\d+$/.test(numeric);
},
strlen		: function (string){
	var charset, rstr = '';
	charset = (document.charset || document.characterSet).toLowerCase();
	if(charset == 'utf-8') {
		rstr = '***';
	} else if (charset.indexOf('gbk') != -1) {
		rstr = '**';
	}
	return string.replace(/[\u4e00-\u9fa5]/g, rstr).length;
}
});
}
})(jQuery)

