﻿// JScript 文件

function nowTime(format)
{
    var dt=new Date();
    //年份
    this.Year=dt.getFullYear();
    //月份
    this.Month=dt.getMonth()+1;
    //日期
    this.Day=dt.getDate();
    //星期几,数字
    this.Week=dt.getDay();
    //星期几，中文
    this.WeekDay='日一二三四五六'.charAt(dt.getDay()); 
    //24制小时
    this.Hours24=dt.getHours();
    //12制小时
    this.Hours12=this.Hours24>12 ? this.Hours24-12 : this.Hours24; 
    //分钟
    this.Minutes=dt.getMinutes();
    //秒
    this.Seconds=dt.getSeconds();
    format=format.replace("yy",this.Year);
    format=format.replace("MM",this.Month);
    format=format.replace("dd",this.Day);
    format=format.replace("HH",this.Hours24);
    format=format.replace("hh",this.Hours12);
    format=format.replace("mm",this.Minutes);
    format=format.replace("ss",this.Seconds);
    format=format.replace("ww",this.Week);
    format=format.replace("WW",this.WeekDay); 
    //时间显示在页面中哪个标签里，这里是其id
    this.toShow=function (element)
    {
        $(element).html(format);        
          //document.getElementById(element).innerHTML=format;
    } 
}
// JScript 文件
function getOs()
{
   if(navigator.userAgent.indexOf("MSIE")>0)return 1;
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
   if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 3;   
   if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 4;
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)return 5;
   return 0;
}
//添加收藏夹
function AddFavorite()
{
   switch(getOs())
   {
       case 1:window.external.addFavorite(webURL,webName);break;
       case 2:window.sidebar.addPanel(webName, webURL, "");break;
   } 
}
//打印时间
function writeDatetime()
{
    var d = new Date().toLocaleString().split(' ');
    document.write(d[0] + " " + d[1]);
}
//校正高度
function adjustHeight(id1,id2)
{
    if($(id1).height() >= $(id2).height())
    {
        $(id2).height($(id1).height());
    }
    else
    {
        $(id1).height($(id2).height());
    }
}
/********************************************
给字符串增加截空格的方法
********************************************/
String.prototype.trim = function() 
{ 
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.ltrim = function() 
{ 
    return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.rtrim = function() 
{ 
    return this.replace(/(\s*$)/g, ""); 
}