String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }

function Img(src)
{
    this.preload = function()
    {
        var new_img = new Image();
        new_img.src = this.getSrc();
    }
    this.get = function()
    {
        return "<img src=\"" + this.getSrc() + "\" />";
    }
    this.getSrc = function()
    {
        return this.src;
    }

    this.src = src;
    this.preload();
}


/**
 *
 *
 */
function preloadImage(mix)
{
    if(typeof mix == 'string')
    {
        new Image().src = mix;
    }
    else
    {
        for(var i in mix)
        {
            new Image().src = mix[i];
        }
    }
}

/**
 * 获取文件扩展名
 * dellker.com 2007-10-31
 * wkkes.com 2008-9-3 17:44
*/
function getFileext(sFile, bToLower) {
  if(! sFile) {
    return null;
  } else {
    var a = sFile.split('.');
    if(a.length>0) {
      return bToLower === true ? a[a.length-1].toLowerCase() : a[a.length-1];
    } else {
      return null;
    }
  }
}


/**
 * 加入收藏夹方法
 * 兼容 FF & IE
*/
function addFavorite(sURL, sTitle) {
  try {
    window.external.addFavorite(sURL, sTitle);
  } catch(e) {
    try {
      window.sidebar.addPanel(sTitle, sURL, "");
    } catch(e) {
      alert("加入收藏失败，请使用Ctrl+D进行添加");
    }
  }
}

/**
 * 打开前台
 *
*/
function openFrontStage() {
}

/* 判断是否包含中文
*/
function haveChinese($s) {
  return escape($s).indexOf('%u') < 0 ? false : true;
}

/* 显示日期
*/
function showDate() {
  var s = '';
  var d = new Date(); 
  s += ((document.all)?d.getYear():d.getYear()+1900)+'-'+(d.getMonth()+1)+'-'+d.getDate()+'';
  s += ' ' + d.getHours() + ':' + (d.getMinutes()*1 > 9 ? d.getMinutes() : '0'+d.getMinutes());
  s += '<span style="background-color:lightyellow;border:solid 1px #EFEFEF;padding:2px;margin-left:3px;margin-right:3px;">';
  switch(d.getDay()) {
   case 0:
    s += '  <font color="#FF0000">Sun';
    break;
   case 1:
    s += '  <font color="#555555">Mon';
    break;
   case 2:
    s += '  <font color="#555555">Tue';
    break;
   case 3:
    s += '  <font color="#555555">Wed';
    break;
   case 4:
    s += '  <font color="#555555">Thu';
    break;
   case 5:
    s += '  <font color="#555555">Fri';
    break;
   case 6:
    s += '  <font color="#FF0000">Sat';
    break;
  }
  s += '</font></span>';
  //s += ':' + d.getSeconds();
  document.write(s);
  //setTimeout('showDate()', 1000);
}





function getcookie(name) {
	var cookie_start = document.cookie.indexOf(name);
	var cookie_end = document.cookie.indexOf(";", cookie_start);
	return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}


function setcookie(name, value, expires, path, domain, secure) {
    return setrawcookie(name, encodeURIComponent(value), expires, path, domain, secure)
}

function setrawcookie(name, value, expires, path, domain, secure) {
    if (expires instanceof Date) {
        expires = expires.toGMTString();
    } else if(typeof(expires) == 'number') {
        expires = (new Date(+(new Date) + expires * 1e3)).toGMTString();
    }

    var r = [name + "=" + value], s, i;
    for(i in s = {expires: expires, path: path, domain: domain}){
        s[i] && r.push(i + "=" + s[i]);
    }
    
    return secure && r.push("secure"), document.cookie = r.join(";"), true;
}


