//修改以下三个变量
var oemid = 500;
var DownUrl = "http://www.smenn.com.cn";
var message = '提示：您还没有政企通客户端，点"确定"将到网站下载.';

//以下变量不需修改
var lavactrlclsid = "CLSID:8AE01514-0125-4597-BDA3-B44B94340E4A";
var islavasetup = 0;
var isdownloadctrl = false;
var lavacttcaburl = DownUrl;
var lavacttctrlurl = DownUrl;
var lavactturl = DownUrl;

//对话
function Standardtalkto(contactid, lavaid)
{
       var lava_ver = check_is_lava_installed();
       if (lava_ver>0) 
                {
                 var shtml;
	         if(lavaid!='') shtml = "lava://chat?" + "gid=" + lavaid+ "&contact=" + contactid;
	         else shtml = "lava://chat?" + "contact=" + contactid;
                 window.location.href = shtml;
		 return true;
		}
       if(!(lava_ver>0))
                {
		  if(confirm(message))
                          {
				window.location.href = DownUrl;
				return true;
			  }
                  else
                          {
				return false;
			  }
		}
	
}
//检查是否安装了相关OEMID的客户端
function check_is_lava_installed(){
		
	
	if (!window.ActiveXObject){
		islavasetup = 0;
		return islavasetup;
	}

	try{
		var obj = null;
		try {
			obj = new ActiveXObject("LAVACTRL.LavaCtrlCtrl.1");
			isdownloadctrl = (obj)?true:false;
			if (obj)
			{
				islavasetup = obj.IsLavaInstalled(oemid);
				//if (!islavasetup){
				//	islavasetup = obj.IsMiniLavaInstalled(oemid, "2") ;
				//	if (islavasetup) islavasetup = 2;
				//}
			}
		}catch(e){
			obj = null;
		}
		if (!islavasetup && isdownloadctrl)
		try {
			obj = document.createElement("OBJECT");
			obj.classid = lavactrlclsid;
			obj.codeBase = lavacttcaburl;
			islavasetup = obj.IsLavaInstalled(oemid);
			//if (!islavasetup)
			//{
			//	islavasetup = obj.IsMiniLavaInstalled(oemid, "2") ;
			//	if (islavasetup) islavasetup = 2;
			//}
		}catch(e){
		}
	}catch(e)
           {
	   }
	return islavasetup;
}

//添加好友,lavaid可为空
function addContact(contactid,lavaid){	
         var lava_ver = check_is_lava_installed();
         if (lava_ver>0) 
                {
                  	var shtml;
	                if(lavaid!='') shtml = "lava://add?" + "gid=" + lavaid+ "&contact=" + contactid;
	                else shtml = "lava://add?" + "contact=" + contactid;  
                        window.location.href = shtml;
		        return true;
		}
         if(!(lava_ver>0))
                {
		  if(confirm(message))
                          {
				window.location.href = DownUrl;
				return true;
			  }
                  else
                          {
				return false;
			  }
		}
}

//添加部落,lavaid可为空
function addtribe(tribeid,lavaid){
         var lava_ver = check_is_lava_installed();
         if (lava_ver>0) 
                {
                  var shtml;
	          if(lavaid!='') shtml = "lava://addtribe?" + "gid=" + lavaid+ "&id=" + tribeid;
	          else shtml = "lava://addtribe?" + "id=" + tribeid;
                  window.location.href = shtml;
		  return true;
		}
         if(!(lava_ver>0))
                {
		  if(confirm(message))
                          {
				window.location.href = DownUrl;
				return true;
			  }
                  else
                          {
				return false;
			  }
		}
}

//进入部落,lavaid可为空
function entertribe(tribeid,lavaid)
{
	 var lava_ver = check_is_lava_installed();
         if (lava_ver>0) 
                {
                  var shtml;
	          if(lavaid!='') shtml = "lava://entertribe?" + "gid=" + lavaid+ "&id=" + tribeid;
	          else shtml = "lava://entertribe?" + "id=" + tribeid;
                  window.location.href = shtml;
		  return true;
		}
         if(!(lava_ver>0))
                {
		  if(confirm(message))
                          {
				window.location.href = DownUrl;
				return true;
			  }
                  else
                          {
				return false;
			  }
		}
}
