﻿var swfVersionStr = "10.0.0";
var xiSwfUrlStr = "";
var flashvars = {
    SwfFile: escape(""),
    Scale: 1,
    ZoomTransition: "easeOut",
    ZoomTime: 0.1,
    ZoomInterval: 0.1,
    MaxZoomSize: 2,
    FitPageOnLoad: true,
    FitWidthOnLoad: true,
    PrintEnabled: true,
    FullScreenAsMaxWindow: false,
    ProgressiveLoading: true,

    PrintToolsVisible: true,
    ZoomToolsVisible: true,
    FullScreenVisible: true,
    NavToolsVisible: true,
    SearchToolsVisible: true,
    ViewModeToolsVisible: true,

    CursorToolsVisible: true,

    localeChain: "zh_CN"
};
var flashvars_Simple = {
    SwfFile: escape(""),
    Scale: 1,
    ZoomTransition: "easeOut",
    ZoomTime: 0.1,
    ZoomInterval: 0.1,
    MaxZoomSize: 2,
    FitPageOnLoad: true,
    FitWidthOnLoad: true,
    PrintEnabled: true,
    FullScreenAsMaxWindow: false,
    ProgressiveLoading: true,

    PrintToolsVisible: true,
    ZoomToolsVisible: true,
    FullScreenVisible: true,
    NavToolsVisible: true,
    SearchToolsVisible: true,

    ViewModeToolsVisible: false,
    CursorToolsVisible: false,

    localeChain: "zh_CN"
};
var params = {}
params.quality = "high";
params.wmode = "transparent";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "FlexPaperViewer";
attributes.name = "FlexPaperViewer";
//新建一个文档播发器
function CreateFlexpaper(swfFile, width, hight, playContentID) {
    swfFile = swfFile.replace("_1.swf", ".swf");
    if (width >= 650) {
        flashvars.SwfFile = escape(swfFile);
        swfobject.embedSWF(
     "http://docshare.mingdao.com/javascript/FlexPaper/FlexPaperViewer.swf", playContentID,
    width, hight,
    swfVersionStr, xiSwfUrlStr,
    flashvars, params, attributes);
    } else {
        flashvars_Simple.SwfFile = escape(swfFile);
        swfobject.embedSWF(
     "http://docshare.mingdao.com/javascript/FlexPaper/FlexPaperViewer.swf", playContentID,
    width, hight,
    swfVersionStr, xiSwfUrlStr,
    flashvars_Simple, params, attributes);
    }
  
    var shareID = playContentID.substr(11);
    RequestWebService(shareID);
}

var xmlHttp;
function createXmlHttp() {
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest(); //mozilla浏览器
    }
    else if (window.ActiveXObject) {
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); //ＩＥ旧版本
        }
        catch (e) {
        }
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); //ＩＥ新版本
        }
        catch (e) {
        }
        if (!xmlHttp) {
            window.alert("不能创建XMLHTTPREQUEST对象!");
            return false;
        }
    }
}
//function RequestWebService(shareID) {
//    createXmlHttp();
//    //使用ＧＥＴ方式
//    var url = "http://docshare.mingdao.com/actionpage/UpdateViewCount.ashx?ShareID=" + shareID;
//    xmlHttp.open("GET", url, true);
//    //xmlHttp.onreadystatechange = bindclass;
//    xmlHttp.send(null);
//}

function RequestWebService(shareID) {
    var url = "http://docshare.mingdao.com/actionpage/UpdateViewCount.ashx?ShareID=" + shareID;
    $.getJSON("http://docshare.mingdao.com/Service/UpdateViewCount.asmx/UpdateDocShareCounts?callback=?",
               { shareID: shareID },
                function (data) {
                    //alert(decodeURI(data.msg))
                });
}

