 var sysName;
 var expName;
 var postFlashData = false;
 function fillSpeed(){//填充测试环境选择
	var ad = ["请选择", "北京", "上海", "天津", "重庆", "安徽", "福建", "甘肃", "广东", "广西", "贵州", "海南", "河北", "河南", "黑龙江", "湖北", "湖南", "吉林", "江苏", "江西", "辽宁", "内蒙古", "宁夏", "青海", "山东", "山西", "陕西", "四川", "新疆", "西藏", "云南", "浙江", "香港", "澳门", "台湾", "其它"];
	var sp = ["请选择", "家里", "公司", "学校", "网吧", "其他"];
	var se = ["请选择", "电信", "网通", "铁通", "有线电视", "长城宽带", "联通", "教育网", "不确定"];
	
	fillSelect(ad,"address");
	fillSelect(sp,"space");
	fillSelect(se,"service");
 }
 
 function fillSelect(ar,oi){//插入option
 	 oi = document.getElementById(oi);
 	 for (var i=0;i<ar.length;i++) oi.add(new Option(ar[i],i));
 }
 
 function gotoQzone(){//返回到上次打开的Qzone
 	 if (top.cUin) setTimeout(function(){top.location = "http://" + top.cUin + ".qzone.qq.com"},500);
 }
 
 function sendCheckToFlash(value,varName){ //往flash动画里传递参数
 	 var st = document.getElementById("speedTools");
 	 value = value - 0;
	 st.SetVariable(varName,(value>=1)?-1:0)
 }
 	 
 
 function postSpeedResult(Data){//发送速度测试结果
 	top.spC --;
 	try {top.window.opener.g_XDoc["spC"] = top.spC} catch(e){}
 	if (postFlashData) return;
 	var address = parseFloat(document.getElementById("address").value)+8;
	var space = parseFloat(document.getElementById("space").value)+43;
	var service = document.getElementById("service").value;
	Data = "?uin="+top.uin+"&location="+address+"&netenv="+space+"&sp="+service+"&"+ Data;
	document.getElementById("postData").src = top.postURL + Data;
	postFlashData = true;
 }
 	 
 function getSystem(){//获得系统名称
 	 var uAgent = window.navigator.userAgent;
 	 var sName = "未知";
	 if (/windows/i.test(uAgent)) sName="Windows";
	 if (/windows ce/i.test(uAgent)) sName="Windows CE";
	 if (/windows 95/i.test(uAgent)) sName="Windows 95";
	 if (/windows 98/i.test(uAgent) || /win98/i.test(uAgent)) sName="Windows 98";
	 if (/windows 2000/i.test(uAgent)) sName="Windows 2000";
	 if (/windows xp/i.test(uAgent)) sName="Windows XP";
	 
	 if (/windows nt/i.test(uAgent)) {
		 if (/windows nt 5.0/i.test(uAgent)) sName="Windows 2000";
		 if (/windows nt 5.1/i.test(uAgent)) sName="Windows XP";
		 if (/windows nt 5.2/i.test(uAgent)) sName="Windows 2003";
		 if (/windows nt 5.3/i.test(uAgent)) sName="Windows Vista"; //真的是 NT 5.3么？- -b
	 }
	 
	 if (/x11/i.test(uAgent) || /unix/i.test(uAgent)) sName="Unix";
	 if (/sunos/i.test(uAgent) || /sun os/i.test(uAgent)) sName="SUN OS";
	 if (/powerpc/i.test(uAgent) || /ppc/i.test(uAgent)) sName="PowerPC";
	 if (/macintosh/i.test(uAgent)) sName="Mac";
	 if (/mac osx/i.test(uAgent)) sName="MacOSX";
	 if (/freebsd/i.test(uAgent)) sName="FreeBSD";
	 if (/linux/i.test(uAgent)) sName="Linux";
	 if (/palmsource/i.test(uAgent) || /palmos/i.test(uAgent)) sName="PalmOS";
	 if (/wap/i.test(uAgent)) sName="WAP";
	 return sName;
 }
 
 function getExplorer(){//获得浏览器名称
 	 var uAgent = window.navigator.userAgent;
 	 var eName = "未知";
	 if (/icab/i.test(uAgent)) eName="iCab";
	 if (/lynx/i.test(uAgent)) eName="Lynx";
	 if (/links/i.test(uAgent)) eName="Links";
	 if (/elinks/i.test(uAgent)) eName="ELinks";
	 if (/jbrowser/i.test(uAgent)) eName="JBrowser";
	 if (/konqueror/i.test(uAgent)) eName="konqueror";
	 if (/Opera/i.test(uAgent)) eName="Opera";

	 if (/gecko/i.test(uAgent)) {
		 type="[Gecko]";
		 if (/aol/i.test(uAgent)) eName="AOL";
		 if (/BonEcho/i.test(uAgent)) eName="Firefox Beta";
		 if (/netscape/i.test(uAgent)) eName="Netscape";
		 if (/firefox/i.test(uAgent)) eName="FireFox";
		 if (/chimera/i.test(uAgent)) eName="Chimera";
		 if (/camino/i.test(uAgent)) eName="Camino";
		 if (/galeon/i.test(uAgent)) eName="Galeon";
		 if (/k-meleon/i.test(uAgent)) eName="K-Meleon";
		 eName+=" "+type;
	 }

	 if (/msie/i.test(uAgent)) {
		type="["+uAgent.split(";")[1].replace(/^\s+|\s+$/g,"")+"]"
		eName="Microsoft Internet Explorer";
		 if (/msn/i.test(uAgent)) eName="MSN";
		 if (/aol/i.test(uAgent)) eName="AOL";
		 if (/webtv/i.test(uAgent)) eName="WebTV";
		 if (/myie2/i.test(uAgent)) eName="MyIE2";
		 //if (/maxthon/i.test(uAgent)) eName="Maxthon";
		 if (/gosurf/i.test(uAgent)) eName="GoSurf";
		 if (/netcaptor/i.test(uAgent)) eName="NetCaptor";
		 if (/sleipnir/i.test(uAgent)) eName="Sleipnir";
		 if (/avant browser/i.test(uAgent)) eName="AvantBrowser";
		 if (/greenbrowser/i.test(uAgent)) eName="GreenBrowser";
		 if (/slimbrowser/i.test(uAgent)) eName="SlimBrowser";
		 if (/tencenttraveler/i.test(uAgent)) eName="Tencent Traveler";
		eName+=" "+type;
	 }
	 return eName
 }

function MediaPlayer_Check(){//媒体播放器检测
	var clsId="{22D6F312-B0F6-11D0-94AB-0080C74C7E95}";
	if (window.ActiveXObject){
		with(document.body){
			addBehavior('#default#clientcaps')
			VersionWord=isComponentInstalled(clsId,"componentid")?'<span class="right" style="color:red">ok</span>' + 'Microsoft Windows Media Player '+getComponentVersion(clsId,"componentid"):"<a href='javascript:;' class='test right' style='margin-right:3px' onclick='showObj(\"wmpInfo\");return false'>软件设置建议</a><span class='warning'>Microsoft Windows Media Player 未安装</span>";
		}
	}else{
		for (i=0;i<navigator.plugins.length;i++){
			if (navigator.plugins[i].name.substring(0,20)=="Windows Media Player"){
				VersionWord='<span class="right" style="color:red">ok</span>' + 'Microsoft Windows Media Player 已安装';
				break;
			}else{
				VersionWord="<span class='warning'>Microsoft Windows Media Player 未安装</span>";
			}
		}
	}
	return VersionWord;
}

function Flash_Check(){//Flash版本检测
	var clsId="{D27CDB6E-AE6D-11cf-96B8-444553540000}";
	if (window.ActiveXObject){
		with(document.body){
			addBehavior('#default#clientcaps')
			VersionWord=isComponentInstalled(clsId,"componentid")?'Adobe Flash Player '+getComponentVersion(clsId,"componentid"):"<a href='javascript:;' class='test right' style='margin-right:3px' onclick='showObj(\"wmpInfo\");return false'>软件设置建议</a><span class='warning'>Microsoft Windows Media Player 未安装</span>";
		}
	}else{
		for (i=0;i<navigator.plugins.length;i++){
			if (navigator.plugins[i].name.substring(0,20)=="Windows Media Player"){
				VersionWord="Adobe Flash Player 已安装";
				break;
			}else{
				VersionWord="<span class='warning'>Adobe Flash Player 未安装</span>";
			}
		}
	}
	return VersionWord;
}
	
function showObj(o){//显示对象
  o=document.getElementById(o);
  o.style.display=(o.style.display=="none")?"":"none";
}

function checkSystem(){//检测客户端系统
    sysName = getSystem();
    if (/windows/i.test(sysName)){
            if (/2000/i.test(sysName) || /2003/i.test(sysName) || /xp/i.test(sysName) || /Vista/i.test(sysName))
                return "<span class='right' style='color:red'>ok</span>" + sysName
            else
            {
                document.getElementById("sysInfo").style.display="";
                document.getElementById("systemTips").innerHTML="您的操作系统为 <b>"+sysName+"</b>，可能会影响您访问腾讯动画频道，我们建议您使用 windows 2000 或 windows xp 以上的操作系统"
                return sysName
            }
        }
    else   
    { 
        document.getElementById("sysInfo").style.display="";
        document.getElementById("systemTips").innerHTML="您的操作系统为 <b>"+sysName+"</b>，可能会影响您访问腾讯动画频道，我们建议您使用 windows 2000 或 windows xp 以上的操作系统"
        return "<span class='warning'>"+sysName+"</span>"
    }
}

function checkExplorer(){//检测客户端浏览器及版本
    expName = getExplorer();
    if (/msie/i.test(expName)){
        var ver = /\[(.*)\]/i.exec(expName)[1];
        if (ver.split(" ")[1] - 0 < 6.0) {
            document.getElementById("expInfo").style.display = "";
            document.getElementById("explorerTips").innerHTML = "您的IE浏览器内核版本为 <b>"+ver+"</b>。我们建议您升级到IE6.0以上版本，方可正常访问腾讯动画频道。<a href='http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=zh-cn&SrcCategoryId=&SrcFamilyId=1e1550cb-5e5d-48f5-b02b-20b602228de6&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fie6sp1%2ffinrel%2f6_sp1%2fW98NT42KMeXP%2fCN%2fie6setup.exe' target='_blank'class='test'>点击下载最新版的IE</a>，进行浏览器自动升级。"
            return "<span class='warning'>"+expName+"</span>"
        }
        else
            return "<span class='right' style='color:red'>ok</span>" + expName
    }
    else{
        document.getElementById("expInfo").style.display="";
        document.getElementById("explorerTips").innerHTML="您的浏览器为 <b>"+expName+"</b>，我们建议您使用IE浏览器，方可正常访问腾讯动画频道。"
        return "<span class='error'>"+expName+"</span>"
    }
}



function showTips(t,o){//显示提示语句
	for (i=2;i<arguments.length;i++){
		document.getElementById(arguments[i]).innerHTML = "";
	}
	o=document.getElementById(o);
	switch(t){
	 case 1:
	 	o.innerHTML='测试结果: 浏览器允许播放动画'
	 	break;	
	 case 2:
	 	//o.innerHTML='测试结果: 浏览器禁止播放动画<br/><a href="javascript:;" class="test" onclick=\'showObj("gifInfo");return false\'>软件设置建议</a>'
		o.innerHTML='测试结果: 浏览器禁止播放动画<br/><a href="../set_check.files/set_pictrue.html" class="test" style="margin-left:38px">软件设置建议</a>';	 	break;	
	 case 3:
	 	o.innerHTML='测试结果: 浏览器已经安装Flash插件，Flash播放正常'
	 	 document.getElementById('flashInfo').style.display='none';document.getElementById('delToolBar').style.display='none';
	 	break;	
	 case 4:
	 	o.innerHTML='测试结果: 系统安装了微软控件补丁，Flash动画需要点击激活<br/><a href="javascript:;" class="test" onclick=\'showObj("flashInfo");document.getElementById("delToolBar").style.display="none";return false\'>软件设置建议</a>'
	 	 document.getElementById('flashInfo').style.display='none';document.getElementById('delToolBar').style.display='none';
	 	 document.getElementById('sT1').style.display='';document.getElementById('sT2').style.display='none';
	 
	  	break;	
	 case 5:
	 	o.innerHTML='测试结果: Flash被屏蔽或者没有安装Flash插件<br/><a href="javascript:;" class="test" onclick=\'showObj("flashInfo");document.getElementById("delToolBar").style.display="none";return false\'>软件设置建议</a>'
	 	 document.getElementById('flashInfo').style.display='none';document.getElementById('delToolBar').style.display='none';
 	 	 document.getElementById('sT1').style.display='none';document.getElementById('sT2').style.display='';
	 	break;	
	}
}

function getClientInfo(){//获得客户端数据
	top.allowPost = true;
    document.getElementById("systemName").innerHTML = checkSystem();
    document.getElementById("explorerName").innerHTML = checkExplorer();
    document.getElementById("cookieEnable").innerHTML = (window.navigator.cookieEnabled)?'<span class="right" style="color:red">ok</span>' + '正常':'<a href="../set_check.files/set_cookie.html" class="test right" style="margin-right:3px">软件设置建议</a><span class="error">不允许</span>';
    document.getElementById("cookieInfo").style.display = (window.navigator.cookieEnabled)?"none":"";
    
    var screenPixel = screen.width + "*" + screen.height;
    document.getElementById("screen").innerHTML = screenPixel + " " + screen.colorDepth + "位色"
    if (screen.width<1024 || screen.height<768) document.getElementById("screenInfo").style.display = ""; else document.getElementById("screen").innerHTML = "<span class='right' style='color:red'>ok</span>" + document.getElementById("screen").innerHTML;
    document.getElementById("javascriptEnable").innerHTML = '<span class="right" style="color:red">ok</span>' + '正常';
    document.getElementById("jsInfo").style.display="none";
    document.getElementById("wmp").innerHTML = MediaPlayer_Check();	
    var fV = GetSwfVer();
    document.getElementById("flashPlayer").innerHTML = "Adobe Flash Player For " + fV;
    if (fV == -1){
    	top.data_Hash["flash_version"] = dataMap["noFlash"];
	    document.getElementById("noFlashPlayer").style.display = "";
    }
    else{
	    var intFV = fV.split(" ")[1].split(",")[0] - 0;
	    if (intFV < 8) {
		    document.getElementById("flashPlayerUpdate").style.display = "";
	    }else{
	    	document.getElementById("flashPlayer").innerHTML = '<span class="right" style="color:red">ok</span>' + document.getElementById("flashPlayer").innerHTML;
	    }
	    if (intFV >= 6) top.data_Hash["flash_version"] = dataMap["flash" + intFV]; else top.data_Hash["flash_version"] = dataMap["otherFlash"];
    }
    
    //--分析客户端参数
    top.data_Hash["os"] = (dataMap[sysName.toLowerCase()])?dataMap[sysName.toLowerCase()]:dataMap["otherSystem"];
    if (/msie/ig.test(expName)) {
    	ver = /\[msie\s(.*?)\]/ig.exec(expName)[1];
	    top.data_Hash["ieversion"] = (dataMap[ver])?dataMap[ver]:dataMap["otherExplorer"];
		
		if ((ver - 0) >= 6.0) {document.getElementById("explorerName").innerHTML += " 推荐使用IE浏览器打开空间"}
    }else{
	    top.data_Hash["ieversion"] = dataMap["otherExplorer"];
    }
    	
    top.data_Hash["distinguish_rate"] = (dataMap[screenPixel])?dataMap[screenPixel]:dataMap["othersize"];
    
	top.data_Hash["cookie_writable"] = (window.navigator.cookieEnabled)?dataMap["cookieEnable"]:dataMap["cookieDisable"];
	top.data_Hash["js_runnable"] = dataMap["javascriptEnable"];
	
	//top.data_Hash["activepic_playable"] = "";
	//top.data_Hash["flash_blocked"] = "";
}

function upF(){
	top.data_Hash["flash_update"] = dataMap['flashUpdate'];
}
	
// Flash 版本检测
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;
	try {
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.9");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	
	try {
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	
	try {
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			version = "WIN 6,0,21,0";
			axo.AllowScriptAccess = "always";
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

function GetSwfVer(){
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = "Mozilla " + versionMajor + "," + versionMinor + "," + versionRevision;
		}
	}
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}