//*******************************************
//   default classes for infobox
//*******************************************	
	var infoboxSuccessClass = "notesuccess"
	var infoboxOkClass		= "notetrue";
	var infoboxWarningClass	= "notewarning";
	var infoboxErrorClass	= "noteawoke";
	var infoboxHintClass	= "note";
	var iTimerID	= null;        				//这个变量是作定时器的ID	
	var theUniqueID=0;
//*******************************************
//   公共函数
//*******************************************	

	String.prototype.trim = function()
	{
		return this.replace(/(^\s*)|(\s*$)/g, "");
	}
	
	//获取指定id的object
	function getObj() { 	
		var elements = new Array();
		for (var i = 0; i < arguments.length; i++){
			var element = arguments[i];
			if (typeof element == 'string')	element = document.getElementById(element);		
			if (arguments.length == 1)return element;		
			elements.push(element);
		}
		return elements;
	}
	
	//获取指定id的页面元素的值
	function getObjValue(elementId){
		if(getObj(elementId).value!="undefined")
			return getObj(elementId).value.trim();
		else
			return "";
	}
	
	
	 
	function showConfirm(msg){
		document.getElementById("massage_box").style.visibility='visible';	
		document.getElementById("message").innerHTML=msg;
	}
	
	function showErrTip(tipId,errMsg){
		getObj(tipId).innerHTML=errMsg;
		getObj(tipId).className="noteawoke";	
	}
	
	function hiddErrTip(tipId,errMsg){
		getObj(tipId).innerHTML=errMsg;
		getObj(tipId).className="";		
	}
	
	function showRightTip(tipId,errMsg){
		getObj(tipId).innerHTML=errMsg;
		getObj(tipId).className="notetrue";	
	}
	
	//复制文字
	function CopyText(obj){
		var rng = document.body.createTextRange()
		rng.moveToElementText(obj)
		rng.scrollIntoView()
		rng.select()
		rng.execCommand("Copy")
		rng.collapse(false)
	}
	
	function showStatus(obj,stat,msg)
	{
		switch(stat){
			case "success":
				getObj(obj).className = infoboxSuccessClass;
				break;
			case "Warning":
				getObj(obj).className = infoboxWarningClass;
				break;
			case "Error":
				getObj(obj).className = infoboxErrorClass;
				break;
			case "Ok":
				getObj(obj).className = infoboxOkClass;
				break;
			case "Normal":
				getObj(obj).className = infoboxHintClass;
				break;
			default:
				getObj(obj).className = "";
				break;
		}
		getObj(obj).innerHTML=msg;
	}

	
	function getManage(url){
		loadPage(url,"managearea");	
	}
	
	function imfei(){
		if(!checkEmpty("serial","编号"))return false;
	
		return true;
	}
	
	function checkEmpty(obj,msg){
		var str=getObjValue(obj);
		if(str==""){
			alert(msg+"不能为空!");
			return false;
		}
		return true;
	}
	
	//得到信息提示ID
	function getInfobox(obj){
		if(obj.id){
		 return (obj.id + "_info");
		}
		return;
	}	
	
	function checkByteLength(str,minlen,maxlen) {
		if (str == null) return false;
		var l = str.length;
		var blen = 0;
		for(i=0; i<l; i++) {
			if ((str.charCodeAt(i) & 0xff00) != 0) {
				blen ++;
			}
			blen ++;
		}
		if (blen > maxlen || blen < minlen) {
			return false;
		}
		return true;
	}
	function isNumberContinue(str){
		var patn1 =   /^[0-9_]+$/;
		var ascendNumber=0;
		var descendNumber=0;
		
		for (var i = 1; i < str.length; i++) {
			if (str.charAt(i).charCodeAt() != (str.charAt(i-1).charCodeAt() + 1)) {
				ascendNumber = 1;
				break;
			}
		}	
		
		for (i = 0; i < (str.length - 1); i++) {
			if (str.charAt(i).charCodeAt() != (str.charAt(i+1).charCodeAt() + 1)) {
				descendNumber = 1;
				break;
			}
		}
		if(descendNumber == 0 || ascendNumber == 0){
			return 1;
		}else{
			return 0;
		}
	}
	
	function isSameLetter(str){
		var sameNumberFlag = 1;
		var patn1 =   /^[0-9]+$/;
		if(patn1.test(str) ){
			for (var i = 0; i < str.length; i++) {
			  if (str.charAt(0) != str.charAt(i)) {
				  sameNumberFlag = 0;
				  break;
			  }
			}          
		} else {
			for (var i = 0; i < str.length; i++) {
				if (str.charAt(0) != str.charAt(i)) {
					sameNumberFlag = 0;
					break;
				}
			}
		}
		return sameNumberFlag;
	}
	function isOnlyDigitOrChar(str) {
		var digit = /^\d+$/;
		var words  = /^[a-zA-Z]+$/;
		if(digit.test(str) || words.test(str)) {
			return 1;
		}else {
			return 0;
		}	
	}	
	
	function showWH(self){
			var imgobj=new Image();
			imgobj.src=self.src;
			var w=imgobj.width + "px";
			var h=imgobj.height + "px";
			//self.style.width=w;
			//self.style.height=h;
			var id =self.id.replace("imgs","")
			document.getElementById("imgb"+id).innerHTML="<img src='" + self.src + "' height='" + h + " width='" + w + "'>"
	}
	
	function showGD(self1){
		//self1.style.width="90px";
		//self1.style.height="90px";
			var id =self1.id.replace("imgs","")
			document.getElementById("imgb"+id).innerHTML=""	
	}	
	
	function submiting(formId,callback){
			var strAction=document.getElementById(formId).action
			if(strAction.indexOf('?')!=-1){
				strAction=strAction.substring(0,strAction.indexOf('?'))
			}		
			theUniqueID= (new Date()).getTime() % 1000000000;			
			document.getElementById(formId).action =strAction + "?ProgressID=" + theUniqueID;  //处理提交数据的文件路径
			document.getElementById(formId).submit();//提交表单	
			ProgressBar(); 
//			showTipInfo("","submit");
//			eval(callback)
	}
	
	
	function ProgressBar(){
			if (iTimerID != null)
					clearTimeout(iTimerID)
		sURL ="inc/upload/Progress_Json.asp?ProgressID=" + theUniqueID //获取上传状态数据的地址
		sendPage4UDF("",sURL,fnLoadComplete)
	}

	function fnLoadComplete(oXML){
		var sResult = oXML.responseText;     //获取返回xml数据的根节点
		eval("var oJson=" + sResult)
		if(oJson!=null){
			if (oJson.ErrorMessage== ''){
				var readyState = oJson.ReadyState
				alert(readyState)
				// 如果还没初始化完成，继续
				if ( readyState == "uninitialized" ){
					iTimerID = setTimeout("ProgressBar()",5); 
				}
				// 上传进行中
				else if ( readyState == "loading" ){ //文件上传结束就取消定时器
					//这里设定时间间隔是0.5秒，你也可以根据你的情况修改获取数据时间间隔
					iTimerID = setTimeout("ProgressBar()",5); 
					showTipInfo("","submit");
				}
				// 上传结束
				else if ( readyState == "loaded" ){
					if (iTimerID != null)
						clearTimeout(iTimerID)
					iTimerID = null;	
					//alert("上传结束，服务器处理中...");
					//eval(callback)
				}
				// 上传结束
				else{
					if (iTimerID != null)
						clearTimeout(iTimerID)
					iTimerID = null;	
					alert("上传结束");
					//eval(callback)
				}
			}
			//出错
			else{
				alert("11")
				document.getElementById('upload').src= "about:blank";
				alert(oJson.ErrorMessage)
				if (iTimerID != null)
						clearTimeout(iTimerID)
				iTimerID = null;
			}
		}
	}
	
	<!-- 
//图片按比例缩放 
//var flag=false; 
function changeImg(ImgD,iwidth,iheight){ 
 var image=new Image(); 
// var iwidth = 200;  //定义允许图片宽度 
// var iheight =200;  //定义允许图片高度 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
// flag=true; 
 if(image.width/image.height>= iwidth/iheight){ 
  if(image.width>iwidth){   
  ImgD.width=iwidth; 
  ImgD.height=(image.height*iwidth)/image.width; 
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
//  ImgD.alt=image.width+"×"+image.height; 
  } 
 else{ 
  if(image.height>iheight){   
  ImgD.height=iheight; 
  ImgD.width=(image.width*iheight)/image.height;   
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
//  ImgD.alt=image.width+"×"+image.height; 
  } 
 } 
}  
//--> 

////此脚本为像QQ上线的冒泡提示调用方法：popmsg("消息内容")==================================================
//
//var PopWidth=150; //信息框宽度
//var PopHeight=80; //信息框高度
//var PopBorder=25; //距屏幕边缘的距离
//var PopShow=2000; //信息框的显示时间
//var PopTop=0;
//var showtime,hidetime;
//var oPopup=window.createPopup();
//function popmsg(msgstr){
//	oPopup.document.body.innerHTML='<table style="border:#84B9F4 solid 1px"  width="'+PopWidth+
//	'"height="'+PopHeight+'" cellpadding="0" cellspacing="0" bgcolor="#CFEEFA">'+'<tr><td valign="top">' +msgstr+'</td></tr></table>';   //信息框的样式
//	popshow();
//	oPopup.document.body.onclick = pophide; //单击信息框时开始隐藏
//}
//function popshow(){
//	//信息框显示程序
//	var tmpHeight=PopTop<PopHeight?PopTop:PopHeight;//当不足以显示信息框全部时，缩小信息框高度
//	oPopup.show(screen.width - (PopWidth + PopBorder),screen.height-PopTop,PopWidth,tmpHeight);
//	//信息框定位，screen.width：屏幕宽度、screen.height：屏幕高度
//	if (PopTop < (PopHeight + PopBorder)){
//		PopTop = PopTop + 10; //信息框位置递增
//	} 
//	else 
//	{
//		setTimeout("pophide();", PopShow); //准备隐藏信息框
//	}
//	showtime = setTimeout("popshow();",100);
//}
//
//function pophide(){
//	//信息框隐藏程序
//	if (showtime) {
//		clearTimeout(showtime); //清除显示时间句柄
//	}
//	var tmpHeight=PopTop<PopHeight?PopTop:PopHeight;
//	oPopup.show(screen.width-(PopWidth+PopBorder),screen.height-PopTop,PopWidth, 
//	tmpHeight);
//	if (PopTop>0){
//	PopTop=PopTop-10;
//	hidetime=setTimeout("pophide();",100);
//	} 
//	else 
//	{
//		clearTimeout(hidetime);
//		oPopup.hide(); //完全隐藏信息框
//	}
//}
//========================冒泡提示结束

function $(objID) {
  return document.getElementById(objID)
}

/*使用时仍要这样调用$(objid)
function $() {
  return document.getElementById(arguments[0])
}
*/

function $F(objID,html){
	$(objID).innerHTML=html;
}

function $FJ(objID,html){
	$(objID).innerHTML+=html;
}

//改变样式名称
function $CN(objID,objClassName){
 $(objID).className=objClassName;
}

//改变样式objstyle="none"是为不显示  objstyle="block"时为显示
function $CS(objID,objStyle)
{
 $(objID).style.display=objStyle;
}
