﻿/*************************************************************************************
 *   
 *  Leador CYJ 3D JavaScript
 *
 *  (c) 2006 CopyRight Leador CO.,LTD. All Right Reserved.
 *
 *  http://www.leador.com.cn
 *
 *  修改记录: 朱亮 2006-12-11 (创建) 数字创业街前台JS脚本      
 *************************************************************************************/
 
/*************************************************************************************
 *  配置属性区
 * 
 *  RequestPageUrl 无刷新数据请求页面URL 例如 "./AjaxReturn.aspx";
 *
 *  RequestVrmlUrl 无数新模型请求页面URL 例如 "AjaxVrml.aspx";
 *
 *  TempleteUrl    模板资源XML文件URL    例如 "Data/Templete.xml"
 *   
 *************************************************************************************/
//无刷新请求页面
var RequestPageUrl = "./AjaxReturn.aspx";
var RequestVrmlUrl = "AjaxVrml.aspx";
var TempleteUrl    = "Data/Templete.xml";
 
/*************************************************************************************
 *  公共变量区
 *************************************************************************************/
//程序虚拟路径
var VirtualPath    = "";
//位置模型集合
var arrLocation    = new ArrayList(); 
//标记模型集合
var arrMarkUrl     = new ArrayList();
//当前位置模型
var SingleLocation = null;
//当前Vrml文件
var CurrentVrml    = "";
//临时Guid
var NewGuid        = "";
var GuidIsUsed     = false;
var TempControl    = new ArrayList(); 
//是否登录
var LoginFlag      = false;
//导航图偏移位置
var MarkOffSetX    = 678;
//var MarkOffSetY    = 109;
var MarkOffSetY    = 134;

/*************************************************************************************
 *  通用方法区
 *************************************************************************************/
//起始调用事件
function start(SceneID,VrmlUrl)
{
    if(!SceneID.Engine)
    {
        alert("请先安装VRML浏览插件!");
    }
    else
    {
        //检测是否登录
        CheckLogined()
        if(VirtualPath == "")
        {
            VirtualPath = GetVirtualPath();
        }
        Init(SceneID);
        var arrParam = GetRequestParam();
        //假如链接参数存在vrml请求
        if(arrParam.vrml)
        {
            SetCurrentVrmlUrl(VirtualPath + arrParam.vrml);
            if(arrParam.px)
            {
                $(txtPx).value   = arrParam.px; 
                $(txtPy).value   = arrParam.py; 
                $(txtPz).value   = arrParam.pz; 
                $(txtOx).value   = arrParam.ox; 
                $(txtOy).value   = arrParam.oy; 
                $(txtOz).value   = arrParam.ox; 
                $(txtOa).value   = arrParam.oa;
                setTimeout("SetLocation()", 1000);
            } 
        }
        else
        {
            SetCurrentVrmlUrl(VirtualPath + VrmlUrl); 
        }
        setTimeout(InitVrml,1000);
        var VrmlUrl = GetCurrentVrmlUrl();
        VrmlUrl = VrmlUrl.replace(VirtualPath, "");
        CurrentVrml = VrmlUrl;
        timerID1 = setTimeout("dispLocation()", 3000);
        SetFocus();
        GetFloorList();
    }
}

//显示位置信息
function dispLocation() 
{ 
    if(GetControlState() > 1)
    {
        var curLocation = GetLocationByPS('PS');
        var px = curLocation.GetPx(); 
        var py = curLocation.GetPy(); 
        var pz = curLocation.GetPz(); 
        var ox = curLocation.GetOx(); 
        var oy = curLocation.GetOy(); 
        var oz = curLocation.GetOz(); 
        var oa = curLocation.GetOa(); 
        MapShow(px, pz);
    }
    timerID2 = setTimeout("dispLocation()", 1000); 
}

//计算在图片中位置
function MapShow(px, pz)
{
    var objx = MarkOffSetX
    var objy = MarkOffSetY;
    if(CurrentVrml == "vrasp/out/out.wrl")
    {
        objx += Math.round((px / 1.354) + 73.17);       
        objy += Math.round((pz / 1.150) + 320);
    }
    else if(CurrentVrml == "vrasp/in/entry.wrl")
    {
        objx += 150;       
        objy += 68;
    }
    else if(CurrentVrml == "vrasp/in/restaurant.wrl")
    {
        objx += 177;       
        objy += 65;
    }
    else
    {
        var v = CurrentVrml.split('-');
        if( v[0] == "vrasp/in/1")
        {
            objx += 17;       
            objy += 69;
        }
        else if( v[0] == "vrasp/in/2")
        {
            objx += 45;       
            objy += 70;
        }
        else if( v[0] == "vrasp/in/3")
        {
            objx += 73;       
            objy += 68;
        }
        else if( v[0] == "vrasp/in/5")
        {
            objx += 107;       
            objy += 66;
        }
        else if( v[0] == "vrasp/in/6")
        {
            objx += 137;       
            objy += 66;
        }
        else if( v[0] == "vrasp/in/7")
        {
            objx += 165;       
            objy += 65;
        }
        else if( v[0] == "vrasp/in/8")
        {
            objx += 193;       
            objy += 65;
        }
        else if( v[0] == "vrasp/in/10")
        {
            objx += 253;       
            objy += 103;
        }
    }
    SetObjMark(objx, objy);
}

//显示在图片中位置
function SetObjMark(aimX, aimY)
{
     $(objMark).style.left = aimX;
     $(objMark).style.top  = aimY;  
}

//导航图跳转
function MapJump()
{
    if(CurrentVrml == "vrasp/out/out.wrl")
    {
        var inMapX = parseInt(event.x) - MarkOffSetX;
        var inMapY = parseInt(event.y) - MarkOffSetY;
        //window.status = "inMapX:" +inMapX + " inMapY:" + inMapY;
        var inVrmlX = (inMapX - 73.17) * 1.354;
        var inVrmlZ = (inMapY - 320) * 1.150;
        var curLocation = GetLocationByPS('PS');
        curLocation.SetPx(inVrmlX);
        curLocation.SetPz(inVrmlZ); 
        SetVP("view0");
        SetViewPosition("view1",curLocation.position);
        SetViewOrientation("view1",curLocation.orientation);
        SetVP("view1");
        ShowStateInfo("导航坐标应用成功!");
    }
    else
    {
        ShowStateInfo("大楼内不能进行导航!");
    }
    SetFocus();
}

//获取场景坐标到编辑框
function GetLocation()
{
    var curLocation = GetLocationByPS('PS');
    FillTextBoxByLocation(curLocation);
    ShowStateInfo("获取场景坐标成功!");
    InitializeInfo();
}

//应用编辑框信息到场景
function SetLocation()
{
    if(GetControlState() > 1)
    {
        if(!ValidateLocation())
        {
            ShowStateInfo("场景坐标格式不正确!");
            return;
        }
        SetVP("view0");
        var curLocation = new Location();
        curLocation.SetPx($F(txtPx));
        curLocation.SetPy($F(txtPy));
        curLocation.SetPz($F(txtPz));
        curLocation.SetOx($F(txtOx));
        curLocation.SetOy($F(txtOy));
        curLocation.SetOz($F(txtOz));
        curLocation.SetOa($F(txtOa));
        SetViewPosition("view1",curLocation.position);
        SetViewOrientation("view1",curLocation.orientation);
        SetVP("view1");
        ShowStateInfo("应用场景坐标成功!");
    }
    else
    {
        setTimeout("SetLocation()", 1000); 
    }
}

//显示状态信息
function ShowStateInfo(StateInfo)
{
     $(lblMsg).innerHTML = StateInfo;
}

//加载场景标记
function LoadMarkUrlModel(LocationModelsXml)
{
    ShowStateInfo("正在加载场景标记!");
    arrMarkUrl = GetMarkUrlXmlData(LocationModelsXml);
    setTimeout("ImportVrmlByArray()", 1000); 
}

function ImportVrmlByArray()
{
    if(GetControlState() > 1)
    {
        var length = arrMarkUrl.GetLength();
        for(var i = 0; i < length; i++)
        {
            var markUrl = arrMarkUrl.Item(i);
            ImportVrmlByModel(markUrl);
        }
        
        ShowStateInfo("场景标记加载已完成!");
    }
    else
    {
        setTimeout("ImportVrmlByArray()", 1000); 
    }
}

//显示位置信息列表
function ShowLocationList(LocationModelsXml)
{
    ShowStateInfo("正在处理检索结果!");
    arrLocation = GetLocationsXmlData(LocationModelsXml);
    ShowMarkLink();  
    FillTextBoxByArrayList(0);
    ShowStateInfo("检索已完成!");
}

//显示标记连接
function ShowMarkLink()
{
    InitializeTextBox();
    var MarkMsg = "位置列表:<br/><br/>"; 
    var arrLength = arrLocation.GetLength();
    for(var i = 0; i < arrLength; i++)
    {
        MarkMsg += "<a href = '#' onclick = ShowMark(";
        MarkMsg += i;
        MarkMsg += ")>";
        MarkMsg += arrLocation.Item(i).Name;
        MarkMsg += "</a> <br/>";
    }
    $(divMark).innerHTML = MarkMsg;
}

//响应视点切换
function ShowMark(index)
{
    SingleLocation = arrLocation.Item(index);
    ShowCurrentVrml();
}

//显示当前Vrml
function ShowCurrentVrml()
{
    LoadMark();
    SetMark();
    SetFocus();   
}

//载入当前Vrml
function LoadMark()
{
    //判断场景切换
    var VrmlUrl = SingleLocation.VrmlUrl;
    VrmlUrl = VirtualPath +  VrmlUrl;
    if(VrmlUrl != GetCurrentVrmlUrl())
    {
        SetCurrentVrmlUrl(VrmlUrl);
        setTimeout(InitVrml,1000);
        CurrentVrml = SingleLocation.VrmlUrl;
    }
}

//应用当前Vrml
function SetMark()
{
    if(GetControlState() > 1)
    {
        SetVP("view0");
        SetViewPosition("view1",SingleLocation.position);
        SetViewOrientation("view1",SingleLocation.orientation);
        FillTextBoxByLocation(SingleLocation);
        SetVP("view1");
        ShowStateInfo("应用场景坐标成功!");
    }
    else
    {
        setTimeout("SetMark()", 1000); 
    }
}


//通过模型填充编辑框
function FillTextBoxByLocation(curLocation)
{
    $(txtName).value       = curLocation.Name; 
    $(txtGuid).value       = curLocation.Guid; 
    $(txtPx).value         = curLocation.GetPx(); 
    $(txtPy).value         = curLocation.GetPy(); 
    $(txtPz).value         = curLocation.GetPz(); 
    $(txtOx).value         = curLocation.GetOx(); 
    $(txtOy).value         = curLocation.GetOy(); 
    $(txtOz).value         = curLocation.GetOz(); 
    $(txtOa).value         = curLocation.GetOa();
   
    $(txtPlace).value      = curLocation.Place; 
    $(txtFloor).value      = curLocation.Floor; 
    $(txtAddress).value    = curLocation.Address; 
    $(txtTel).value        = curLocation.Tel; 
    $(txtFax).value        = curLocation.Fax; 
    $(txtWeb).value        = curLocation.Web; 
    $(txtLinkMan).value    = curLocation.LinkMan; 
    $(txtEnterTime).value  = curLocation.EnterTime; 
    $(txtCorpType).value   = curLocation.CorpType; 
    $(txtIntro).value      = curLocation.Intro; 
    $(txtOperation).value  = curLocation.Operation; 
    $(txtMemo).value       = curLocation.Memo;
    $(txtFund).value       = curLocation.Fund; 
    $(txtProduceUrl).value = curLocation.ProduceUrl;  
}

//通过编辑框填充模型
function FillLocationByTextBox(curLocation)
{
    curLocation.Name = $F(txtName);
    curLocation.Guid = $F(txtGuid); 
    curLocation.SetPx($F(txtPx));
    curLocation.SetPy($F(txtPy));
    curLocation.SetPz($F(txtPz));
    curLocation.SetOx($F(txtOx));
    curLocation.SetOy($F(txtOy));
    curLocation.SetOz($F(txtOz));
    curLocation.SetOa($F(txtOa));
    
    curLocation.Place      = $F(txtPlace);
    curLocation.Floor      = $F(txtFloor);
    curLocation.Address    = $F(txtAddress);
    curLocation.Tel        = $F(txtTel); 
    curLocation.Fax        = $F(txtFax);
    curLocation.Web        = $F(txtWeb); 
    curLocation.LinkMan    = $F(txtLinkMan);
    curLocation.EnterTime  = $F(txtEnterTime); 
    curLocation.CorpType   = $F(txtCorpType);
    curLocation.Intro      = $F(txtIntro); 
    curLocation.Operation  = $F(txtOperation);
    curLocation.Memo       = $F(txtMemo);
    curLocation.Fund       = $F(txtFund);
    curLocation.ProduceUrl = $F(txtProduceUrl);
}

//通过数组填充编辑框
function FillTextBoxByArrayList(index)
{             
    var arrLength = arrLocation.GetLength();
    if(index < arrLength)
    {
        FillTextBoxByLocation(arrLocation.Item(index));
    }
    else
    {    
        ShowStateInfo("对不起,未找到匹配场景坐标!");
    }
}

//初始化编辑框
function InitializeTextBox()
{
    $(txtName).value = ""; 
    $(txtGuid).value = "";
    $(txtPx).value   = "";
    $(txtPy).value   = "";
    $(txtPz).value   = "";
    $(txtOx).value   = ""; 
    $(txtOy).value   = "";
    $(txtOz).value   = "";
    $(txtOa).value   = "";
    InitializeInfo();
}

//初始化提示信息
function InitializeInfo()
{
    $(txtNameInfo).innerHTML = ""; 
    $(txtPxInfo).innerHTML   = "";
    $(txtPyInfo).innerHTML   = "";
    $(txtPzInfo).innerHTML   = "";
    $(txtOxInfo).innerHTML   = ""; 
    $(txtOyInfo).innerHTML   = "";
    $(txtOzInfo).innerHTML   = "";
    $(txtOaInfo).innerHTML   = "";
}


//同步更新数组中模型信息
function UpdateArrayList()
{
    var strGuid = $F(txtGuid);   
    var arrLength = arrLocation.GetLength();
    for(var i = 0; i < arrLength; i++)
    {
        if(arrLocation.Item(i).Guid == strGuid)
        {
            FillLocationByTextBox(arrLocation.Item(i));
            ShowMarkLink();
            FillTextBoxByArrayList(i);
        }
    }
}

//同步删除数组中模型信息
function DeleteArrayList()
{
    var strGuid = $F(txtGuid);
    var arrLength = arrLocation.GetLength();
    for(var i = 0; i < arrLength; i++)
    {
        if(arrLocation.Item(i).Guid == strGuid)
        {
            arrLocation.Remove(arrLocation.Item(i));
            ShowMarkLink();
            FillTextBoxByArrayList(0);
        }
    }
}


//验证Guid
function ValidateGuid()
{
    if($F(txtGuid) == "")
        return false;
    else
        return true;
}


//验证输入框
function ValidateTextBox()
{
    var validateValue = true;
    validateValue &= isEmpty("txtName",true);
    validateValue &= ValidateLocation();
    return validateValue;
}

//验证位置参数
function ValidateLocation()
{
    var validateValue = true;
    validateValue &= isNumber("txtPx",true);
    validateValue &= isNumber("txtPy",true);
    validateValue &= isNumber("txtPz",true);
    validateValue &= isNumber("txtOx",true);
    validateValue &= isNumber("txtOy",true);
    validateValue &= isNumber("txtOz",true);
    validateValue &= isNumber("txtOa",true);
    return validateValue;
}

//通过输入框导入VRML
function ImportVrmlByTextBox()
{
    var url = VirtualPath + RequestVrmlUrl;
    url += "?randnum=";
    url += Math.random();
    url += "&x="
    url += $F(txtPx);
    url += "&y="
    url += $F(txtPy);
    url += "&z="
    url += $F(txtPz);
    url += "&target="
    url +=  $F(sltTarget);
    url += "&url="
    url +=  $F(txtUrl);
    AddVrmlByUrl(url);
}

//通过模型导入VRML
function ImportVrmlByModel(markUrl)
{
    var url = VirtualPath + RequestVrmlUrl;
    url += "?randnum=";
    url += Math.random();
    url += "&x="
    url += markUrl.GetPx();
    url += "&y="
    url += markUrl.GetPy();
    url += "&z="
    url += markUrl.GetPz();
    url += "&target="
    url += markUrl.Target;
    url += "&url="
    url += markUrl.Url;
    AddVrmlByUrl(url);
}

//初始化Vrml(载入Vrml初始化数据)
function InitVrml()
{
    if(GetControlState() > 1)
    {
        var VrmlUrl = GetCurrentVrmlUrl();
        VrmlUrl = VrmlUrl.replace(VirtualPath, "");
        var url = VirtualPath + RequestVrmlUrl;
        url += "?randnum=";
        url += Math.random();
        url += "&vrml="
        url += VrmlUrl;
        AddVrmlByUrl(url);
    }
    else
    {
        setTimeout(InitVrml,1000);
    }
}

//填充Guid到文本框
function FillTextBoxByGuid(Control)
{
    if(NewGuid == "" || GuidIsUsed)
    {
        TempControl.Add(Control);
        GetGuid();
        setTimeout(FillGuidToTextBox,100);
    }
    else
    {
        Control.value = NewGuid;
        GuidIsUsed = true;
        GetGuid();
    }
}

//填充Guid到文本框(setTimeout 调用)
function FillGuidToTextBox()
{
    if(NewGuid == "" || GuidIsUsed)
    {
        GetGuid();
        setTimeout(FillGuidToTextBox,100);
    }
    else
    {
        var length = TempControl.GetLength();
        if(length > 0)
        {
            TempControl.Item(0).value = NewGuid;
            TempControl.Remove(TempControl.Item(0));
            GuidIsUsed = true;
            GetGuid();
        }
        length = TempControl.GetLength();
        if(length > 0)
        {
            setTimeout(FillGuidToTextBox,100);
        }
    }
}

function ShowSingleLocation()
{
    if(SingleLocation)
    {
        var Msg =" <img src='./images/btnJump.png' alt='转到该处' border='0' onclick='ShowCurrentVrml();' style='cursor:hand;'/>";
        Msg +=" <img src='./images/btnIntro.png' alt='企业介绍' border='0' onclick='ShowLocationIntro();' style='cursor:hand;'/>";
        Msg +=" <img src='./images/btnOperation.png' alt='业务范围' border='0' onclick='ShowLocationOperation();' style='cursor:hand;'/>";
        Msg +=" <img src='./images/btnMemo.png' alt='备注说明' border='0' onclick='ShowLocationMemo();' style='cursor:hand;'/></a>";
        $(lblReturnBtn).innerHTML = Msg;
        ShowLocationDetailInfo()  
    }
    else
    {
        $(lblReturnBtn).innerHTML = "";
        $(lblReturnMsg).innerHTML = "";
    }
}


function ShowLocationDetailInfo()
{
    if(SingleLocation)
    { 
        var InfoMsg = GetXmlTemplete(VirtualPath + TempleteUrl,"ReturnInfoTemplete");
        InfoMsg = InfoMsg.replace("{Name}",SingleLocation.Name);
        InfoMsg = InfoMsg.replace("{Place}",SingleLocation.Place);
        InfoMsg = InfoMsg.replace("{Floor}",SingleLocation.Floor);
        InfoMsg = InfoMsg.replace("{Address}",SingleLocation.Address);
        InfoMsg = InfoMsg.replace("{Tel}",SingleLocation.Tel);
        InfoMsg = InfoMsg.replace("{Fax}",SingleLocation.Fax);
        InfoMsg = InfoMsg.replace("{Web}",SingleLocation.Web);
        InfoMsg = InfoMsg.replace("{LinkMan}",SingleLocation.LinkMan);
        InfoMsg = InfoMsg.replace("{EnterTime}",SingleLocation.EnterTime);
        InfoMsg = InfoMsg.replace("{CorpType}",SingleLocation.CorpType);
        $(lblReturnMsg).innerHTML = InfoMsg;
    }
}

function ShowLocationIntro()
{
    if(SingleLocation)
    {
        window.open(SingleLocation.Web);
        //var InfoMsg = "<textarea name='textareaIntro' cols='35' rows='8' readonly='readonly'>";
        //InfoMsg += SingleLocation.Intro;
        //InfoMsg += "</textarea><br/><a onclick='ShowLocationDetailInfo();' style='cursor:hand;'>[返回]</a>";
        //$(lblReturnMsg).innerHTML =InfoMsg
    }
}

function ShowLocationOperation()
{
    if(SingleLocation)
    { 
        window.open(SingleLocation.ProduceUrl);
        //var InfoMsg = "<textarea name='textareaOperation' cols='35' rows='8' readonly='readonly'>";
        //InfoMsg += SingleLocation.Operation;
        //InfoMsg += "</textarea><br/><a onclick='ShowLocationDetailInfo();' style='cursor:hand;'>[返回]</a>";
        //$(lblReturnMsg).innerHTML = InfoMsg;
    }
}

function ShowLocationMemo()
{
    if(SingleLocation)
    { 
        var InfoMsg = "<textarea name='textareaMemo' cols='35' rows='8' readonly='readonly'>";
        InfoMsg += SingleLocation.Memo;
        InfoMsg += "</textarea><br/><a onclick='ShowLocationDetailInfo();' style='cursor:hand;'>[返回]</a>";
        $(lblReturnMsg).innerHTML = InfoMsg;
    }
}

/******************************* 
*  无刷新请求区
********************************/

// 无刷新请求入口(集合第一个 Item 统一为调用参数)
function AjaxRequest(arrParam,returnFuntion)
{
    var url = RequestPageUrl;
    var pars = 'Param=' + arrParam.Export(AjaxChar);
    AjaxRequestPost(url, pars, returnFuntion);
}

//从后台检索场景坐标
function SearchLocation()
{
    var arrParam = new ArrayList();
    arrParam.Add("SearchLocation");       //方法类别
    arrParam.Add($F(txtSearchName));      //位置名称
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("检索场景坐标中……");
}

//保存编辑框中信息到后台
function SaveLocation()
{
    if(!ValidateTextBox())
    {
        ShowStateInfo("保存场景失败!");
        return;
    }
    var arrParam = new ArrayList();
    arrParam.Add("SaveLocation");       //方法类别
    arrParam.Add($F(txtName));          //位置名称
    //位置坐标
    arrParam.Add($F(txtPx));
    arrParam.Add($F(txtPy));
    arrParam.Add($F(txtPz));
    //位置方向
    arrParam.Add($F(txtOx));
    arrParam.Add($F(txtOy));
    arrParam.Add($F(txtOz));
    arrParam.Add($F(txtOa));
    //Vrml所在的Url
    var VrmlUrl = GetCurrentVrmlUrl();
    VrmlUrl = VrmlUrl.replace(VirtualPath, "");
    arrParam.Add(VrmlUrl);
    //附加信息
    arrParam.Add($F(txtPlace));
    arrParam.Add($F(txtFloor));
    arrParam.Add($F(txtAddress));
    arrParam.Add($F(txtTel));
    arrParam.Add($F(txtFax));
    arrParam.Add($F(txtWeb));
    arrParam.Add($F(txtLinkMan))
    arrParam.Add($F(txtEnterTime));
    arrParam.Add($F(txtCorpType));
    arrParam.Add($F(txtIntro));
    arrParam.Add($F(txtOperation));
    arrParam.Add($F(txtMemo));
    arrParam.Add($F(txtProduceUrl));
    arrParam.Add($F(txtFund));
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("保存场景坐标中……");
}

function UpdateLocation()
{
    if(!ValidateGuid())
    {
        ShowStateInfo("请先选择场景数据!");
        return;
    }
    if(!ValidateTextBox())
    {
        ShowStateInfo("更新场景失败!");
        return;
    }
    var arrParam = new ArrayList();
    arrParam.Add("UpdateLocation");    　 //方法类别
    arrParam.Add($F(txtName));          　//位置名称
    arrParam.Add($F(txtGuid));         　 //位置Guid
    //位置坐标
    arrParam.Add($F(txtPx));
    arrParam.Add($F(txtPy));
    arrParam.Add($F(txtPz));
    //位置方向
    arrParam.Add($F(txtOx));
    arrParam.Add($F(txtOy));
    arrParam.Add($F(txtOz));
    arrParam.Add($F(txtOa));
    //Vrml所在的Url
    var VrmlUrl = GetCurrentVrmlUrl();
    VrmlUrl = VrmlUrl.replace(VirtualPath, "");
    arrParam.Add(VrmlUrl);
    //附加信息
    arrParam.Add($F(txtPlace));
    arrParam.Add($F(txtFloor));
    arrParam.Add($F(txtAddress));
    arrParam.Add($F(txtTel));
    arrParam.Add($F(txtFax));
    arrParam.Add($F(txtWeb));
    arrParam.Add($F(txtLinkMan))
    arrParam.Add($F(txtEnterTime));
    arrParam.Add($F(txtCorpType));
    arrParam.Add($F(txtIntro));
    arrParam.Add($F(txtOperation));
    arrParam.Add($F(txtMemo));
    arrParam.Add($F(txtProduceUrl));
    arrParam.Add($F(txtFund));   
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("修改场景坐标中……");
}

function DeleteLocation()
{
    if(!ValidateGuid())
    {
        ShowStateInfo("请先选择场景数据!");
        return;
    }
    var arrParam = new ArrayList();
    arrParam.Add("DeleteLocation");    　 //方法类别
    arrParam.Add($F(txtName));          　//位置名称
    arrParam.Add($F(txtGuid));         　 //位置Guid
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("删除场景坐标中……");
}

//保存编辑框中信息到后台
function SaveMarkUrl()
{
    var arrParam = new ArrayList();
    arrParam.Add("SaveMarkUrl");    　　　　　 //方法类别
    arrParam.Add($F(txtName));               　//标记名称
    arrParam.Add($F(txtPx));
    arrParam.Add($F(txtPy));
    arrParam.Add($F(txtPz));
    arrParam.Add($F(sltTarget));
    arrParam.Add($F(txtUrl));
    //Vrml所在的Url
    var VrmlUrl = GetCurrentVrmlUrl();
    VrmlUrl = VrmlUrl.replace(VirtualPath, "");
    arrParam.Add(VrmlUrl);
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("保存场景链接中……");
    ImportVrmlByTextBox();
}

function LoadMarkUrl()
{
    var arrParam = new ArrayList();
    arrParam.Add("LoadMarkUrl");    　　　　　 //方法类别
    //Vrml所在的Url
    var VrmlUrl = GetCurrentVrmlUrl();
    VrmlUrl = VrmlUrl.replace(VirtualPath, "");
    arrParam.Add(VrmlUrl);
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("检索场景标记中……");
}

function GetGuid()
{
    var arrParam = new ArrayList();
    arrParam.Add("GetGuid");    　　　　　 
    AjaxRequest(arrParam,AjaxReturn);
}

function GetPlaceList()
{
    var arrParam = new ArrayList();
    arrParam.Add("GetPlaceList");   　　　　　
    AjaxRequest(arrParam,AjaxReturn);
}

function GetFloorList()
{
    var arrParam = new ArrayList();
    arrParam.Add("GetFloorList");
    arrParam.Add($F(slcPlace));    　　　　　
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("检索楼层列表中……");
}

function GetLocationList()
{
    var arrParam = new ArrayList();
    arrParam.Add("GetLocationList"); 
    arrParam.Add($F(slcPlace));    
    arrParam.Add($F(slcFloor));       　　　　　
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("检索位置列表中……");
}

function GetSingleLocation()
{
    var arrParam = new ArrayList();
    arrParam.Add("GetSingleLocation"); 
    arrParam.Add($F(slcPlace));    
    arrParam.Add($F(slcFloor)); 
    arrParam.Add($F(slcLocation)); 
    AjaxRequest(arrParam,AjaxReturn);
    ShowStateInfo("检索位置详细信息中……");
}

function CheckLogined()
{
    var arrParam = new ArrayList();
    arrParam.Add("CheckLogined"); 
    AjaxRequest(arrParam,AjaxReturn);
}

function LoginOut()
{
    var arrParam = new ArrayList();
    arrParam.Add("LoginOut"); 
    AjaxRequest(arrParam,AjaxReturn);
}

/******************************* 
*  无刷新返回区
********************************/
//无刷新返回入口 返回调用方法统一为(return + 调用参数)
function AjaxReturn(originalRequest)
{
    var arrReturn =  new ArrayList();
    arrReturn.Import(originalRequest.responseText,AjaxChar);
    var returnName = arrReturn.Item(0);
    switch(returnName)
    {
        case "SearchLocation":
            returnSearchLocation(arrReturn);
            break;
        case "SaveLocation":
            returnSaveLocation(arrReturn);
            break;
        case "UpdateLocation":
            returnUpdateLocation(arrReturn);
            break;
        case "DeleteLocation":
            returnDeleteLocation(arrReturn);
            break;
        case "SaveMarkUrl":
            returnSaveMarkUrl(arrReturn);
            break;
        case "LoadMarkUrl":
            returnLoadMarkUrl(arrReturn);
            break;
        case "GetGuid":
            returnGetGuid(arrReturn);
            break;
        case "GetFloorList":
            returnGetFloorList(arrReturn);
            break;
        case "GetLocationList":
            returnGetLocationList(arrReturn);
            break;
        case "GetSingleLocation":
            returnGetSingleLocation(arrReturn);
            break;
        case "CheckLogined":
            returnCheckLogined(arrReturn);
            break;
        case "LoginOut":
            returnLoginOut(arrReturn);
            break;
        case "Error":
            returnError(arrReturn);
            break;
        default:
            //alert("Error!");
            break;
    }
    InitializeInfo();
    SetFocus();
}

//位置保存返回
function returnSaveLocation(arrReturn)
{
    var StateInfo = arrReturn.Item(1);
    ShowStateInfo(StateInfo);    
}

//返回检索信息
function returnSearchLocation(arrReturn)
{
    var LocationModelsXml = arrReturn.Item(1);
    ShowLocationList(LocationModelsXml);
}

//位置更新返回
function returnUpdateLocation(arrReturn)
{
    var StateInfo = arrReturn.Item(1);
    ShowStateInfo(StateInfo);
    UpdateArrayList();
}

//位置删除返回
function returnDeleteLocation(arrReturn)
{
    var StateInfo = arrReturn.Item(1);
    ShowStateInfo(StateInfo);
    DeleteArrayList();
}

//链接保存返回
function returnSaveMarkUrl(arrReturn)
{
    var StateInfo = arrReturn.Item(1);
    ShowStateInfo(StateInfo);
}

//链接载入返回
function returnLoadMarkUrl(arrReturn)
{
    var MarkUrlModelsXml = arrReturn.Item(1);
    LoadMarkUrlModel(MarkUrlModelsXml);
}

//Guid返回
function returnGetGuid(arrReturn)
{
     NewGuid = arrReturn.Item(1);
     GuidIsUsed = false;
}

//返回楼层列表
function returnGetFloorList(arrReturn)
{ 
    var length =  $(slcFloor).length;  
    for(var i=0; i< length; i++)
    {
        $(slcFloor).options[0] = null;
    }
    var objOption = new Option("全部","", false, "");
    $(slcFloor).add(objOption);   
    length = arrReturn.GetLength();
    if(length > 1)
    {
        for(var i=1;i< length; i++)
        {
            var objOption = new Option(arrReturn.Item(i), arrReturn.Item(i), false, "");
            $(slcFloor).add(objOption);      
        }
    }
    ShowStateInfo("楼层列表检索完成!");
    GetLocationList();
}

function returnGetLocationList(arrReturn)
{
    var length =  $(slcLocation).length;  
    for(var i=0; i< length; i++)
    {
        $(slcLocation).options[0] = null;
    }
    length = arrReturn.GetLength();
    if(length > 1)
    {
        for(var i=1;i< length; i+=2)
        {
            var localName = arrReturn.Item(i);
            if(localName.length > 13)
            {
                localName = localName.substr(0,13);
                localName += ">";
            }
            var objOption = new Option(localName, arrReturn.Item(i+1), false, "");
            objOption.label = arrReturn.Item(i);
            $(slcLocation).add(objOption);      
        }
    }
    ShowStateInfo("位置列表检索完成!");
    
    GetSingleLocation();
}

function returnGetSingleLocation(arrReturn)
{
    var LocationXml = arrReturn.Item(1);
    SingleLocation = OPSingleLocation(LocationXml);
    ShowSingleLocation();
    ShowStateInfo("位置详细信息检索完成!");
}

function returnCheckLogined(arrReturn)
{
    var isLogined = arrReturn.Item(1); 
    if(isLogined == "1")
    {
        $(divManager).style.display = "block";
        $(lblLogin).innerHTML = "<a style='cursor:hand;' onclick='LoginOut();'>退出</a>";
        LoginFlag = true;
    }
    else
    {
        $(divManager).style.display = "none";
        $(lblLogin).innerHTML = "<a href='Login.aspx'>登录</a>";
        LoginFlag = false;
    }
}

function returnLoginOut(arrReturn)
{
    $(divManager).style.display = "none";
    $(lblLogin).innerHTML = "<a href='Login.aspx'>登录</a>";
    LoginFlag = false;
}

function returnError(arrReturn)
{
    var StateInfo = arrReturn.Item(1);
    ShowStateInfo(StateInfo);
}

function Debug()
{
    var Temp = null;
}

/******************************* 
*  临时方法
********************************/

//获取碰撞模板
function btnGetTemplete_onclick() 
{
    FillTextBoxByGuid(txtPSName);
    FillTextBoxByGuid(txtScriptName);
    var PsTemplete = GetXmlTemplete(VirtualPath + TempleteUrl,"PsTemplete");
    $(txtAutoCode).value = PsTemplete;
}

//替换触发地点
function Get1_onclick() 
{
    var PsTemplete = $F(txtAutoCode);
    PsTemplete = PsTemplete.replace("{PSName}",$F(txtPSName));
    PsTemplete = PsTemplete.replace("{ScriptName}",$F(txtScriptName));
    PsTemplete = PsTemplete.replace("{PSName}",$F(txtPSName));
    PsTemplete = PsTemplete.replace("{ScriptName}",$F(txtScriptName));
    PsTemplete = PsTemplete.replace("{x}",$F(txtPx));
    PsTemplete = PsTemplete.replace("{y}",$F(txtPy));
    PsTemplete = PsTemplete.replace("{z}",$F(txtPz));
    $(txtAutoCode).value = PsTemplete;       
}

//替换目的地点
function Get2_onclick() 
{
    var VrmlUrl = GetCurrentVrmlUrl();
    VrmlUrl = VrmlUrl.replace(VirtualPath, "");
    var PsTemplete = $F(txtAutoCode);
    PsTemplete = PsTemplete.replace("{PSName}",$F(txtPSName));
    PsTemplete = PsTemplete.replace("{ScriptName}",$F(txtScriptName));
    PsTemplete = PsTemplete.replace("{PSName}",$F(txtPSName));
    PsTemplete = PsTemplete.replace("{ScriptName}",$F(txtScriptName));
    PsTemplete = PsTemplete.replace("{px}",$F(txtPx));
    PsTemplete = PsTemplete.replace("{py}",$F(txtPy));
    PsTemplete = PsTemplete.replace("{pz}",$F(txtPz));
    PsTemplete = PsTemplete.replace("{ox}",$F(txtOx));
    PsTemplete = PsTemplete.replace("{oy}",$F(txtOy));
    PsTemplete = PsTemplete.replace("{oz}",$F(txtOz));
    PsTemplete = PsTemplete.replace("{oa}",$F(txtOa));
    PsTemplete = PsTemplete.replace("{vrml}",VrmlUrl);
    $(txtAutoCode).value = PsTemplete;   
}
