function initArray()  
{  
  for(i = 0 ; i<initArray.arguments.length ; i++)  
  	this[i] = initArray.arguments[i];  
}
  
function getFullYear(d)  
{  
  yr = d.getYear();
  
  if(yr<1000)  
  	yr += 1900;
  	
  return yr;
}  

function getNowDate()
{
	var isnMonths = new initArray("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");  
	var isnDays   = new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");  
	today = new Date();  
	
	var NowDate = ''
	NowDate += getFullYear(today)+"年";
	NowDate += isnMonths[today.getMonth()]; 
	NowDate += today.getDate() + "日 ";
	NowDate += isnDays[today.getDay()];

	return NowDate; 
}

//=======================================================================================

function AddFavorite(sURL, sTitle)
{	
	try
	{
		window.external.addFavorite(sURL, sTitle);
	}
	catch (e)
	{
		try
		{
			window.sidebar.addPanel(sTitle, sURL, "");
		}
		catch (e)
		{
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}

function SetHome(obj,vrl)
{
	try
	{	
			obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}
	catch(e){
			if(window.netscape) {
					try {
							netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
					} 
					catch (e) { 
							alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
					}
					var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
					prefs.setCharPref('browser.startup.homepage',vrl);
			 }
	}
}

//======================================================================================

function GetCookieVal(offset)
	{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	}
	function GetCookie(name)
	{
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen)
		{
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg)
			return GetCookieVal (j);
			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
		return "";
	}
	function fun()
	{
		var username=decodeURIComponent(GetCookie('UserName'))
		if(username!="")
		{
			document.getElementById('divusername').innerHTML='欢迎您，'+username
			document.getElementById('loginyes').style.display="";
			document.getElementById('loginno').style.display="none";
		}
		else
		{
			document.getElementById('loginyes').style.display="none";
			document.getElementById('loginno').style.display="";
		}		
	}
	function DelCookie(name)
	{
		var exp = new Date();
		exp.setTime (exp.getTime() - 1);
		var cval = GetCookie (name);
		document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
	}

	function userexit()
	{
		if(confirm("您确定要退出吗!"))
		{
			DelCookie('UserName');
			document.location.reload();
			//window.showModalDialog('[{$appserver}]admin/exit.php',window,"dialogWidth:200px;dialogHeight:100px;scroll:1");
		}
	}