//<!--
function initArray()
{
  for(i=0;i<initArray.arguments.length;i++)
  this[i]=initArray.arguments[i];
}

 var isnMonths=new initArray("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
 var isnDays=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");
 today=new Date();
 hrs=today.getHours();
 min=today.getMinutes();
 sec=today.getSeconds();
 clckh=""+((hrs>12)?hrs-12:hrs);
 clckm=((min<10)?"0":"")+min;clcks=((sec<10)?"0":"")+sec;
 clck=(hrs>=12)?"下午":"上午";
 var stnr="";
 var ns="0123456789";
 var a="";

function getFullYear(d)
{
  yr=d.getYear();if(yr<1000)
  yr+=1900;return yr;
}

function writeCalendar()
{
  document.write("今天是"+getFullYear(today)+"年"+isnMonths[today.getMonth()]+""+today.getDate()+"日 "+isnDays[today.getDay()]);
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++)
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  return foundObj;
}

function showHideLayers()
{ 
  var i, visStr, obj, imgObj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = '';
        else if(visStr == 'hide') visStr = 'none';
        else if (visStr == 'change')
        {
          if (obj.display == '')
          {
            visStr = 'none';
          } else
          {
            visStr = '';
          }
        }
      }
      obj.display = visStr;
      //保存
	  writeCookie(args[i], visStr, 1000000);
      //改变指示状态 copy to the loadLayerStatus
      if ((imgObj = findObj(args[i+1])) != null)
      {
        if (imgObj.src)
        {
          if (visStr == 'none')
          {
            imgObj.src = './images/icon_expand.gif';
          } else
          {
            imgObj.src = './images/icon_collapse.gif';
          }
        }
      }
    }
  }
}

// Example: // writeCookie("myCookie", "my name", 24); // Stores the string "my name" in the cookie "myCookie" which expires after 24 hours. 
function writeCookie(name, value, hours)
{ var expire = ""; if(hours != null) { expire = new Date((new Date()).getTime() + hours * 3600000); expire = "; expires=" + expire.toGMTString(); } document.cookie = name + "=" + escape(value) + expire; 
} 

// Example: // alert( readCookie("myCookie") ); 
function readCookie(name) 
{ var cookieValue = ""; var search = name + "="; 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; cookieValue = unescape(document.cookie.substring(offset, end)) } } return cookieValue; 
}

// call: 'layername', 'img', 'defValue' 'layername', 'img', 'defValue'
function loadLayerStatus()
{
  var i, visStr, obj, args = loadLayerStatus.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
	visStr = readCookie(args[i]);
    if ((obj = findObj(args[i])) != null)
    {
	  if (obj.style)
	  {
		obj.style.display = visStr;
	  }
      if ((imgObj = findObj(args[i+1])) != null)
      {
        if (imgObj.src)
        {
          if (visStr == 'none')
          {
            imgObj.src = './images/icon_expand.gif';
          } else
          {
            imgObj.src = './images/icon_collapse.gif';
          }
        }
      }
    }
  }
}
//-->
