//This js include some util functions that we used every once in a while
function killErrors() 
{ 
return true; 
} 
window.onerror = killErrors; 
//change the date var to the formate of 'yyyy-mm-dd'
function formatDate(date){
	var yy = date.getFullYear();
	var mm = date.getMonth()+1<10?'0'+(date.getMonth()+1):(date.getMonth()+1) ;
	var dd = date.getDate()+1<10?'0'+(date.getDate()):date.getDate();
	return date.getFullYear()+"-"+mm+"-"+dd;
}

	//---------------------- global function ----------------
	function parseString(a) { 
		return ""+a;
	} 

	function isAlien(a) {
	  return isObject(a) && typeof a.constructor != 'function';
	} 
	 
	
	function isArray(a) {
	  return isObject(a) && a.constructor == Array;
	}
	
	function isBoolean(a) {
	  return typeof a == 'boolean';
	}
	
	function isEmpty(o) {
	  var i, v;
	  if (isObject(o)) {
		for (i in o) {
		  v = o[i];
		  if (isUndefined(v) && isFunction(v)) {
			return false;
		  }
		}
	  }
	  return true;
	}
	
	function isFunction(a) {
	  return typeof a == 'function';
	}
	
	function isNumber(a) {
	  return typeof a == 'number' && isFinite(a);
	}
	
	function isObject(a) {
	  return (a && typeof a == 'object') || isFunction(a);
	}
	
	function isString(a) {
	  return typeof a == 'string';
	}
	
	function isUndefined(a) {
	  return typeof a == 'undefined';
	}
	
	function isNull(a) {
	  return ("null" == ""+a) || ("undefined" == ""+a);
	}
	
	
		function GetFormObjectName(formObject) {
		for(var i = 0; i < document.forms.length; i++) {
			if(document.forms[i] == formObject) {
				return formObject.name ;
			}
		}
	}
	
	// 只能输入数字，onKeyUp="javascript:After(this);"
	function After(textObject) {
		if(textObject != null) {
			try {
				var textValue = "" ;
				textValue = textObject.value ;
				var NumberString = "0123456789." ;
				var intNo ; 
					
				intNo = 0 ;
					
				for(var i = 0; i < textValue.length; i++) { // loop all character
					if(NumberString.indexOf(textValue.substring(i, i+1)) == -1) {
						break ;
					}
					intNo = i+1 ;
				}
				if(intNo == 0) { // set value = "" if value is "0"
					textValue = "" ;
				} else {
					textValue = textValue.substring(0, intNo) ;
				}
				/*
				intNo = 0 ;
				for(var i = 0; i < textValue.length; i++) {
					if(textValue.substring(i, i+1) != "0") {
						intNo = i+1 ;
						break;
					}
				}
				if(intNo == 0) {
					textValue = "" ;
				} else {
					textValue = textValue.substring(intNo-1, textValue.length) ;
				}
				*/
				textObject.value = textValue ;
			} catch(e){}
		}
	}
	
	//字数限制,usage: onkeyup=limitWord(this,100,spanId,'prompt','prompt_2') ;
	function limitWord(object,limitNo,spanAlertId,normalClassName,alertClassName){
		if(object.value.length>limitNo)	{
			document.getElementById(spanAlertId+'').className=alertClassName ;
			object.value = object.value.substring(0,limitNo) ;
		}else{
			document.getElementById(spanAlertId).className=normalClassName ;	
		}
	}
	


