var nSpaceDate = 15;
var nPopMaxTimes = 1;
var naWeekTimes = 0;
var nCountWeek = 0;
var bExist = 0;
var strDomainPath = ";path=/;domain=sina.com.cn;";
var ietcookie = "ietong_cookie";
var ddtcookie = "ddtong_cookie";
var cookieenable = "sina_cookie_enable";
function getCookieData(label)
{
var labelLen = label.length;
var cLen = document.cookie.length;
var i = 0;
var cEnd;
while(i < cLen)
{
var j = i + labelLen;
if (document.cookie.substring(i, j) == label)
{
cEnd = document.cookie.indexOf(";", j);
if (cEnd == -1)
{
cEnd = document.cookie.length;
}
return unescape(document.cookie.substring(j, cEnd));
}
i++;
}
return "";
}
function IsCookieEnable()
{
document.cookie = cookieenable + "=yes" + strDomainPath;
var data = getCookieData(cookieenable);
return data.length >= 3;
}
function GetDateString()
{
var curDate = new Date();
var endTime = curDate.getTime() + nSpaceDate*24*60*60*1000;
curDate.setTime(endTime);
return curDate.toGMTString();
}
function reDownLoadietong(cookieName,bCanDownLoad)
{
var allCookie;
if(bCanDownLoad)
{
allCookie = cookieName + "=0;expires=" + GetDateString() + strDomainPath;
}
else
{
naWeekTimes += 1;
allCookie = cookieName + "=" + naWeekTimes + ";expires=" + GetDateString() + strDomainPath;
}
document.cookie = allCookie;
}
function TestActivexIET()
{
if(bExist == 0){
try{
search.IETInit(2);
}
catch(e){
reDownLoadietong(ietcookie,false);
//window.open('err.html','Pop');
}
}
}
function TestActivexDDT()
{
if(bExist == 0){
try{
search.IETInit(2);
}
catch(e){
reDownLoadietong(ddtcookie,false);
//window.open('err.html','Pop');
}
}
}
function ShowToolbarIET()
{
if(bExist == 0){
try{
search.IETInit(5);
}
catch(e){
reDownLoadietong(ietcookie,false);
//window.open('err.html','Pop');
}
}
else{
try{
search.IETInit(5);
}
catch(e){
}
}
}
function ShowToolbarDDT()
{
if(bExist == 0){
try{
search.IETInit(5);
}
catch(e){
reDownLoadietong(ddtcookie,false);
//window.open('err.html','Pop');
}
}
else{
try{
search.IETInit(5);
}
catch(e){
}
}
}
function TestIEVer()
{
var Ver=navigator.appVersion;
var result;
if(Ver.substr(Ver.search("MSIE ")+5,3) >= 5.0)
result = true;
else
result = false;
return result;
}
function GetCurTimes(cookieName,allCookies)
{
var firstOne;
var lastOne;
firstOne = allCookies.indexOf(cookieName);
if(firstOne != -1)
{
firstOne += cookieName.length + 1;
lastOne = allCookies.indexOf(';', firstOne);
if(lastOne == -1) lastOne = allCookies.length;
return parseInt(allCookies.substring(firstOne, lastOne));
}
return 0;
}
function IsInstalledIET()
{
try
{
var iet = new ActiveXObject("SinaIETInit.SinaInitObj");
iet.IETInit(0);
}
catch(e)
{
return false;
}
return true;
}
function IsInstalledDDT()
{
try
{
var ddt = new ActiveXObject("DDT_INIT.IDDTInitObj");
ddt.IETInit(0);
}
catch(e)
{
return false;
}
return true;
}
function CanDownLoadietong()
{
var cookieValue;
var allCookie ;
var bCanDownLoad = false;
if(!TestIEVer()) return false;
if(IsCookieEnable() && navigator.cookieEnabled && !IsInstalledDDT())
{
allCookie = document.cookie;
if(allCookie != null && allCookie != "")
{
naWeekTimes = GetCurTimes(ietcookie,allCookie);
if(naWeekTimes >= nPopMaxTimes)
return false;
}
bCanDownLoad = true;
}
return bCanDownLoad;
}
function CanDownLoadddtong()
{
var cookieValue;
var allCookie ;
var bCanDownLoad = false;
if(!TestIEVer()) return false;
if(IsCookieEnable() && navigator.cookieEnabled && !IsInstalledIET())
{
allCookie = document.cookie;
if(allCookie != null && allCookie != "")
{
naWeekTimes = GetCurTimes(ddtcookie,allCookie);
if(naWeekTimes >= nPopMaxTimes)
return false;
}
bCanDownLoad = true;
}
return bCanDownLoad;
}
function BeginDownLoadIET()
{
if(CanDownLoadietong())
{
if (IsInstalledIET())
{
bExist = 1;
}
else
{
bExist = 0;
}
var lang=navigator.browserLanguage;
if(lang.match("zh"))
{
document.write("");
}
}
else
{
bExist = 1;
}
}
function BeginDownLoadDDT()
{
if(CanDownLoadddtong())
{
if (IsInstalledDDT())
{
bExist = 1;
}
else
{
bExist = 0;
}
var lang=navigator.browserLanguage;
if(lang.match("zh"))
{
document.write("");
}
}
else
{
bExist = 1;
}
}
function ShowToolBar()
{
try{
search.IETInit(5);
}
catch(e){
}
}
function BeginShowToolBar()
{
if (IsInstalledIET())
{
document.write("");
}
else if (IsInstalledDDT())
{
document.write("");
}
}
function TestActivex()
{
TestActivexIET();
}
function BeginDownLoad()
{
BeginDownLoadIET();
}