/*******S20070320 与用户状态有关的一些函数*********/
// get UserId
var UserId = SalonAjax.getMyUserId().value;

// user's head img is gray, the id of 'img' tag must be named 'img_head_'+userid
function setUserImgState()
{
	var idStr,idStrTmp;
	var imgNum = document.getElementsByTagName("img").length;
	var onlineStrList = SalonAjax.getOnlineList().value;
	for(var i=0; i<imgNum; i++)
	{
		idStr = document.getElementsByTagName("img")[i].id.toString();
		if(idStr.indexOf("img_head_")==0)
		{
			idStrTmp = ","+ idStr.substr(9) +",";
			if(onlineStrList.indexOf(idStrTmp) == -1)
				document.getElementsByTagName("img")[i].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(opacity=.9,grayScale=1);";
			else
				document.getElementsByTagName("img")[i].style.filter = "";
		}
	}
}
function getUserInfo()
{
  var userInfoStr = SalonAjax.getLoginStr("2").value;
  if(userInfoStr==null)
	  location = lhrf;
  else
	  document.getElementById('dv_top').innerHTML = userInfoStr;
  setUserImgState();
}
function setUserShow()
{
  getUserInfo();
  setInterval("getUserInfo();", 300000);
}
// CLK b
function CLK()
{
	var CLKN="0";
	var a = lhref; 
	a = a.toLowerCase()
	if(a.indexOf("/salon/")>0)
	{
		a = a.substr(a.indexOf("/salon/")+7);
		if(a.indexOf("/")==-1||a.indexOf("/")==a.lastIndexOf("/"))// i
			CLKN = SalonAjax.UPC("1",outParam).value;
		else if(a.indexOf("/paste/")>=0)
		{
			a = a.substr(a.indexOf("/paste/")+7);
			if(a.length>15) // p
				CLKN = SalonAjax.UPC("2",outParam).value;
		}
		else if(a.indexOf("/album/")>=0)
		{
			a = a.substr(a.indexOf("/album/")+7);
			if(a.length>15) // a
				CLKN = SalonAjax.UPC("3",outParam).value;
		}
	}
	
	if(document.getElementById("sp_clicknum") != null)
	{
		if(CLKN!=0 && CLKN!=null)
    			 document.getElementById('sp_clicknum').innerText = CLKN;
	}
}
function chkLogin()
{
	if(UserId==null||UserId=="")
	{
		window.location = "/login.aspx?url1="+ lhref;
		return false;
	}
	else
	{
		return true;
	}
}
function pageOpen()
{
	var t=SalonAjax.isOpen(outParam, UserId).value;
	if(t==false) location = "/Salon/lock.aspx?orgid="+outParam;
}
function getRefreshPage()
{
	var a = lhref; 
	a = a.toLowerCase()
	if(a.indexOf("/salon/")>0)
	{
		a = a.substr(a.indexOf("/salon/")+7);
		if(a.length<15) location = lhref;
	}
}
window.onload = function(){setUserShow();CLK();setInterval("getRefreshPage();", 600000);}