host = 'http://' + location.host + '/';
/**
 * WPS官网下载统计
 */
var downloadWpsApp = function(){
    wpsBetaUrl = 'http://kad.www.wps.cn/wps/download/special/wpsptb.18.813.exe';
    wpsReleaseUrl = 'http://kad.www.wps.cn/wps/download/special/WPS2009.12012.exe';
    wpsGuide = host + 'index.php?mod=product&act=guide';
    betaId = 'wpsBeta';
    releaseClass = 'wpsRelease';
    parentId = 'bdy4';
    virtualLink = document.createElement('a');
    wpsReleaseVer = 'wps_1966';
    wpsBetaVer = 'wps_2063';
    /**
     * 虚拟链接处理
     */
    this.openNewWindowPre = function()//通过模拟点击超链接，打开新窗口,防止被弹出窗口被阻止
    {
        virtualLink.setAttribute('href', wpsGuide);
        virtualLink.setAttribute('target', '_blank');
        web = document.getElementById(parentId);
        web.appendChild(virtualLink);
    }
    /**
     * 测试版本和正式版本的下载处理
     */
    this.showUrl = function()//绑定URL
    {
        //测试版的下载地址处理	
        downBetaLink = document.getElementById(betaId);
        if (navigator.appVersion.match(/\bMSIE\b/)) {
            downBetaLink.href = '#';//如果支持javascript
        }
        downBetaLink.onclick = function(){
            if (navigator.appVersion.match(/\bMSIE\b/)) {
                virtualLink.click();
                this.href = wpsBetaUrl;
            }
            else {
                window.open(wpsGuide);
            }
            downloadRecord(wpsBetaVer);
        }
        document.getElementById(betaId).oncontextmenu = function()//右键菜单
        {
            this.href = wpsBetaUrl;
            downloadRecord(wpsBetaVer);
        }
        //正式版本的下载地址处理
        $('.' + releaseClass).each(function(){
            if (navigator.appVersion.match(/\bMSIE\b/)) {
                $(this).attr('href', '#');//如果支持javascript
            }
            $(this).click(function(){
                if (navigator.appVersion.match(/\bMSIE\b/)) {
                    virtualLink.click();
                    this.href = wpsReleaseUrl;
                }
                else {
                    window.open(wpsGuide);
                }
                downloadRecord(wpsReleaseVer);
            }).bind('contextmenu', function()//右键菜单
            {
                this.href = wpsReleaseUrl;
                downloadRecord(wpsReleaseVer);
            });
        });
    }
}
function IniLink()//初始化下载链接处理
{
    downloadWps = new downloadWpsApp();
    downloadWps.openNewWindowPre();//虚拟连接初始化
    downloadWps.showUrl();
}

//下载计数
function downloadRecord(prodVer){
    urchinTracker('pack/' + prodVer);//GA
    $.get(host + "index.php?mod=download&act=downwps", function(msg){
        $('#WPSDownNum').html(msg);
    });
}
//下载链接处理
if (window.addEventListener) {
    window.addEventListener('load', IniLink, false);
}else if (window.attachEvent) {
	window.attachEvent('onload', IniLink);
}
function tuijian(i){
    var tui_1 = document.getElementById("tui_1");
    var tui_2 = document.getElementById("tui_2");
    var tui_3 = document.getElementById("tui_3");
    
    var tuishow_1 = document.getElementById("tuishow_1");
    var tuishow_2 = document.getElementById("tuishow_2");
    var tuishow_3 = document.getElementById("tuishow_3");
    if (i == 1) {
        tui_1.className = "tui_now";
        tuishow_1.style.display = "block";
        
        tui_2.className = "tui_not";
        tuishow_2.style.display = "none";
        
        tui_3.className = "tui_not";
        tuishow_3.style.display = "none";
        
    }
    else 
        if (i == 2) {
            tui_1.className = "tui_not";
            tuishow_1.style.display = "none";
            
            tui_2.className = "tui_now";
            tuishow_2.style.display = "block";
            
            tui_3.className = "tui_not";
            tuishow_3.style.display = "none";
        }
        else {
            tui_1.className = "tui_not";
            tuishow_1.style.display = "none";
            
            tui_2.className = "tui_not";
            tuishow_2.style.display = "none";
            
            tui_3.className = "tui_now";
            tuishow_3.style.display = "block";
        }
}

function OnbulrQuestion(){
    if (document.getElementById("myquestion").value.replace(/(^\s*)|(\s*$)/g, "") == "") {
        document.getElementById("myquestion").value = "请输入问题";
    }
}

function onclickQuestion(){
    keyword = document.getElementById("myquestion").value;
    if (keyword.replace(/(^\s*)|(\s*$)/g, "") == "请输入问题") {
        document.getElementById("myquestion").value = "";
    }
}

function onsubmitQuestion(){
    keyword = document.getElementById("myquestion").value;
    if (keyword.replace(/(^\s*)|(\s*$)/g, "") == "请输入问题") {
        document.getElementById("myquestion").value = "";
        return true;
    }
}
