
function left(mainStr,lngLen) {
if (lngLen>0) {return mainStr.substring(0,lngLen)}
else{return null}
} 

function right(mainStr,lngLen) {
// alert(mainStr.length)
if (mainStr.length-lngLen>=0 && mainStr.length>=0 && mainStr.length-lngLen<=mainStr.length) {
return mainStr.substring(mainStr.length-lngLen,mainStr.length)}
else{return null}
}
function mid(mainStr,starnum,endnum){
if (mainStr.length>=0){
return mainStr.substr(starnum,endnum)
}else{return null}
//mainStr.length
}
 

/*
 * 函数说明：设置cookie值
 * 参数：	cookie字段名,cookie值,过期时间
 * 返回值：	无
 * 时间：2006-5-12
 */
 function setCookie(c_name,value,expiredays)
{var exdate=new Date()
exdate.setDate(expiredays)
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate)
}

/*
 * 函数说明：取cookie值
 * 参数：	cookie字段名
 * 返回值：	cookie值
 * 时间：2006-5-12
 */
function getCookie(sName) {
	  var aCookie = document.cookie.split("; ");
	  for (var i=0; i < aCookie.length; i++)
	  {
	    var aCrumb = aCookie[i].split("=");
	    if (sName == aCrumb[0]) 
	      return unescape(aCrumb[1]);
	  }
	  return null;		
}
/*
 * 函数说明：去除头尾空格
 * 参数：	字符串
 * 返回值：	字符串
 * 时间：2006-5-12
function trim(inputString) {
	return inputString.replace(/^ +/,"").replace(/ +$/,"");
}
*/
function trim(str)
{
	return str.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}
String.prototype.trim = function()
{
	return this.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}

function checkIP(sIPAddress) 
{ 

var sIPAddress=sIPAddress 
var IPsplit; 
var re=/^(\d{1,3}\.){3}\d{1,3}\/(\d{1,3}\.){3}\d{1,3}$/gi; 
var chkflag=true; 
var ErrMsg="你输入的是一个非法的IP地址段！\nIP段为：:xxx.xxx.xxx.xxx/xxx.xxx.xxx.xxx（xxx为0-255)!" 

if(sIPAddress.search(re)==-1){ 
chkflag=false; 
}else{ 
IPsplit=sIPAddress.split("/"); 
IPsplit=IPsplit[0]+"."+IPsplit[1] 
IPsplit=IPsplit.split("."); 

for(i=0;i<8;i++){ 
if(IPsplit[i]>255){ 
chkflag=false; 
break; 
} 
} 
} 
if(!chkflag) 
alert(ErrMsg); 
return chkflag 
}
/*
 * 函数说明：删除对象
 * 参数：	 对象名，参数可以多个，用逗号隔开
 * 返回值：	对象
 * 时间：2006-6-27
 */
function deleteElement(documentID){
	documentID.parentNode.removeChild(documentID);
}
/*
 * 函数说明：取出对象，等于document.getElementById()
 * 参数：	 对象名，参数可以多个，用逗号隔开
 * 返回值：	对象
 * 时间：2006-6-27
 */
function $() {
  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;
}

function isIE(){ //ie? 
   if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
    return true; 
   else 
    return false; 
} 
/*给Firefox加上insertAdjacentHTML属性
*/
//for FireFox compatible
if(navigator.appName=="Netscape"){
HTMLElement.prototype.insertAdjacentHTML=function(where, html){
           var e=this.ownerDocument.createRange();
           e.setStartBefore(this);
           e=e.createContextualFragment(html);
           switch (where) {
                    case 'beforeBegin': this.parentNode.insertBefore(e, this);break;
                    case 'afterBegin': this.insertBefore(e, this.firstChild); break;
                    case 'beforeEnd': this.appendChild(e); break;
                    case 'afterEnd':
                    if(!this.nextSibling) this.parentNode.appendChild(e);
                    else this.parentNode.insertBefore(e, this.nextSibling); break;
           }
};
HTMLElement.prototype.__defineGetter__("innerText", 
  function(){
   var anyString = "";
   var childS = this.childNodes;
   for(var i=0; i<childS.length; i++) {
    if(childS[i].nodeType==1)
     anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
    else if(childS[i].nodeType==3)
     anyString += childS[i].nodeValue;
   }
   return anyString;
    } 
 ); 
   HTMLElement.prototype.__defineSetter__("innerText", 
    function(sText){ 
     this.textContent=sText; 
    } 
   ); 
}

String.prototype._indexOf = String.prototype.indexOf;
String.prototype.indexOf2 = function()
{
 if(typeof(arguments[arguments.length - 1]) != 'boolean'){
  return this._indexOf.apply(this.toLowerCase(),arguments);
 }
 else
 {
  var bi = arguments[arguments.length - 1];
  var thisObj = this;
  var idx = 0;
  if(typeof(arguments[arguments.length - 2]) == 'number')
  {
   idx = arguments[arguments.length - 2];
   thisObj = this.substr(idx);
  }
  
  var re = new RegExp(arguments[0],bi?'i':'');
  var r = thisObj.match(re);
  return r==null?-1:r.index + idx;
 }
}

function Browser() {

   var ua, s, i;

   this.isIE     = false;   // Internet Explorer
   this.isNS     = false;   // Netscape
   this.version = null;

   ua = navigator.userAgent;

   s = "MSIE";
   if ((i = ua.indexOf(s)) >= 0) {
     this.isIE = true;
     this.version = parseFloat(ua.substr(i + s.length));
     return;
   }

   s = "Netscape6/";
   if ((i = ua.indexOf(s)) >= 0) {
     this.isNS = true;
     this.version = parseFloat(ua.substr(i + s.length));
     return;
   }

   // Treat any other "Gecko" browser as NS 6.1.

   s = "Gecko";
   if ((i = ua.indexOf(s)) >= 0) {
     this.isNS = true;
     this.version = 6.1;
     return;
   }
}

var browser = new Browser();


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function LoadScript( url )
{
	document.write( '<scr' + 'ipt type="text/javascript" src="' + url + '"><\/scr' + 'ipt>' ) ;
}

function LoadCss( url )
{
	document.write( '<link href="' + url + '" type="text/css" rel="stylesheet" />' ) ;
}