﻿//多图片上传页面
function initialPlayer(swfName, flashID, w, h, flashOutID, paras) {
    if (!checkFlashVesion(flashOutID)) {
        var so = new SWFObject(swfName, flashID, w, h, "10.0.0", "#FFFFFF");
        so.addParam("allowNetworking", "all");
        so.addParam("allowScriptAccess", "always");
        so.addParam("allowFullScreen", "true");
        so.addParam("scale", "noscale");
        so.addParam("wmode", "window");
        if (paras != undefined) {
            var ps = paras.split('&&');
            for (var i = 0; i < ps.length; i++) {
                var items = ps[i];
                var ims = items.split('==');
                so.addVariable(ims[0], ims[1]);
            }
        }
        so.write(flashOutID);
    }
    this.flashProxy = document.getElementById(flashID);
}
//验证flash插件版本
function checkFlashVesion() {
    var hasFlash=0;             //是否安装了flash
    var flashVersion=0;            //flash版本
    var isIE=/*@cc_on!@*/0;      //是否IE浏览器
    if(isIE)
    {
        var  swf  = null;
        try{ swf=  new  ActiveXObject('ShockwaveFlash.ShockwaveFlash');  }catch(e){}
        if(swf) {
            hasFlash=1;
            VSwf=swf.GetVariable("$version");
            flashVersion=parseInt(VSwf.split(" ")[1].split(",")[0]);        
        }
    }else{
        if (navigator.plugins && navigator.plugins.length > 0)
        {
            var swf= null;
            try{ swf=navigator.plugins["Shockwave Flash"]; }catch(e){}
            if (swf)
             {
                 hasFlash=1;
                var words = swf.description.split(" ");
                for (var i = 0; i < words.length; ++i)
                {
                    if (isNaN(parseInt(words[i]))) continue;
                    flashVersion = parseInt(words[i]);
                }
            }
        }
    }
    if (flashVersion < 10 && arguments[0] == undefined) {
        var llq = "ie";
        if (isIE)llq = "ie";
        else llq = "firefox";
        document.write("<div><div style=\"padding:10px; text-align:center;\"><img src=\"http://static.diyifangwu.com/images/noflashplayer.gif\" width=\"296\" height=\"59\" /></div>");
        document.write("<div style=\"padding:10px; text-align:center;\">");
        document.write("<a target=\"_blank\" href=\"http://www.adobe.com/go/getflashplayer\">");
        document.write("<img src=\"http://static.diyifangwu.com/images/get_adobe_flash_player.png\" border=\"0\"></a> ");
        document.write("<a target=\"_blank\" href=\"http://static.diyifangwu.com/Flash/install_flash_player(" + llq + ").exe\" onclick='javascript: pageTracker._trackPageview(\"/downloads/flas\")'>点击下载</a></div></div>");
        return true;
    }
    if (flashVersion < 10) return true;
    return false;
}
//房源页面调用全景
var webFlashObj;
function fuYeFlashInit() {
    if (!checkFlashVesion("dfwViewer")) {
        var a = arguments;
        webFlashObj = new fhouse("dfwViewer", new fhouseOption(a[0], a[1], a[2], a[3], a[4], a[5]));
        webFlashObj.addEventListener(fhouse.EVENT_FLASH_INITIALIZED, onFlash_InitializedComplete, webFlashObj);
    }
}
function fhouseOption() {
    var a = arguments;
    this.staticType = "fhouseOption"; //readOnly
    this.flashID = "flashFy";
    this.wmode = "transparent";
    this.filePath = "http://pic.diyifangwu.com/dfwviewer/1.4/fhmain.swf";
    this.configFile = "http://roompano.diyifangwu.com/panolib/" + a[0] + "-" + a[1] + "-" + a[2] + "-" + a[3] + "-" + a[4] + "-" + a[5] + ".xml";  //CONFIG文件 
    this.panoDomain = "http://roompano.diyifangwu.com/panolib/"; //全景图片的域
    this.panoInfoDomain = "http://roompano.diyifangwu.com/panolib/"; //全景信息的域
    //this.mapDomain = ""; //地图数据的域
    this.mapAjax = "http://poimark.diyifangwu.com/ajax/pxy.imap?";
    this.href = location.href;
    this.key = "ABQIAAAArhBcN2pSMMAqfDmh0qfe_xQAWyS5ifvXkMGO5iX-tEXBlUmSMxRcwEo7P4hl7Kr86p7E3CrHDRC8hw";

};
//列表页面全景
function searListFlashInit() {
    if (!checkFlashVesion("searFlashDiv")) {
        var a = arguments;
        webFlashObj = new fhouse("searFlashDiv", new searFlashInit(a[0], a[1]));
        webFlashObj.addEventListener(fhouse.EVENT_FLASH_INITIALIZED, onFlash_InitializedComplete, webFlashObj);
    }
}
function searFlashInit() {
    var a = arguments;
    this.staticType = "fhouseOption"; //readOnly
    this.flashID = "flashFy";
    this.wmode = "transparent";
    this.filePath = "http://pic.diyifangwu.com/dfwviewer/1.4/fhmain.swf";
    this.configFile = "http://static.diyifangwu.com/panolib/021/" + a[0] + "/" + a[1] + ".xml";  //CONFIG文件 
    this.panoDomain = "http://pic.diyifangwu.com/panolib/"; //全景图片的域
    this.panoInfoDomain = "http://pic.diyifangwu.com/panolib/"; //全景信息的域
    //this.mapDomain = ""; //地图数据的域
    this.mapAjax = "http://poimark.diyifangwu.com/ajax/pxy.imap?";
    this.href = location.href;
    this.key = "ABQIAAAArhBcN2pSMMAqfDmh0qfe_xQAWyS5ifvXkMGO5iX-tEXBlUmSMxRcwEo7P4hl7Kr86p7E3CrHDRC8hw";
};

function indexFlashLoad() {
    if (!checkFlashVesion("indexpano")) {
        webFlashObj = new fhouse('indexpano', new indexFlashInit());
        webFlashObj.addEventListener(fhouse.EVENT_FLASH_INITIALIZED, onFlash_InitializedComplete, webFlashObj);
    }
};

function indexFlashInit() {
    var a = arguments;
    this.staticType = "fhouseOption"; //readOnly
    this.flashID = "indexpano";
    this.wmode = "transparent";
    this.filePath = "http://pic.diyifangwu.com/dfwviewer/1.4/fhmain.swf";
    this.configFile = "http://sh.diyifangwu.com/config/homepage/homepage.xml";   //CONFIG文件 
    this.panoDomain = "http://pic.diyifangwu.com/panolib/"; //全景图片的域
    this.panoInfoDomain = "http://pic.diyifangwu.com/panolib/"; //全景信息的域
    //this.mapDomain = ""; //地图数据的域
    this.mapAjax = "http://poimark.diyifangwu.com/ajax/pxy.imap?";
    this.href = location.href;
    this.key = "ABQIAAAArhBcN2pSMMAqfDmh0qfe_xQAWyS5ifvXkMGO5iX-tEXBlUmSMxRcwEo7P4hl7Kr86p7E3CrHDRC8hw";
};
function uploadSNeiQJingFlashInit() {
    if (!checkFlashVesion("upLoadQJFlash")) {
        var so = new SWFObject("http://pic.diyifangwu.com/dfwViewer/panoUpload.swf", "upLoadQJFlash", "100%", "100%", "10.0.0", "#FFFFFF");
        so.addParam("allowNetworking", "all");
        so.addParam("allowScriptAccess", "always");
        so.addParam("allowFullScreen", "true");
        so.addParam("scale", "noscale");
        so.addParam("wmode", "window");
        var a = arguments;
        so.addVariable("upLoadPage", "http://roompano.diyifangwu.com/panoupload/panoupload.aspx?action=uploadimage");
        so.addVariable("initDataPage", "http://roompano.diyifangwu.com/panoupload/panoupload.aspx?action=manageimage");
        so.addVariable("deletePage", "http://roompano.diyifangwu.com/panoupload/panoupload.aspx?action=deleteimage");
        so.addVariable("updatePage", "http://roompano.diyifangwu.com/panoupload/panoupload.aspx?action=updateimagedes&uid="+a[0]);
        so.addVariable("lptype", a[1]);
        so.addVariable("fytype", a[2]);
        so.addVariable("id", a[3]);
        so.addVariable("maxUpLoadFile", 28);
        so.write("upLoadQJFlash");
    }
};
var isPlay = true; //是否开始播放，默认为true，初始化完成即播放
function onFlash_InitializedComplete() {
    if (isPlay) {
        if (webFlashObj != null && webFlashObj != undefined) webFlashObj.fhouseActive();
    }
    flashTrace("init");
};


//跟踪flash操作时间
function flashTrace(p) {
    var path = '/flash/';
    switch (p) {
        case "playPauseMovie":
            path += "play/" + fhtID;
            break;
        case "showHideMap":
            path += "map/" + fhtID;
            break;
        case "subMenuClick":
            path += "submenu/" + fhtID;
            break;
        case "fullScreen":
            path += "quanping/" + fhtID;
            break;
        case "roadFlag":
            path += "step/" + fhtID;
            break;
        case "init":
            path += "loaded/" + fhtID;
    }
    if (pageTracker != null && pageTracker != undefined) {
        pageTracker._trackPageview(path);
    }
};

function getEvent(e) {
    if (e) return e;
    return window.event;
};
function getEventObj(e) {
    if (e) return e.target;
    return window.event.srcElement;
};
function stopEvent(e) {
    if (!e) window.event.returnValue = false;
    else e.preventDefault();
};

function handleKeyDOWN(e) {
    var xe = getEvent(e);
    var objID = getEventObj(e);
    if (objID.id == "fhouse0") {
        stopEvent(e);
        var o;
        o = (document.all) ? { delta: xe.wheelDelta / 12} : { delta: -xe.detail };
        if (webFlashObj != null && webFlashObj != undefined) webFlashObj.handleWheel(o);
    }
    else {
        playFlash();
    }
    return;
};

function playFlash() {
    if (!isPlay) {
        var sTop = 0; //滚轮移动的距离
        var dfwTop = $("#dfwViewer").offset().top + 500; //flash对象，距body对象顶端的距离
        var screenLookHeight = $(window).height(); //屏幕可视高度
        if (document.compatMode == 'BackCompat') sTop = document.body.scrollTop;
        else sTop = document.documentElement.scrollTop == 0 ? document.body.scrollTop : document.documentElement.scrollTop;
        if (!isPlay && (sTop + screenLookHeight) >= dfwTop) {
            isPlay = true;
            if (webFlashObj != null && webFlashObj != undefined) webFlashObj.fhouseActive();
        }
    }
}

if (document.all) document.onmousewheel = handleKeyDOWN;
else window.addEventListener("DOMMouseScroll", handleKeyDOWN, false);

window.onscroll = function () {
    playFlash();
}

function ListFlash() {
    var a = arguments;
    var so = new SWFObject("http://static.diyifangwu.com/Flash/fpano.swf", "fpano", 206, 153, "10.0.0", "#ffffff");
    so.addParam("quality", "high");
    so.addParam("salign", "lt");
    so.addParam("allowScriptAccess", "always");
    so.addParam("wmode", "Transparent");
    so.addVariable("url", "http://pic.diyifangwu.com/panolib/" + a[0] + "-" + a[1] + "-" + a[2] + "-" + a[3] + ".jpg");
    so.addVariable("p", "0");
    so.addVariable("t", "1");
    so.addVariable("f", "90");
    so.write("flashcontent");
}
