var d = new Date();
var dp = new Date(d.getTime() + 10);
document.write('<META HTTP-EQUIV="expires" CONTENT="' + dp + '">')
//处理回车默认提交按钮 begin。
var defaultSubmitButton ;
//不是IE浏览器。
var   _nonMSDOMBrowser   =   (window.navigator.appName.toLowerCase().indexOf('explorer')   ==   -1)? true:false;   
var   _defaultFired   =   false; 
// 获得事件Event对象，用于兼容IE和FireFox
function getEventObj() {
     return window.event || arguments.callee.caller.arguments[0];
}
//使对象获得焦点。
function ObjFocus(obj,isSelectAll)
{
    if(isSelectAll==true)
    {
        window.setTimeout( function(){ obj.focus();obj.select();}, 0); 
    }
    else
    {
        window.setTimeout( function(){ obj.focus();}, 0); 
    }
}
 document.onkeypress=ClickEnter ;
  function ClickEnter()
  {
      try
      {
        var eObj =getEventObj();
        if(_defaultFired 
            && getKeyCode(eObj)   ==   13 
            &&   !(eObj.srcElement   &&   (eObj.srcElement.tagName.toLowerCase()   ==   "textarea"))
          )   
        {  
           if   (defaultSubmitButton   &&   typeof(defaultSubmitButton.click)   !=   "undefined")   
           {     
                 //window.setTimeout("onButtonClick();",10);
                  defaultSubmitButton.click();   
                  eObj.cancelBubble   =   true;   
                  if   (eObj.stopPropagation)   eObj.stopPropagation();  
           }
        }
        
      }
      catch(ex)
      {
        alert(ex);
      }
}
function onButtonClick()
{
  defaultSubmitButton.click();   
}
//获得键盘按下的值，返回一数值。
function getKeyCode(e)
{
    var kCode ;
     if(_nonMSDOMBrowser)
     {
        kCode= e.which ;
     }
     else
     {
       kCode=event.keyCode;
     }
     return kCode ;
}
function setDefaultSubmitButton(buttonId)
{
    if(_nonMSDOMBrowser)   
    {   
        defaultSubmitButton   =   document.getElementById(buttonId);   
    }   
    else   
    {   //ie
        defaultSubmitButton   =   document.all[buttonId];   
    }   
   
    _defaultFired=true;
    
}

//处理回车默认提交按钮 end。


          
function mouseCoords(ev){
    try
    {
       if(ev.pageX || ev.pageY){
            return {x:ev.pageX, y:ev.pageY};
       }
       return {
            x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
            y:ev.clientY + document.body.scrollTop   - document.body.clientTop
       };
       }
       catch(e){}
}

function getpos(e)
{ 
    var t1 = e.offsetTop;
    var l1 = e.offsetLeft;
    var height = e.offsetHeight;
    while (e = e.offsetParent) 
    {
        t1 += e.offsetTop;
        l1 += e.offsetLeft;
    }
   return {t:t1,l:l1} ;
}

function mouseMove(ev){
       var ev = ev || window.event;
       var mousePos = mouseCoords(ev);
       var getS=getScroll() ;
       try
       { 
       
       var divId = document.getElementById("myRunting");
        divId.style.top = mousePos.y -20 + getS.t  ;
        divId.style.left= mousePos.x- 60 +getS.l;
       
       }
       catch(e){}
}
document.onmousemove = mouseMove;

 

function getScroll() 
 {     
    var t, l, w, h;          
    if (document.documentElement && document.documentElement.scrollTop) 
    {         
        t = document.documentElement.scrollTop;         
        l = document.documentElement.scrollLeft;         
        w = document.documentElement.scrollWidth;         
        h = document.documentElement.scrollHeight;     
    } 
    else if (document.body) 
    {         
        document.body.scrollLeft - document.body.clientLeft
        t = document.body.scrollTop;         
        l = document.body.scrollLeft +   document.body.clientLeft;         
        w = document.body.scrollWidth;         
        h = document.body.scrollHeight + document.body.clientTop;     
    }     
    return { t: t, l: l, w: w, h: h }; 
} 

//Page	面滚动
var currentpos,timer; 
function initialize() 
{
	timer = setInterval("scrollwindow()",5);
} 
function sc()
{
	clearInterval(timer);
}

function scrollwindow() 
{
	currentpos=document.body.scrollTop;
	window.scroll(0,++currentpos);
	if (currentpos != document.body.scrollTop) 
		sc();
} 

//document.onmousedown=sc
//document.ondblclick=initialize
//完
//显示Page	面List变化事件
var TableTrOnMouseOverClass="";
var TableTrCurrObject ;
function TableOnMouseOver(currTR)
{	TableTrCurrObject=currTR;
	TableTrOnMouseOverClass=currTR.className;
	currTR.className = "p_datagrid_select";
	
}

function TableOnMouseOut(currTR,className)
{
	if(currTR!=null)
	{	if(className!=null)
		{
			currTR.className=className ;
		}
		else
		{
			currTR.className=TableTrOnMouseOverClass ;
		}
	}
	else
	{
		TableTrCurrObject.className=TableTrOnMouseOverClass ;
	}
}


function hL(E){
	
	E.className = "p_datagrid_select";
}		

function dL(E, className){
	E.className = className;
}	

//显示层的M些函授
function clearAll(){
try
{
    self.parent.BoardTitle.ticket.style.visibility = 'hidden';
    self.parent.BoardTitle.market.style.visibility = 'hidden';
    self.parent.BoardTitle.sales.style.visibility = 'hidden';
    self.parent.BoardTitle.product.style.visibility = 'hidden';
    self.parent.BoardTitle.project.style.visibility = 'hidden';
    self.parent.BoardTitle.apgrp.style.visibility = 'hidden';
    self.parent.BoardTitle.system.style.visibility = 'hidden';
    self.parent.BoardTitle.message.style.visibility = 'hidden';
    self.parent.BoardTitle.mydesk.style.visibility = 'hidden';
    self.parent.BoardTitle.faq.style.visibility = 'hidden';
    }
    catch(e){}
}
function MM_showHideLayers(obj, v, img) {
    var objStyle=obj.style;
    if (objStyle)
     {
        v=(v=='show')?'visible':(v='hide')?'hidden':v;
       }
    objStyle.visibility=v; 
     var divMsgList=self.parent.BoardTitle.document.getElementById("divMsgList");
     if(divMsgList!=null)
     {divMsgList.style.width=getObjectWidth(obj);
        divMsgList.style.left=getObjectLeft(obj);
        divMsgList.style.top=getObjectTop(obj) +getObjectHeight(obj)+5;
     }
	//self.parent.adminHeader.Form1.menu.value = img ;
	//self.parent.BoardMain.menuicon.src = 'images/top/mydesk.gif' ;
	//alert(obj.top+obj.height+obj.offsetLeft);
	//alert(getObjectTop(obj));
	
}


//对一组div进行显示或隐藏。Div_showHideLayers（divId,visibleORhidden,idNum) idNum为定义ID名称的开头字符。
function Div_showHideLayers(obj,visibleORhidden , startName) {
    var objStyle=obj.style;

	objStyle.display = 'block';
	visibleORhidden = visibleORhidden.toLowerCase();
	objStyle.visibility = visibleORhidden ;
    if (objStyle)
     {
	 
        visibleORhidden =( visibleORhidden =='show')?'visible':(visibleORhidden='hide')?'hidden':visibleORhidden;
     }
	 var divs=document.getElementsByTagName("div")
	 var divObj ;
	 for (divId in divs)
	     {
			 divObj=divs[divId];
			 if(divObj.id)
			 {
				if(divObj.id.indexOf(startName)==0 && divObj.id!=obj.id)
				{
					divObj.style.visibility=visibleORhidden; 
					divObj.style.display='none'; 
					
				}
			}
   		}
	
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImgRestoreMenu() { //v3.0
	var tmpModule = self.parent.adminHeader.Top.menu.value ;
	var tmpName , tmpSrc ;
	var i,j=0,x,a=document.images; 
	for(i=0; i<a.length; i++)
	{
		x = a[i] ;
		tmpName  = x.name ;
		tmpSrc = x.src ;
		j = tmpSrc.indexOf(tmpName) ;
		
		if (tmpModule.length>0)
		{
			if (tmpName != tmpModule)
			{
				x.src = tmpSrc.substring(0, j) + "/" + tmpName + ".gif" ;
			}
			else
			{
				x.src = tmpSrc.substring(0, j) + "/" + tmpName + "_f2"+ ".gif" ;
			}
		}
		else
		{
			x.src = tmpSrc.substring(0, j) + "/" + tmpName + ".gif" ;
		}
		
	}
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

///显示窗口的Content
function winStatus( msg )
{
	window.status = msg;
}

//关闭左边的菜单栏
function switchSysBar(){
	if (switchPoint.innerText==3){
		switchPoint.innerText=4
		top.content.cols="10,*"
	}
	else{
		switchPoint.innerText=3
		top.content.cols="200,*"		
	}
}

//SetMove down拉菜单
  function aClass(aData, aValue, aText) {
    if (aClass.arguments.length < 3)
      alert("Data Entry Error！")
    else {
      this.Data  = aData;
      this.Value = aValue;
      this.Text  = aText;
    }
  }

  function chgDnCombobox(aSrc, aDes, aClass, aRemain){
    if (chgDnCombobox.arguments.length < 3)
	  alert("Data Entry Error！")
    else if (aSrc.type != "select-one")
      alert("Data Entry Error！")
    else if (aClass == null)
      alert("Undefined Class Error！")
    else {
      if (aRemain==null)
        aRemain = 1;
      chgDnComboboxItem(aSrc.options[aSrc.selectedIndex].value, aDes, aClass, aRemain);
    }
  }

  function chgDnComboboxItem(aValue, aDes, aClass, aRemain){
    if (chgDnComboboxItem.arguments.length<3)
      alert("Parameter Entry Error！")
    else if (aClass==null)
      alert("Error! Undefined Class！")
    else{
      if (aRemain==null)
        aRemain = 1;
      deleteAllComboboxItem(aDes, aRemain);
      for (var i=0; i<aClass.length; i++)
        if (aClass[i].Data==aValue)  
          if (aClass[i].Data!="")
            addComboboxItem(aDes, aClass[i].Text, aClass[i].Value);
    }
  }

  function deleteAllComboboxItem(aList, aRemain) {
    for (var i=aList.options.length; i > aRemain-1; i--)
      aList.options[i] = null;
  }    

  function addComboboxItem(aList, aText, aValue) {
    var aOption = new Option(aText, aValue);
    eval("aList.options[aList.options.length]=aOption");
  }
  
  function getComboxValue(combObj)
  {
	document.tablelist.comstrid.value='============' ;
	return combObj.options[combObj.selectedIndex].value  ;
  
  }
  //end
  
  //选择项
  function setOption(selectName,OptionValue)
	{ var opt;
		for (var i=0; i<selectName.options.length; i++)
			{	opt=selectName.options[i];
				if(opt.value==OptionValue)
				{
					opt.selected = true;
					break;
				}
				else
				{
					opt.selected=false;
				}
			}
	}

//多选的确定
function changeDicSelect(objForm)
{
	var srcName = objForm.name ;
	var tmpName ;
	var tmpBol ;
	if (objForm.checked)
		tmpBol = true ;
	else
		tmpBol = false ;
	
	for (var i=0; i < document.tablelist.length; i++)
	{
		tmpName = document.tablelist[i].name;
		if(tmpName.indexOf(srcName) >= 0)
		{
			eval("document.tablelist." + tmpName + ".checked=" + tmpBol)
		}
	}
}

//Upload Document
function uploadFile(frmName, srcFldName, fldName, filePath,sikpFileName,rootUrl)
{
	var uploadURL = "/Upload.aspx?frmName=" + frmName + "&fldName=" + fldName + "&filePath=" + filePath  + "&srcFldName=" + srcFldName ;
	if(rootUrl != null)
	{
	    uploadURL=rootUrl+uploadURL ;
	}
	
	if (sikpFileName!=null)
	{
	uploadURL+="&sikpFileName="+sikpFileName;
	}

	openWindow('no_tb', uploadURL)
}  



//PreviewDocument
function viewFile(frmName, srcFldName, fldName, filePath)
{
	var sValue ;
	eval("sValue=document." + frmName + "." + fldName + ".value") ;
	
	if (sValue == "")
	{
		alert("Please Upload Document ! ") ;
	}
	else
	{
		var fileURL = filePath + sValue;
		openWindow('no_tb',fileURL) ;
	}
}  

//DownloadDocument
function downloadFile(frmName, srcFldName, fldName, filePath)
{
	var sValue ;
	eval("sValue=document." + frmName + "." + fldName + ".value") ;
	
	if (sValue == "")
	{
		alert("Please Upload Document ! ") ;
	}
	else
	{
		var fileURL = filePath + sValue;
		openWindow('no_tb',fileURL) ;
	}
}  

//Move Up传多个Document
function uploadMutileFile(frmName, srcFldName, fldName, filePath,rootUrl)
{
    uploadFile(frmName, srcFldName, fldName, filePath,null,rootUrl) ;

}

///Preview多个Document
function viewMutileFile(frmName, srcFldName, fldName, filePath)
{
	var sValue ;
	eval("sValue=document." + frmName + "." + fldName + ".value") ;
	
	var sName ;
	eval("sName=document." + frmName + "." + srcFldName + ".value") ;
	
	if (sValue == "")
	{
		alert("Please Upload Document ! ") ;
	}
	else
	{
		var fileURL = filePath + sValue;
		var tmpName = "" ;
		var tmpValue = "" ;
		//openWindow('no_tb',fileURL) ;
		
		var wTemp = window.open('','', 'width=600,toolbar=yes,height=400,resizable=1,scrollbars=auto');
		var doc = wTemp.document;
		var str = '<HTML><HEAD><TITLE></TITLE></HEAE><BODY>';
		
		var sNames =sName.split(",") ;
		var sValues=sValue.split(",") ;
		for (var i=0 ; i < sValues.length; i++)
		{
			tmpName =  sNames[i];
			tmpValue= sValues[i];
			str += "<a href=\'" + filePath + tmpValue + "\'>" + tmpName + "</a><br>";
		}
		
		/*
		for (var i=0 ; i < (sValue.length/24); i++)
		{
			tmpName = sValue.substring((i-1)*25, i*25-1 ) ;
			str += "<a href=\'" + filePath + tmpName + "\'>" + tmpName + "</a><br>";
		}
		*/
	
			str += '</BODY></HTML>' ;//+sValue;
			doc.write(str);
		
			doc.close()
	}
}  

//Download多个Document
function downloadMutileFile(frmName, srcFldName, fldName, filePath)
{
	var sValue ;
	eval("sValue=document." + frmName + "." + fldName + ".value") ;
	
	if (sValue == "")
	{
		alert("Please Upload Document ! ") ;
	}
	else
	{
		var fileURL = filePath + sValue;
		var tmpName = "" ;
		//openWindow('no_tb',fileURL) ;
		
		var wTemp = window.open('','', 'width=600,toolbar=yes,height=400,resizable=1,scrollbars=auto');
		var doc = wTemp.document;
		var str = '<HTML><HEAD><TITLE></TITLE></HEAE><BODY>';
			
		for (var i=1 ; i < (sValue.length/24); i++)
		{
			tmpName = sValue.substring((i-1)*25, i*25-1 ) ;
			str += "<a href=\'" + filePath + tmpName + "\'>" + tmpName + "</a><br>";
		}
			str += '</BODY></HTML>';
			doc.write(str);
			doc.close()
	}
}  

//PreviewDocument
function viewFile(frmName, srcFldName, fldName, filePath)
{
	var sValue ;
	eval("sValue=document." + frmName + "." + fldName + ".value") ;
	
	if (sValue == "")
	{
		alert("Please Upload Document ! ") ;
	}
	else
	{
		var fileURL = filePath + sValue;
		openWindow('no_tb',fileURL) ;
	}
}  

//DeleteDocument
function deleteFile(frmName, srcFldName, fldName, filePath)
{

if (confirm("Are you sure you would like to delete??"))
	{
		var sValue ;
		eval("document." + frmName + "." + fldName + ".value=''") ;
		eval("document." + frmName + "." + srcFldName + ".value=''") ;
	}
}  
function deleteImg(ControlName)
{
	document.write ("<a href=\"JavaScript:deleteItem('"+ControlName+"');\"><img src=\"../Images/btn_delete.gif\" onMouseOut=\"this.src='../Images/btn_delete.gif'\" onMouseOver=\"this.src='../images/btn_delete_f2.gif'\" border=0></a>");
}

function deleteItem(ControlName,myMsg)
{
    var msg="Are you sure you would like to delete data??" ;
    if(myMsg!=null) msg=myMsg ;
	if (confirm(msg))
	{
		if(ControlName!=null)
		{
		 __doPostBack(ControlIdToJsControlId(ControlName),'');
		 }
		return true ;
	}
	else
	{
		return false ;
	}
}



//将动态控件ID转为javascript使用ID。
function ControlIdToJsControlId(ControlName)
{ var rv , rvs ,oldstr;
	 rv=ControlName.toString();
	if(rv.indexOf("__")>-1)
	{
			rvs=rv.split("__") ;
			oldstr="__";
	}
	else if (rv.indexOf(":_")>-1)
	{
		 rvs=rv.split(":_") ;
		 oldstr=":_";
	}
	for( key in rvs)
	{
		rv=rv.replace(oldstr,"$_");
	}
	return rv ;

}
//执行服务器按钮回发，并可设置一个参数值。
//LinkButtonClick(控件ID,参数值,HiddenInput名称)
function LinkButtonClick(ControlName,idValue,idName)
{	
	var rv=ControlIdToJsControlId(ControlName);
	if(idValue!=null)
	{   
	    var hiddenInput;
	    if(idName!=null)
	    {
	        hiddenInput=idName ;
	     }
	     else
	     {
	        hiddenInput=ControlName+"_ID" ;
	     }
	    var str ="<input type=hidden name="+hiddenInput+" id="+hiddenInput+">" ;	
	    
	    document.forms[0].insertAdjacentHTML("beforeEnd",str) ;
	    var  idItem=document.getElementById(hiddenInput);
	    idItem.value=idValue ;
	}
	__doPostBack(rv,'');
	
}

//执行服务器按钮回发，并可设置一个参数值。
function LinkButtonClickConf(ButtonName,idValue,formName)
{
	if( confirm('Are you sure you would like to delete data??'))
	{  
		if(idValue !=null)
		{
			var str ="<input type=hidden name=LinkButton_Delete_Id id=LinkButton_Id>" ;	
			if (formName==null)
			{	document.forms[0].insertAdjacentHTML("beforeEnd",str) ;
    			document.forms[0].LinkButton_Delete_Id.value=idValue;
			}
			else
			{	formName.insertAdjacentHTML("beforeEnd",str) ;
				formName.LinkButton_Delete_Id.value=idValue;
			}
		}
		__doPostBack(ControlIdToJsControlId(ButtonName),'');
		return true ;
	}
	else
	{
		return false ;
	}
}


//设置对象 style.visibility
function ControlShow(ControlName,hiddenBool)
{	cont=getControl(ControlName);
	if(cont!=null)
	{	
		if(hiddenBool!=null)
		{
			if(hiddenBool==true) 
				{
					
					cont.style.visibility="hidden";
				}
				else
				{
					cont.style.visibility="visible";
				}
				//cont.disabled=hiddenBool;
		}
		else
		{
			cont.style.visibility="visible";
		}
	alert(cont.name);	
	}
	else
	{
	    alert("null") ;
	}
}
//将对象disable。
function ControlDisable(ControlName,disableBool)
{	cont=getControl(ControlName);
	if(cont!=null)
	{	
		if(disableBool!=null)
		{
			if(disableBool==true) 
				{
					cont.disabled=true;
				}
				else
				{
					cont.disabled=false;
				}
		}
		else
		{
			cont.disabled=true;
		}
		
	}
	
}

//获得组件对象。还则返回null
//getControl (字符串/object)
function getControl(Control)
{
	var contypeStr=false ;
		if(Control.constructor==String) contypeStr=true;
		thisform=document.forms[0];
		
		for (var i=0;i<thisform.elements.length;i++)
		{
			var e = thisform.elements[i];
			if(contypeStr)
			{
			    //alert(typeof(e)+"="+e.name+"="+e.id);
				if (e.name == Control || e.id==Control)
				{
					 return e;
				}
			}
			else
			{
				if (e== Control) return e;
			}
		}
		return null ;
}

//打开Date FromSelect窗口
function openDate(fedName, curDate){ 
	var ReturnValue = window.showModalDialog("/date.htm","","dialogWidth=220px;dialogHeight=262px;status=0");
	//var ReturnValue = window.open('/apcrm_web/date.htm','', 'width=600,height=200,resizable=1,scrollbars=auto')
	fedName.value = ReturnValue ;
	//alert(ReturnValue);
} 

function isBlank(str)
{	var ret=true;
	if(typeof(str)=="undefined" || str==null || str=="")
		return true;
	for(var i=0;i<str.length;i++)
	{
		if(str.charAt(i)!=" ")
		{
			ret=false;
			break;
		}
	}
	return ret;
}
  

function openWindow(style,page,winStyle)
{
	var name=null;
	var features="";
	var replace=null;
	
	switch(style)
	{
		case 'no_tb':
			features="height=300,width=450,status=no,toolbar=no,"+
						"menubar=no,location=no,channelmode=no,"+
						"directories=no,resizable=yes,scrollbars=no,"+winStyle;
			break;
		case 'stf_sel':
			features="height=400,width=800,status=no,toolbar=no,"+
						"menubar=no,location=no,channelmode=no,"+
						"directories=no,resizable=yes,scrollbars=yes";
			break;
	    case 'report':
			features="top =10,left=100, height=650,width=900,status=no,toolbar=no,"+
						"menubar=yes,location=no,channelmode=no,"+
						"directories=no,resizable=yes,scrollbars=yes";
			var thisDate=new Date();
			style=thisDate.getTime();	
			break;
	   case 'apgrpinf_sel':
			features="top=150,left=100,height=500,width=750,status=no,toolbar=yes,"+
						"menubar=no,location=no,channelmode=no,"+
						"directories=no,resizable=yes,scrollbars=yes";
			break;
		case 'reportview':
			features="top=10,left=10,height=650,width=900,status=no,toolbar=no,"+
						"menubar=no,location=no,channelmode=no,"+
						"directories=no,resizable=yes,scrollbars=yes";
		break;				
		case 'fileopen':
			features="top=10,left=10,height=600,width=800,status=no,toolbar=yes,"+
						"menubar=no,location=no,channelmode=no,"+
						"directories=no,resizable=yes,scrollbars=yes";
		
			break;
		case "payment":
				features="top=10,left=200,height=600,width=500,status=no,toolbar=no,"+
					"menubar=yes,location=no,channelmode=no,directories=no,resizable=yes,scrollbars=yes";
    		break;
		default:
			features="top=10,left=100,height=600,width=850,status=no,toolbar=no,"+
						"menubar=no,location=no,channelmode=no,"+
						"directories=no,resizable=yes,scrollbars=yes,"+winStyle;
		break;
	}
	
	var w=window.open(page,style,features,replace);
	ObjFocus(w);
}
//必须输入正数/整数/int。
function checknumPlus(thisform)
{
	var checknum=thisform.value;
	
	if(checknum!=null)
	{
		while(checknum.indexOf(",")>-1)
		{
	 	checknum=checknum.replace(",","");
	 	}
	}
	if(isNaN(checknum)&&checknum!="")
	{
		alert("This field must be a number!");
		ObjFocus(thisform,true);
		return false;
	}
	else
	{
		if (checknum=="0." || checknum=="0.0")
		{
			alert("This field must be a number!");
			ObjFocus(thisform,true);
			return false;
		}
	}
		if (checknum<0)
		{
			alert("Invalid Input!");
			ObjFocus(thisform,true);
			return false;
		}
		else if(checknum.indexOf(".")!=-1)
		{
			alert("Invalid Input!");
			ObjFocus(thisform,true);
			return false;
		
		}
		
		
	return true ;
}
//检测是否为数字，介可检测是否超过最大值。
function checknum(thisform,maxNum,minNum,myMsg)
{
	var checknum=thisform.value;
	
	if(checknum!=null)
	{
		while(checknum.indexOf(",")>-1)
		{
	 	checknum=checknum.replace(",","");
	 	}
	}
	if (checknum=="0." || checknum=="0.0")
		{
			alert("This field must be a number!!");
			ObjFocus(thisform,true);
			return false;
		}
		
	if(isNaN(checknum)&&checknum!="")
	{
		alert("This field must be a number!");
		ObjFocus(thisform,true);
		return false;
	}
	else
	{
		
	}
	if( checknum !="")
	{ 
	    numObj = new Number(checknum) ;
	    if (isNaN(numObj)) 
        { 
            alert("This field must be a number!");
		    ObjFocus(thisform,true);
		    return false;
        }
        else
        {
		    if (maxNum!=null && minNum==null)
		    {
			    if(numObj > maxNum)
			    {
			        if(myMsg!=null)
			         {
			            alert(myMsg) ;
			         }
			         else
			         {   
				        alert("This field must be <= "+maxNum.toString()+"!");
				    }
				    ObjFocus(thisform,true);
				    return false;
			    }
		    }
		    else if (maxNum!=null && minNum!=null)
		    {
			    if(numObj>maxNum || numObj<minNum)
			    {
			        if(myMsg!=null)
			         {
			            alert(myMsg) ;
			         }
			         else
			         {
				         alert("This field must be "+minNum.toString()+" - "+maxNum.toString()+"!");
				      }
				    ObjFocus(thisform,true);
				    return false;
			    }
    		
		    }
		}
	}
	return true;
}

function checkmail(thisform,Msg)
{
    var mail=thisform.value;
    if (mail!="")
	    {
		    if (mail.indexOf("@") == -1 ||mail.indexOf(".") == -1)
		    { if(Msg==null) Msg="Please enter valid email address in the form of  yourname@yourcompany.com .";
			    alert(Msg);
			    ObjFocus(thisform,true);
			    return false;  
		    }
	    } 
	    
 /*
  var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
  var check=/@[\w\-]+\./;
  var checkend=/\.[a-zA-Z]{2,3}$/;
  if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
    return false;
  }
  */
}
 
 //检测电话号码是否合法。
function checkTel(thsiInp)
{
  var thisTel=thsiInp.value;
  if(thisTel!="")
  {
      var exclude =/^\s*[^a-z^A-Z]{1,20}\s*$/;  // /^\s*[0123456789+-\s]{7,99}\s*$/; 
      if(exclude.test(thisTel)==false)
      {
        alert("Please enter valid number!");
        ObjFocus(thsiInp,true);
	    return false;
      }
  }
  else
  {
    return true ;
  }
  

}
 //检测URL是否合法。
function checkURL(thsiInp)
{
  var thisValue=thsiInp.value;
    
  if(thisValue !="")
  {
      var exclude=/([\w-]+\.)+[\w-]+([\w- ./?%&=]*)?/;

      if(exclude.test(thisValue)==false)
      {
            alert("Please enter valid url!");
            ObjFocus(thsiInp,true);
		   return false;
      }
  }
  else
  {
    return true ;
  }

}

function getRandom()
{
    var rv="" ;
    rv=Math.random().toString();
    
    return rv ;
}
var SourImgUrl="" ;
var SourImgObj ;
var isMouseOvew=false ;
 
function ImgOnMouseOver(objimg,ShowImgFileName)
{ 
   // isMouseOvew=true ;
	SourImgUrl =objimg.src ;
	SourImgObj =  objimg ;
	var overimg=ShowImgFileName ;
	if (overimg==null 
	 )//   && SourImgUrl.lastIndexOf("_f2.")==-1 )
	{
		var s = SourImgUrl.lastIndexOf(".");
		overimg= SourImgUrl.substr(0,s)+"_f2"+SourImgUrl.substr(s) ;
	}
	if(overimg!=null) objimg.src=overimg ;

}


function ImgOnMouseOut(objimg,ShowImgFileName)
{	
//   isMouseOvew=false ;
//   wait(this,1000);//调用暂停函数
//   this.nextFun=function()
//   {
//      if(isMouseOvew==false)
//       {
            if(ShowImgFileName!=null)
            {
                objimg.src=ShowImgFileName;
            }
            else
            { 
	                if(objimg!=null)
	                {
                        objimg.src=SourImgUrl ;

	                }
	                else
	                {
		                SourImgObj.src=SourImgUrl ;
	                }   
	         }
//	     }
//    }
}
  
  function wait(obj,secon){
   if (window.eventList==null)
   window.eventList=new Array();
   var con=-1;
   
   for (var i=0;i<window.eventList.length;i++){
     if (window.eventList[i]==null) {
      window.eventList[i]=obj;
      con=i;
     break;
     }
   }
   
if (con==-1){
   con=window.eventList.length;
   window.eventList[con]=obj;
   }
   setTimeout("exec(" + con + ")",secon); //当然还是需要借助setTimeout了
}
  function exec(con){
   var obj=window.eventList[con];
   window.eventList[con]=null;
    if (obj.nextFun) 
       obj.nextFun();//在这里调用下一步的动作
    else{ obj();}
}

function SelectBoxAll(thisform,checkname,thischeck) {
	for (var i=0;i<thisform.elements.length;i++)
	{
		var e = thisform.elements[i];
		if ((e.name == checkname) && (e.type=='checkbox'))
		e.checked = thischeck;
	}
}

//在datagrid中全选检测或input相同内容。
function DataGridSelectBoxAll(thisForm,DataGridName,ConName,defValue)
{
	
	for (var i=0;i<thisForm.elements.length;i++)
	{
		var e = thisForm.elements[i];
		if(e.type=='checkbox' && e.disabled==false)
		{
			var en=e.name ;
			var sen1=en.indexOf(DataGridName) ;
			if(sen1>-1)
			{
				var sen2=en.substr(sen1).indexOf(ConName) ;
				if(sen2>-1)
				{
					e.checked = defValue;
				}
			}
		}
		
		if(e.type=='text')
		{
			var ien=e.name ;
			var isen1=ien.indexOf(DataGridName) ;
			if(isen1>-1)
			{
				var isen2=ien.substr(isen1).indexOf(ConName) ;
				if(isen2>-1)
				{
					//if(e.value=="")
					 e.value=defValue ;
				}
			}
			
			
		
		}
	}

}

//当输入后对应checkbox进行打勾。
function DataGridInNumberCheckBoxSelect(thisInput,CheckBoxName)
{
	if(checknum(thisInput))
	{
		if(parseFloat(thisInput.value))
		{
		CheckBoxName.checked=true;
		}
	}
}
//四舍五入
function  myRound(number,Digs)  
{ 
		   number=getNumber(number) ;
           number  =  Math.round(number*Math.pow(10,Digs))/Math.pow(10,Digs);  
           return  number;  
}  
function getNumber(number)
{
	try
	{
	
		if(isNaN(number))
			{
	           while(number.indexOf(",")>-1)
                {
                number=number.replace(",","");
                }
        	}
			number = new Number(number);
			return number ;
	}
	catch(e)
	 	{
	 		//alert(e );
	 		return 0 ;
	 	}
	
			
		
}

//计算百分比。100* 10% =10 ;
//total=100,percent=10,returnFile为返回显示地方控件。
function percentDiscount(total ,percent ,returnFile)
{ 
	try
	{
		totalNum = getNumber(total);// parseFloat (total);
		 percentNum=getNumber(percent); //parseFloat (percent)//
		var rv=totalNum * (percentNum/100) ;
		if(rv.toString()!="NaN")
		{
			rv=myRound(rv,4) ;
		 	returnFile.value=rv.toString();
		 }
	}
	 	catch(e)
	 	{
	 		alert(e);
	 	}
}

function percentQty (TotalFile ,percentFile ,returnFile)
{
 percentDiscount(TotalFile.value,percentFile.value,returnFile);
 var rv=new Number(returnFile.value);
 var t=new Number(TotalFile.value);
 var p=new Number(percentFile.value);
 if(rv!="NaN" && p>0 )
 {
 	rv=Math.round(rv);
 	if(rv==0 && t>0) rv=1;
 	
 	if(rv>t) rv= t ;
	
	returnFile.value=rv ;
 
 }
 
 
}
//相加 input.value=plusAdd(input1,input2);
function plusAdd(AddInput1,AddInput2,AddInput3,AddInput4,AddInput5,AddInput6,AddInput7,AddInput8)
{
    try
	    {
	     var rv=0 ;
	     var crv=0;
	        if(AddInput1!=null)
				{	crv = getNumber(AddInput1.value);
					rv = rv+ crv;
				}
	        if(AddInput2!=null)
				{	crv = getNumber(AddInput2.value);
					rv = rv+ crv;
				}
	        if(AddInput3!=null)
				{	crv = getNumber(AddInput3.value);
					rv = rv+ crv;
				}
	        if(AddInput4!=null)
				{	crv = getNumber(AddInput4.value);
					rv = rv+ crv;
				}
	        if(AddInput5!=null)
				{	crv = getNumber(AddInput5.value);
					rv = rv+ crv;
				}
	        if(AddInput6!=null)
				{	crv = getNumber(AddInput6.value);
					rv = rv+ crv;
				}
	        if(AddInput7!=null)
				{	crv = getNumber(AddInput7.value);
					rv = rv+ crv;
				}
	        if(AddInput8!=null)
				{	crv =getNumber(AddInput8.value);
					rv = rv+ crv;
				}
				
				
				
	    }
	catch(e)
	 	{
	 		alert(e);
	 	}
		return  myRound(rv,2) ;	
	 	
    
}

//multiplierInput * （faciendAddInput_1+faciendAddInput_2+faciendAddInput_3）=returnInput
function multiplicationTotal(multiplierInput,returnInput,faciendAddInput_1,faciendAddInput_2,faciendAddInput_3,faciendAddInput_4,faciendAddInput_5,faciendAddInput_6)
{	
	try
	{
			var multiplier = new Number(multiplierInput.value);
			var faciend1 = 0;// new Number(faciendAddInput_1.value);
			var faciend2 =0;// new Number(faciendAddInput_2.value);
			var faciend3 = 0;// new Number(faciendAddInput_3.value);
			var faciend4 = 0;
			var faciend5 = 0;
			var faciend6 = 0;
			var faciend=0 ;
		
			if(faciendAddInput_1!=null)
				{	faciend1 = new Number(faciendAddInput_1.value);
					if(faciend1.toString()!="NaN") faciend = faciend+ faciend1;
				}
			
			if(faciendAddInput_2!=null)
				{	faciend2 = new Number(faciendAddInput_2.value);
					if(faciend2.toString()!="NaN") faciend =faciend+ faciend2;
				}
			
			if(faciendAddInput_3!=null)
				{	faciend3 = new Number(faciendAddInput_3.value);
					if(faciend3.toString()!="NaN") faciend = faciend+faciend3;
				}
			if(faciendAddInput_4!=null)
				{	faciend4 = new Number(faciendAddInput_4.value);
					if(faciend4.toString()!="NaN") faciend = faciend+faciend4;
				}
			if(faciendAddInput_5!=null)
				{	faciend5 = new Number(faciendAddInput_5.value);
					if(faciend5.toString()!="NaN") faciend = faciend+faciend5;
				}		
		if(faciendAddInput_6!=null)
				{	faciend6 = new Number(faciendAddInput_6.value);
					if(faciend6.toString()!="NaN") faciend = faciend+faciend6;
				}
			if(faciend.toString()!="NaN")
			{
				returnInput.value= myRound(multiplier * faciend,2) ;
			}
		
		}
		
		catch(e)
	 	{
	 		alert(e);
	 	}
		
}

//multiplicationTotal(除数,返回input ,相加值,相加值,相加值) 
function divisionTotal(divisionInput,returnInput,faciendAddInput_1,faciendAddInput_2,faciendAddInput_3)
{	
	try
	{
			var multiplier = new Number(divisionInput.value);
			var faciend1 = 0;// new Number(faciendAddInput_1.value);
			var faciend2 =0;// new Number(faciendAddInput_2.value);
			var faciend3 = 0;// new Number(faciendAddInput_3.value);
			var faciend=0 ;
		
			if(faciendAddInput_1!=null)
				{	faciend1 = new Number(faciendAddInput_1.value);
					if(faciend1.toString()!="NaN") faciend += faciend1;
				}
			
			if(faciendAddInput_2!=null)
				{	faciend2 = new Number(faciendAddInput_2.value);
					if(faciend2.toString()!="NaN") faciend += faciend2;
				}
			
			if(faciendAddInput_3!=null)
				{	faciend3 = new Number(faciendAddInput_3.value);
					if(faciend3.toString()!="NaN") faciend += faciend3;
				}
		
			if(faciend.toString()!="NaN")
			{
				var rv=parseInt(faciend / multiplier);
				var modnum=faciend % multiplier;
				if(modnum>0) rv++ ;
				returnInput.value= rv
			}
		
		}
		
		catch(e)
	 	{
	 		alert(e);
	 	}
}

//比较新值不能小于某值 if(inpText<Num2) alert(Mess)
// Sour原值，inpText输入框对象，num要比较的值，
function compareNum(inpText,Num2,Mess,Sour)
{	checknum(inpText) ;
		var num1 = new Number(inpText.value);
		var num2 = new Number(Num2);
		if(num1<num2)
		{	var str="" ;
				if (Mess==null)
					{
						str="Sale price is lower than purchase price:"+Num2 +"!"
					}
				else
					{
						str=Mess;
					}
				alert(str) ;
				

		}

}

//显示文件。如图片/txt/swf
//ViewImage(文件名称,url文件路径) ViewImage("a.gif","../upload");
function OpenViewFile(Option,Url){
	var imgstr=Option.toLowerCase();
    var str = '<HTML><HEAD><TITLE></TITLE></HEAE><BODY>';
    if(Url==null) Url="" ;
	if (imgstr!="")
		{
			for (var i = 0; i < Option.length; i++)
				 {
				 Option=Option.replace("\\","/");
			      }
			  for (var i = 0; i < Url.length; i++)
			 {
			 Url=Url.replace("\\","/");
			  }

			if (imgstr.indexOf(".swf")>=0)
				{	
				str += '<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 width=450 height=300>';
				str += '	  <param name=movie value=\'' + Url + Option + '\'>';
				str += '	  <param name=quality value=high>';
				str += '	  <embed src=\'' + Url + Option + '\'> quality=high pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash width=450 height=300>';
				str += '	  </embed>' ;
				str += '	</object>';
					
				}
			else if (imgstr.indexOf(".dcr")>=0)
				{
				str += '<object classid=clsid:166B1BCA-3F9C-11CF-8075-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,0,0  width=450  height=300>';
				str += '	  <param name=src value=\'' + Url + Option + '\'>';
				str += '	  <embed src=\'' + Url + Option + '\'>  pluginspage=http://www.macromedia.com/shockwave/download/ width=450 height=300>';
				str += '	  </embed>' ;
				str += '	</object>';
				}
			else if (imgstr.indexOf(".gif")>=0 || imgstr.indexOf(".jpg")>=0 ||  imgstr.indexOf(".jpeg")>=0  )
				{
					str += '<IMG src=\'' + Url + Option + '\'>';
				}
			else
				{
    				window.open(Url+Option,"", "width=600,height=400,resizable=1,scrollbars=1");
				    str="";
				}
			}
		else
			{
			str +='<div align=center><font size=+1><b>Not Picture !</b></font></div>';
			}
	if (str!="")
	{
		str +='<p><a href=JavaScript:window.close()><b>Window Close</b></a>';
		str += '</BODY></HTML>';
    	var wTemp = window.open('','', 'left=200,top=100,width=600,height=400,resizable=1,scrollbars=1');
    	//var wTemp =	window.showModalDialog('dialogHeight=500px;dialogWidth=850px;help=0;status=0;resizable=1',str); 
    	 var doc = wTemp.document;
		doc.write(str);
        doc.close()

//        window.showModalDialog('../Apgroup/Apgrpinfmodule.aspx?parentchildsharedsessionname=customer_modselect_popupwinForPacking',window,'dialogHeight=500px;dialogWidth=850px;help=0;status=0;resizable=1');
		}
}


//选择日期
var dateSpliteTag="-" ;
function SelectDate(fedName,yyText,mmText,ddText,TButton,Root)
{ 
	var dateRoot="date.htm";
	if (Root!=null) dateRoot=Root+"/date.htm" ;
	var tdate=new Date() ;
	var yy=yyText.value;
	var mm=mmText.value;
	var dd=ddText.value;
	if (yy=="") yy=tdate.getFullYear();
	if (mm=="") mm=tdate.getMonth+1 ;
	if (dd=="") dd=tdate.getDate();
	var defDate=yy + "-" +mm +"-"+dd; 
	var butPos=getpos(TButton) ;
	var screen="";
	//screen="dialogTop="+(butPos.t+170)+"px;dialogLeft="+(butPos.l+100)+"px;" ;
	window.status=butPos.t+ '  '+butPos.l ;
	var ReturnValue = window.showModalDialog(dateRoot,defDate,screen+"dialogWidth=260px;dialogHeight=260px;status=0;titlebar=no;scrollbars=yes;help=0");
	if (ReturnValue!=null && ReturnValue!=" " )
	{fedName.value = ReturnValue ;
	 getDateSplite(fedName,yyText,mmText,ddText) ;
	}
	return false ;
} 

function SelectDate2(fedName,Root,formDate,toDate){ 
	var dateRoot="../date.htm";
	if (Root!=null) dateRoot=Root+"/date2.htm" ;
	var ReturnValue = window.showModalDialog(dateRoot,"","dialogWidth=250px;dialogHeight=270px;status=0;");
	
	if (ReturnValue!=null && ReturnValue!=" " )
	{
	
	    if(checkDate(ReturnValue,formDate,toDate))
	    {
	      fedName.value = ReturnValue ;
	    }
	   
	 }
	
	
} 

//将字串转为日期。
function getDateTime(DateString)
{   var rv ; 
        var ds=DateString.split("-") ;
        if(ds.length>2)
        {
       
          rv = new Date(ds[0], ds[1]-1, ds[2]) ;
        }
   return rv ;
}
///getDateString(日期，样式yyyy/yyyymm/yyyymmdd) ;
function getDateString(DateObj,yyyymmddStyle)
{
     var yy=DateObj.getFullYear() ;
     var mm=DateObj.getMonth()+1;
     var dd=DateObj.getDate() ;
     var rv=yy +  dateSpliteTag + mm + dateSpliteTag  + dd ;
     if(yyyymmddStyle!=null)
     {
        switch(yyyymmddStyle)
        {
           case "yyyy":
                rv=yy  ;
                break;
           case "yyyymm":
                rv=yy +  dateSpliteTag + mm
                break;
        }
     }
     
     return rv ;
}
//将日期拆分。
function getDateSplite(dText,yyText,mmText,ddText)
{
    var dStr=dText.value ;
    var err=" " ;
    
    if(dStr.length>0)
    {  
        var dateObj=getDateTime(dStr);
           if(dateObj!="NaN")
           {
                if(yyText!=null) yyText.value=dateObj.getFullYear();
                if(mmText!=null) mmText.value=dateObj.getMonth()+1;
                if(ddText!=null) ddText.value=dateObj.getDate() ;
                err="" ;
            }
     }
     
     if (err!="")
        {
            alert("Please input Date!(YYYY-MM-DD)");
            ObjFocus(dText,true);
        }
}

function onBlueDateChage(dText,yyText,mmText,ddText)
{
    try
    {
        var yy=0 ;
        var mm=0 ;
        var dd=1 ;
        if(yyText!=null) yy=yyText.value ;
        if(mmText!=null) mm=mmText.value-1 ;
        if(ddText!=null) dd=ddText.value ;
        if(mm<0) mm=0 ;
        if(yy=="" 
            && mmText.value==""
            && dd=="")
         {
         dText.value="" ;
         }
         else
         {
            if(mm<0) mm=0 ;
            var d = new Date(yy,mm,dd)
             if(d!="NaN")
             {
                dText.value= getDateString(d) ;
            }
        }
    }
    catch(e)
    {}
    
}


//检测当前日期是否在指定的范围内。
function checkDate(dateStr,formDate,toDate,dateInp)
{ 
    var msg="";
    var rv=true ;
    if(isDate(dateStr))
    {
       
        var curDate=getDateTime(dateStr) ;
	    //from date
	    if(isDate(formDate))
        {
	        var fdate=getDateTime(formDate);
            if(fdate>curDate)
            {
                msg+="\nThis is Date < "+formDate ;
                if(isDate(toDate))  msg+="\n (From "+formDate+" To "+ toDate+")";
            }
        }
	    
	    //to date
	     if(isDate(toDate))
        {
	        var tdate = getDateTime(toDate);
            if(tdate<curDate)
            {
                msg+="\nThis is Date > "+toDate ;
                if(isDate(formDate))  msg+="\n (From "+formDate+" To "+ toDate+")";
            }
        }
	}
//	else if(dateInp!=null)
//	{
//	 dateInp.focus();
//	 dateInp.select();
//	}
	
	if(msg!="")
	{
	    alert(msg) ;
	    rv=false ;
	}
	
	return rv ;

}

//检测是否为日期型数据(yyyy-mm-dd)
function isDate(dateStr) 
{ 
	if(dateStr!=null)
	{
	    if(dateStr.length>0)
	    {
		    var datePat = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; 
		    var matchArray = dateStr.match(datePat); 
    		
		    if (matchArray == null) { 
		    alert("Please enter date as either yyyy/mm/dd or yyyy-mm-dd."); 
		    return false; 
		    } 
    		
		    month = matchArray[3]; 
		    day = matchArray[5]; 
		    year = matchArray[1]; 
    		
		    if (month < 1 || month > 12) { 
		    alert("Month must be between 1 and 12."); 
		    return false; 
		    } 
    		
		    if (day < 1 || day > 31) { 
		    alert("Day must be between 1 and 31."); 
		    return false; 
		    } 
    		
		    if ((month==4 || month==6 || month==9 || month==11) && day==31) { 
		    alert("Month "+month+" doesn't have 31 days!") 
		    return false; 
		    } 
		
		    if (month == 2) { 
		    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); 
		        if (day > 29 || (day==29 && !isleap)) { 
		        alert("February " + year + " doesn't have " + day + " days!"); 
		        return false; 
		        } 
		    } 
		    return true; 
	    }
	}

	
	return false ;
} 





//获得控件位置left
function   getObjectLeft(e)   
  {   
      var   l=e.offsetLeft;   
     // while(e=e.offsetParent)   l   +=   e.offsetLeft;   
      return   l;   
  }   
  function   getObjectTop(e)   
  {   
      var   t=e.offsetTop;   
      while(e=e.offsetParent)   t   +=   e.offsetTop;   
      return   t;   
  }
  function   getObjectWidth(e)   
  {   
      var   t=e.offsetWidth;   
      //while(e=e.offsetParent)   t   +=   e.offsetHeight;   
      return   t;   
}    
  function   getObjectHeight(e)   
  {   
      var   t=e.offsetHeight;   
      //while(e=e.offsetParent)   t   +=   e.offsetHeight;   
      return   t;   
}

var BrowserInfo = new Object() ;
BrowserInfo.MajorVer = navigator.appVersion.match(/MSIE (.)/)[1] ;
BrowserInfo.MinorVer = navigator.appVersion.match(/MSIE .\.(.)/)[1] ;
BrowserInfo.IsIE55OrMore = BrowserInfo.MajorVer >= 6 || ( BrowserInfo.MajorVer >= 5 && BrowserInfo.MinorVer >= 5 ) ;
    var oPopupMenu = window.createPopup();

StyleMenuHeader = "<head>"
	+"</head>"
	+"<body scroll='no' onConTextMenu='event.returnValue=false;'>";

function showDiv(bodyStr)
{
    var oPopDocument = oPopupMenu.document;
	var oPopBody = oPopupMenu.document.body;
	var width = 200;
	var height=100;
	var lefter = event.clientX;
	var leftoff = event.offsetX
	var topper = event.clientY;
	var topoff = event.offsetY;
    oPopBody.style.overflow = "auto";
	oPopDocument.open();
	oPopDocument.write(StyleMenuHeader+bodyStr + " "+lefter + "  "+leftoff);
	oPopDocument.close();

	//if(lefter+width > document.body.clientWidth) lefter=lefter-width+22;

	//oPopupMenu.show(lefter - leftoff, topper - topoff + 22, width, height,document.body);
	oPopupMenu.show(lefter, topper - topoff + 22, width, height,document.body);
	return false;
}
function closeDiv()
{
   
}
//将listBox中的项目进行互掉.
function listBoxItemMove(sBoxObj,tBoxObj)
{
    var sIndex=sBoxObj.selectedIndex;
    if(sIndex>-1)
    {
        var aOption = new Option(sBoxObj.options[sIndex].text, sBoxObj.options[sIndex].value);
        eval("tBoxObj.options[tBoxObj.options.length]=aOption");
    }
} 

function Trim(str){
 if(str.charAt(0) == " "){
  str = str.slice(1);
  str = Trim(str); 
 }
 return str;
}


//后退
function goback()
{
    history.go(-1);
}
//提示Yes No信息。
function alertYesNo(MessageStr)
{
    return confirm(MessageStr);
}

//ifrom 自动设置窗口size begin 
var DYNIFS = {
	// Storage for known IFrames.
	iframes: {},
	// Here we save any previously installed onresize handler.
	oldresize: null,
	// Flag that tell us if we have already installed our onresize handler.
	ready: false,
	// The document dimensions last time onresize was executed.
	dim: [-1,-1],
	// Timer ID used to defer the actual resize action.
	timerID: 0,
	// Obtain the dimensions (width,height) of the given document.
	getDim: function(d) {
		var w=10, h=10, scr_h, off_h;
		if( d.width )  { return [d.width,d.height]; }
		if( d.height ) { return [d.width,d.height]; }
try{
		with( d.body ) {
			if( scrollHeight ) { h=scr_h=scrollHeight; w=scrollWidth; }
			if( offsetHeight ) { h=off_h=offsetHeight; w=offsetWidth; }
			if( scr_h && off_h ) h=Math.max(scr_h, off_h);
		}
}
catch(ex){}
		return [w,h];
	},
	// This is our window.onresize handler.
	onresize: function() {
		// Invoke any previously installed onresize handler.
		if( typeof this.oldresize == 'function' ) { this.oldresize(); }
		// Check if the document dimensions really changed.
		var dim = this.getDim(document);
		if( this.dim[0] == dim[0] && this.dim[1] == dim[1] ) return;
		// Defer the resize action to prevent endless loop in quirksmode.
		if( this.timerID ) return;
		this.timerID = setTimeout('DYNIFS.deferred_resize();', 10);
	},
	// This is where the actual IFrame resize is invoked.
	deferred_resize: function() {
		// Walk the list of known IFrames to see if they need to be resized.
		for( var id in this.iframes ) this.resize(id);
		// Store resulting document dimensions.
		this.dim = this.getDim(document);
		// Clear the timer flag.
		this.timerID = 0;
	},
	// This is invoked when the IFrame is loaded or when the main window is resized.
	resize: function(id) {
		// Browser compatibility check.
		if( !window.frames || !window.frames[id] || !document.getElementById || !document.body )
			return;
		// Get references to the IFrame window and layer.
		var iframe = window.frames[id];
		var div = document.getElementById(id);
		if( !div ) return;
		// Save the IFrame id for later use in our onresize handler.
		if( !this.iframes[id] ) {
			this.iframes[id] = true;
		}
		// Should we inject our onresize event handler?
		if( !this.ready ) {
			this.ready = true;
			this.oldresize = window.onresize;
			window.onresize = new Function('DYNIFS.onresize();');
		}
		// This appears to be necessary in MSIE to compute the height
		// when the IFrame'd document is in quirksmode.
		// OTOH, it doesn't seem to break anything in standards mode, so...
		if( document.all ) div.style.height = '0px';
		// Resize the IFrame container.
		var dim = this.getDim(iframe.document);
		div.style.width = (dim[0]) + 'px';
		div.style.height = (dim[1]) + 'px';
		
	}
};
//检测最大输入字符串长度。
//onkeyUp=inputMaxSize(this,64,"") ;
function inputMaxSize(con,maxLengthValue,errMsg)
{
	
	try
	{
	    
		
		if(con!=null && maxLengthValue>0)
		{
			
			var v=con.value ;
			if(v.length>(maxLengthValue))
			{
			    var er="Please input maxLength "+maxLengthValue.toString()+"!";
			    if(errMsg!=null)
			    {
			        if(errMsg.length>0) er=errMsg ;
			    }
				alert(er) ;	
				con.value=v.substring(0,maxLengthValue) ;
			}
			
		}
		}
	catch(e)
	{}
}
//ifrom 自动设置窗口size End 
//动行等待窗口
//var runtingStyleIsRun=true ;
function runtingStyle(divId)
{
   
    var divStr="" ;
    var isSetStyle=false ;
    var s="" ;
    divStr+="<table bgcolor='#FFFFFF'>" ;
    divStr+="    <tr align='left'>" ;
    divStr+="        <td><img src='"+HttpRootPathAndThemeName+"/images/loadingRed.gif'/></td>" ;
    divStr+="     </tr>" ;
    divStr+="    <tr align='right' valign='bottom'>" ;
    divStr+="        <td><font color='red'>Loading . . .</font></td>" ;
    divStr+="    </tr>" ;
    divStr+="    </table>" ;
    /*    
    divStr+="<table>" ;
//    divStr+="    <tr align='center'>" ;
//    divStr+="        <td><!img src='../images/loading2.gif'/></td>" ;
//    divStr+="     </tr>" ;
    divStr+="    <tr align='center'>" ;
    divStr+="        <td><font color='red'>Loading . . .</font></td>" ;
    divStr+="    </tr>" ;
    divStr+="    </table>" ;
    */
    divId.innerHTML =divStr ;
    /*
    var atts = divId.attributes;
    for (var i = 0; i < atts.length; i++)
    {
        var att = atts[i];
        if(att.specified == true)
        {
            if(att.nodeName.toLowerCase( )=="style")
            {
                isSetStyle=true;
                runtingStyleIsRun=false ;
               break ; 
            }
        }
    }
       if(isSetStyle==false || runtingStyleIsRun)
       
       {*/

         try{   
         var getS=getScroll() ;
            divId.style.zIndex= 99999;
            divId.style.position="absolute";
            divId.style.backgroundColor="#EDEEEA";

//          var docWidth   = document.body.scrollLeft - document.body.clientLeft ;//   document.body.clientWidth;   
//          var docHeight   =window.screen.scrollTop  - document.body.clientTop ; // window.screen.Height-200; // window.screen.Height-300 ; document.body.clientHeight;
//        
//        //  if(docHeight==0 || docHeight>1024) docHeight=1024 ;
//          //if(docHeight==0)docHeight = window.screen.Height-300 ; 
//          divId.style.top   = getS.h/2 +getS.t ;// (docHeight-divHeight)/2 ;  
//          divId.style.left   = getS.w/2+getS.l; //  (docWidth   -   divWidth)/2   +   parseInt(document.body.scrollLeft,10) ;
//      
       
    //   alert(getS.w + "  " + getS.h);
         
          }   
          catch(e)
          {
           //alert(e.Message);
          }   
        //}

   
}


function DateAdd(interval,number,date){ 
// date 可以是时间对象也可以是字符串，如果是后者，
//形式必须为: yyyy-mm-dd hh:mm:ss 其中分隔符不定。"2006年12月29日 16点01分23秒" 也是合法的
number = parseInt(number);
if (typeof(date)=="string"){
date = date.split(/D/);
--date[1];
eval("var date = new Date("+date.join(",")+")");
}
if (typeof(date)=="object"){
var date = date
}
switch(interval){
case "y": date.setFullYear(date.getFullYear()+number); break;
case "m": date.setMonth(date.getMonth()+number); break;
case "d": date.setDate(date.getDate()+number); break;
case "w": date.setDate(date.getDate()+7*number); break;
case "h": date.setHours(date.getHour()+number); break;
case "n": date.setMinutes(date.getMinutes()+number); break;
case "s": date.setSeconds(date.getSeconds()+number); break;
case "l": date.setMilliseconds(date.getMilliseconds()+number); break;
} 
return date;
}


//可折叠式导航菜单 expandShow(html标签,父ID，当前ID，url)
function expandShow(htmlTag,parentId,curId,url)
{ 
    //document.getElementById('menu_sub_'+i); 
    var obj,i=0;
    try
    {
       // var objs= document.all.tags(htmlTag);
        var objs= document.getElementsByTagName(htmlTag);
        var gid="",id="",ids ;
        var goURl=true ;
        for (i=0; i<objs.length; i++) 
        {            
            obj = objs[i];
            ids = obj.id.split(';');
            if(ids.length==2)
            {
           
                id= ids[0];
                gid= ids[1];
                if (gid == curId)
                   { 
                        goURl=false ;
                       if (obj.style.display == "none") 
                       {           
                            obj.style.display = "block";  
                            obj.style.visibility ="visible";  
                       }
                       else 
                       {            
                            obj.style.display = "none";  
                            obj.style.visibility = "hidden";       
                       } 
                   }
             }
        }
        if(goURl)
        {
            document.location=url ;
        }
    }
    catch(e)
    {
        alert(e);
    }
   
}

	
newWin=null;
function ShowDialog_2(url, iWidth, iHeight, frmName, param)  //模仿ShowModal弹出窗体， wengy 2009-01-03
{
            //var iWidth=600; //窗口宽度
            //var iHeight=420;//窗口高度
           
            
            if(iWidth!=null)
            {
                iWidth=iWidth.toString();
                iWidth=iWidth.toLowerCase();
                if(iWidth.indexOf("px")==-1)
                {
                    iWidth=iWidth+"px";
                }
                
            }
            if(iHeight!=null)
            {
                iHeight=iHeight.toString();
                iHeight=iHeight.toLowerCase();
                if(iHeight.indexOf("px")==-1)
                {
                    iHeight=iHeight+"px";
                }
                
            }
			if (frmName=="") {
				frmName = "newWin"
				}
           
            if (param =="")
            {	
                var iTop=(window.screen.height-iHeight)/2;
                var iLeft=(window.screen.width-iWidth)/2;	
			    var param="top="+iTop.toString()+",left="+iLeft.toString()+",Width="+iWidth.toString()+",Height="+iHeight.toString();
			} else {
			    var param="Width="+iWidth.toString()+",Height="+iHeight.toString()+","+param;
			}
			
            newWin =window.open(url, frmName, param);		
           // window.showModalDialog(url,frmName,param);
            window.onfocus=function()
                {
                    if(newWin)
                     {
                        if(!newWin.closed)
                        {
                           ObjFocus(newWin) ;
                        }
                     } 
                 };	
}

function ShowDialog(url, iWidth, iHeight, frmName)  //模仿ShowModal弹出窗体， wengy 2009-01-03
{
            //var iWidth=600; //窗口宽度
            //var iHeight=420;//窗口高度
           
        ShowDialog_2(url, iWidth, iHeight, frmName, "Scrollbars=yes,Toolbar=no,Location=not,status=1,Direction=no,resizable=yes")    
					
}


window.onfocus=function (){  
 if(newWin){
  if(!newWin.closed)
   newWin.focus();
 } 
}; 

window.document.onfocus=function (){ 
 if(newWin){
  if(!newWin.closed)
 newWin.focus();  
 } 
 
}; 

window.document.onclick=function (){  
 if(newWin){
  if(!newWin.closed)
 newWin.focus();
 } 
}; 

window.document.ondblclick=function (){  
 if(newWin){
  if(!newWin.closed)
 newWin.focus();  
 } 
}; 


function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

//div 提示窗口begin
// JScript source code
function divMessageBox(title, msg, w, h,ShowSeconds,YesUrl,YesTxt)
{
    var showTime= 2000;
    var t = showTime/1000;
    if(ShowSeconds!=null)
    {    t=ShowSeconds ;
    }
    var titleheight = "20px"; // 提示窗口标题高度 
    var bordercolor = "#cccccc"; // 提示窗口的边框颜色 
    var titlecolor = "#ffffff"; // 提示窗口的标题颜色 
    var titlebgcolor = "#000099"; // 提示窗口的标题背景色
    var bgcolor = "#cccccc"; // 提示内容的背景色
    var msgColor="red";//提示文字内容颜色。
    var iWidth = document.body.clientWidth; 
    var iHeight = document.body.clientHeight; 
    var bgObj = document.createElement("div"); 
    bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
    document.body.appendChild(bgObj); 
    var msgObj=document.createElement("div");
    msgObj.style.cssText = "position:absolute;font:11px '宋体';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:"+titleheight+";z-index:102;";
    document.body.appendChild(msgObj);
    var table = document.createElement("table");
    msgObj.appendChild(table);
    table.style.cssText = "margin:0px;border:0px;padding:0px;";
    table.cellSpacing = 0;
    table.cellPadding = 0;
    var tr = table.insertRow(-1);
    var titleBar = tr.insertCell(-1);
    titleBar.style.cssText = "width:100%;height:"+titleheight+"px;text-align:left;padding:0px;margin:0px;font:bold 13px '宋体';color:"+titlecolor+";border:0px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
    titleBar.style.paddingLeft = "10px";
    titleBar.innerHTML = title;
    var moveX = 0;
    var moveY = 0;
    var moveTop = 0;
    var moveLeft = 0;
    var moveable = false;
    var docMouseMoveEvent = document.onmousemove;
    var docMouseUpEvent = document.onmouseup;
    titleBar.onmousedown = function() 
    {
           var evt = getEvent();
           moveable = true; 
           moveX = evt.clientX;
           moveY = evt.clientY;
           moveTop = parseInt(msgObj.style.top);
           moveLeft = parseInt(msgObj.style.left);      
           document.onmousemove = function() 
           {
                if (moveable)
                {
                     var evt = getEvent();
                     var x = moveLeft + evt.clientX - moveX;
                     var y = moveTop + evt.clientY - moveY;
                     if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) 
                     {
                          msgObj.style.left = x + "px";
                          msgObj.style.top = y + "px";
                     }
                 } 
           };
           document.onmouseup = function ()
           { 
                if (moveable) 
                { 
                     document.onmousemove = docMouseMoveEvent;
                     document.onmouseup = docMouseUpEvent;
                     moveable = false; 
                     moveX = 0;
                     moveY = 0;
                     moveTop = 0;
                     moveLeft = 0;
                } 
           };
     }
    var closeBtn = tr.insertCell(-1);
    closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor+";height:"+titleheight+"px;";
    closeBtn.innerHTML = "<span style='font-size:14pt; color:"+titlecolor+"'>×</span>";
    closeBtn.onclick = divMessagesClose;
    var msgBox = table.insertRow(-1).insertCell(-1);
    msgBox.style.cssText = "font:10pt '宋体';height:50px;color:"+msgColor;
    msgBox.colSpan = 2;
	msgBox.align = "center";
    msgBox.innerHTML = msg;
    
    
    //显示剩余的时间数
    var time = table.insertRow(-1).insertCell(-1);
    time.style.cssText = "font:9pt '宋体';";
	time.align = "center";
    time.innerHTML = t ;//+" 秒后自动关闭!";
    
    if(YesUrl!=null)
    {
        //显示OK按钮
        var YesBtn =table.insertRow(-1).insertCell(-1);
        var YesInnerTxt="Yes" ;
        if(YesTxt!=null)
        {
            if(YesTxt.length >0)  YesInnerTxt=YesTxt ;
        }
        YesBtn.innerHTML="<input type=button value=\" "+YesInnerTxt+" \" onClick=\"javascript:location='"+YesUrl+"';\">" ;
        //YesBtn.innerHTML="<a href=\""+YesUrl+"\"> Yes </a>" ;
    }

    // 获得事件Event对象，用于兼容IE和FireFox
    function getEvent() {
         return window.event || arguments.callee.caller.arguments[0];
    }
    //处理自动关闭事件
    function autoClose(){		
	    --t;
	    if(t>0)
	    {
		    time.innerHTML = t;//+" 秒后自动关闭!";
		    setTimeout(autoClose,1000);
	    }
	    else
	    {
		    setTimeout(divMessagesClose,1000);
	    }		
	 }
    //关闭
	 function divMessagesClose(){	
	 try
	 {
       document.body.removeChild(bgObj); 
       document.body.removeChild(msgObj);
       }
       catch(e)
       {} 
     }
    //自动关闭处理入口
    setTimeout(autoClose,1000);
} 	 


//div 提示窗口end

//更改form.action连接
function changeFormUrl(url,formObj)
{
    if(url!=null)
    {
        var formObject=this.document.forms[0] ;
        if(formObj!=null)
        {
            formObject=formObj ;
        }
        formObject.action=url ;
    }
}
// var sURL = window.document.URL;
//读取URL的参数值。getQueryString(Url，参数名称)
  function getQueryString(sURL,key)
     {
         var value = ""; 
         if (sURL.indexOf("?") > 0)
         {
              var arrayParams = sURL.split("?");
              var arrayURLParams = arrayParams[1].split("&");
              for (var i = 0; i < arrayURLParams.length; i++)
              {
                   var sParam =  arrayURLParams[i].split("=");
                   if ((sParam[0] == key) && (sParam[1] != ""))
                   {
                       value = sParam[1];
                       break;
                   }
              }        
         }
         return value;
     }
//检测输入长段不能超出指定长度
function checkLength(obj,MaxLength)
{
    try
    {
        if   (obj.value.length>MaxLength)
        {  
              obj.value=obj.value.substring(0,MaxLength)  
         } 
      }
      catch(ex){alert(ex)} 
   
      return   true 
}