	/************************************/
	/*与本系统无直接关系的公共函数             */
	/************************************/
	//图片操作
	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_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_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];}
	}
		
	//去左空格; 
	function ltrim(s){ 
	    return s.replace( /^\s*/, ""); 
	} 
	//去右空格; 
	function rtrim(s){ 
	    return s.replace( /\s*$/, ""); 
	} 
	//去左右空格; 
	function trim(s){ 
	    return rtrim(ltrim(s)); 
	}	
	//去所有的空格; 
	function trimAll(s){ 
	    return rtrim(ltrim(s)); 
	}	
		
	//判断原串中是否以子串为开始
	function isSub(str,sub){
	   if (str.substr(0,sub.length)==sub)
	   {
	     return true;
	
	   }else{
	      return false;
	   }
	}
		
	//禁止copy
	function noCopy(){	   
	   document.selection.empty();
	   alert('禁止copy!');
	}		
	
	//禁止cut
	function noCut(){	   
	   document.selection.empty();
	   alert('禁止cut!');
	}

	/*获得srcElement。兼容IE与fireFox*/
	function schTarget(evt){
	  var srcElement = evt.srcElement? evt.srcElement : evt.target; 
	  return srcElement;
	}
	
	/*获得event对象 兼容IE与fireFox*/
	function schEvent(){
	 //IE
	 if(brs()=='IE')
	   return window.event;	  
	 func=schEvent.caller;
	 while(func!=null) {
	  var arg0=func.arguments[0];  
	  if(arg0){
	    if(arg0.constructor==MouseEvent)
	    return arg0;
	  }
	  func=func.caller;
	 }
	    return null;
	}
	// 得到调用者的引用 object
    function getCaller(){
      return schTarget(schEvent()); 
	}	
	
	/*获得浏览器信息*/ 
	function brs(){
	  var userAgent=window.navigator.userAgent;
	  if (userAgent.indexOf('MSIE')>=1) {
	  	return 'IE';
	  }else if (userAgent.indexOf("Firefox")>=1){
	    return 'FF';
	  }
	  return ;
	}
		
	//检查textarea的长度。
	function chkLen(Obj,len,T)
    {
	    if (typeof(T) == "undefined"){T='';}
		var desc=T+"长度不能超过"+len+"!";
	    if (typeof(Obj) == "undefined") 
		{
	       alert("目标不存在。");
	       return true;
	    }
	    var str=Obj.value;
	    if (str==''){return true;}
	
	    if(str.length<len){
	        return true;
	    }else{
	       alert(desc);
	       Obj.focus();
		   return false;
		}
   }//~~~
		
    //自定义的hash函数。可以将一个形如'userName=demo&userName=ttt'的字符串转化为hash的形式
    /*
	function $H(str){
	   var hash=this;
	   var arr=str.split('&');
       for (i=0;i<arr.length; i++){
            sarr = arr[i].split('=');
			hash[sarr[0]] = sarr[1];
       }
	   return this;
	}
	*/
	
	//使组件可见
	function visible(){
	   for (var i=0;i<arguments.length;i++){
	     var ob = document.getElementById(arguments[i]);
	     ob.style.display='inline';
	     //document.getElementById(arguments[i]).disabled=false;
	     var oChild=ob.childNodes;
	     for (var j=0;j<oChild.length;j++){
		      if (oChild[j].nodeType == 1 && oChild[j].type=='input')
	     	  oChild[j].disabled=false;
	     }	     
	   }
	}
	
	//使组件不可见
	function invisible(){
	   for (var i=0;i<arguments.length;i++){
	     var ob = document.getElementById(arguments[i]);
	     ob.style.display='none';
	     //document.getElementById(arguments[i]).disabled=true;
	     //不可用
	     var oChild=ob.childNodes;
	     for (var j=0;j<oChild.length;j++){
		      if (oChild[j].nodeType == 1 && oChild[j].type=='input')
	     	  oChild[j].disabled=true;
	     }
	   }	
	}
	
	//得到某个标签内的所有的元素
	function getall(o)
	{
	var oChild = o.childNodes;
	for (var i=0; i<oChild.length; i++)
	{
	if (oChild[i].nodeType == 1)
	{
	alert(oChild[i].tagName)
	if (oChild[i].hasChildNodes())
	{
	getall(oChild[i]);
	}
	}
	}
	}
	
	
	    //弹出窗口
    function popWin(url,caption,width,height,callback){
      if (height){
      	url+='&height='+height;
      }
      if (width){
      	url+='&width='+width;
      }
      tb_show(caption,url,'',callback);
	  return false; 
    }
	//关闭窗口
	function onClose(){
		 window.opener=null;		
		 window.close();
	}    
    //随机码
    function rnd(){
		var random = Math.floor(Math.random() * 10001);
	  	var id = (random + "_" + new Date().getTime()).toString();
	  	return '&randomid='+id;
    }

    //随机码
    function rndId(){
		var random = Math.floor(Math.random() * 10001);
	  	var id = (random + "_" + new Date().getTime()).toString();
	  	return id;
    }
	
		//取得单选框的值。如果没有选择，返回''
	function getRdoVal(oName){
	  /*
	  for (i=0;i<document.all.length;i++ )
	  {
	     e = document.all(i);
	     if (e.type=='radio'&&e.name==oName&&e.checked)
	     {
	       return e.value;
	     }
	  }
	  	 return '';
	  */
	 	 return  $('input[@name='+oName+'][@checked]').val()
	 }

	//计算器	
	function calc(ob) {
	   try {
	      if (document.getElementById(ob).value==''){
	          return;
	      }
	      document.getElementById(ob).value =
	      ForDight(eval(document.getElementById(ob).value),2);
	   }
	   catch(ejsjg) {
	      alert('无法计算，输入可能有误!');
	      document.getElementById(ob).innerHTML = "";
	   }
	}
	
	//四舍五入。 how:位数
	function ForDight(Dight,How)
	{
		Dight = Math.round (Dight*Math.pow(10,How))/Math.pow(10,How);
		return Dight;
	} 
	
		//关闭窗口
	function closeWindow(){
		 window.opener=null;		
		 window.close();
	}
	
	
	//打开窗口。full：是否隐藏工具栏
	function openWindow(URL,W,H,full){
	
       	var	top =Math.floor((screen.availHeight-H)/2);
       	var	left =Math.floor((screen.availWidth-W)/2);
	    if (typeof(full) == "undefined"||full==true){	
	       window.open(URL, '', 'height='+H+', width='+W+', top='+top+', left='+left+', toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no', false);
	    }else{
	       window.open(URL, '', 'height='+H+', width='+W+', top='+top+', left='+left+', toolbar=yes, menubar=yes, scrollbars=no, resizable=yes,location=no, status=no', false);	    
	    }
	}
		
	/**
	 * Sets a Cookie with the given name and value.
	 *
	 * name       Name of the cookie
	 * value      Value of the cookie
	 * [expires]  Expiration date of the cookie (default: end of current session)
	 * [path]     Path where the cookie is valid (default: path of calling document)
	 * [domain]   Domain where the cookie is valid
	 *              (default: domain of calling document)
	 * [secure]   Boolean value indicating if the cookie transmission requires a
	 *              secure transmission
	 */
	function setCookie(name, value, expires, path, domain, secure)
	{
	    document.cookie= name + "=" + escape(value) +
	        ((expires) ? "; expires=" + expires.toGMTString() : "") +
	        ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        ((secure) ? "; secure" : "");
	}
	
	/**
	 * Gets the value of the specified cookie.
	 *
	 * name  Name of the desired cookie.
	 *
	 * Returns a string containing value of specified cookie,
	 *   or null if cookie does not exist.
	 */
	function getCookie(name,defaultvalue)
	{
	    var dc = document.cookie;
	    var prefix = name + "=";
	    var begin = dc.indexOf("; " + prefix);
	    if (begin == -1)
	    {
	        begin = dc.indexOf(prefix);
	        if (begin != 0) {
				if (defaultvalue) {return defaultvalue;}else{return null;}
			}
		}
		else
		{
			begin += 2;
		}
		var end = document.cookie.indexOf(";", begin);
	    if (end == -1)
	    {
	        end = dc.length;
	    }
	    //return unescape(dc.substring(begin + prefix.length, end));decodeURI
	    return decodeURI(dc.substring(begin + prefix.length, end));
	}
	
	/**
	 * Deletes the specified cookie.
	 *
	 * name      name of the cookie
	 * [path]    path of the cookie (must be same as path used to create cookie)
	 * [domain]  domain of the cookie (must be same as domain used to create cookie)
	 */
	function deleteCookie(name, path, domain){
	    if (getCookie(name)){
	        document.cookie = name + "=" + 
	            ((path) ? "; path=" + path : "") +
	            ((domain) ? "; domain=" + domain : "") +
	            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	    }
	}
	
	//获得Cookie解码后的值	
	function  GetCookieVal(offset)
	{
	var  endstr  =  document.cookie.indexOf  (";",  offset);
	if  (endstr  ==  -1)
	endstr  =  document.cookie.length;
	return  unescape(document.cookie.substring(offset,  endstr));
	}
	
	//Cookie读取
	/*
	function readCookie(Name) { 
		var search = Name + "=";
		var returnvalue = "";
		if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) { 
		offset += search.length;
		end = document.cookie.indexOf(";", offset); 
		if (end == -1)
		end = document.cookie.length;
		returnvalue=unescape(document.cookie.substring(offset,end));
	   }
	}
	return returnvalue;
	}
	*/
   
   //获取radio的值
   function getRadioValue(radioName){
      //$("div#divPosType input[@name=chkJobType][@checked]").each(function(){
      var ob = $('input[@name='+radioName+'][@checked]');
      
      if (ob.val()){
          return ob.val();
      }else{
          alert('请选择一条记录！');
          return false;
      }
   }
   
   //获取checkbox的值,返回以豆号分隔的形式1,2,3
   function getCheckValue(chkName){
      //$("div#divPosType input[@name=chkJobType][@checked]").each(function(){
      var ob = $('input[@name='+chkName+'][@checked]');
      var rs='';
      ob.each(function(){
            if (rs!='') {rs+=',';}
            rs+=this.value;
      });
      
      if (rs==''){
         alert('请选择一条记录！');
         return false;
      }else{
         return rs;
      }
   }
   
   //获取checkbox选中的数目
   function getCheckCount(chkName){
      //$("div#divPosType input[@name=chkJobType][@checked]").each(function(){
      return $('input[@type=checkbox][@name='+chkName+'][@checked]').length;
   }
	
   //取得字符串的长度.汉字算两个字符
   function getStrLen(str){
      return   str.replace(/[^\x00-\xff]/g,"**").length;
   }	
	
   //取得用户名的长度.汉字算三个字符
   function getUserNameLen(str){
      return   str.replace(/[^\x00-\xff]/g,"***").length;
   }	
	
   //根据当前对象，查找包含它的form
   function getForm(ele){
      return $(ele).parents('form:last');
   }
	
    Tab=function(){}
    Tab.active=function(me){
       var curTab=$(me).parent();
       var tabs = curTab.parent();
       tabs.children().each(function(){
          $(this).removeClass('active').addClass('unactive');
          var id = $(this).attr('id');
          $('#'+id+'_content').hide();
       })       
       curTab.removeClass('unactive').addClass('active');
       var curId = curTab.attr('id');
       $('#'+curId+'_content').show();
    }
	
	