﻿/*************************************************
* 企业泡泡控件 v1.1 xb 2008.10.28
*************************************************/
var MapNewsPopControl = Class.create();
Object.extend(MapNewsPopControl.prototype, ControlBase.prototype);  //继承基类
Object.extend(MapNewsPopControl.prototype, {
    _loadUI: function() {
        this.LoadUI('MapNewsPopControl');
    },
    _loadComplete: function() {
        this.$('btnClose').onclick = this.ClosePop.bind(this);
        this.$('divLoading').innerHTML = this.Config.Loading;
        this.onLoadComplete();
    },
    GID: 0,
    IsMove: false,
    CopyMsg: '复制成功，请贴到你的QQ/MSN上发给你的好友！',
    PopAD: [],
    ShowPop: function(id, ismove) {
        //
        if (ismove) {
            this.IsMove = true;
        }
        else {
            this.IsMove = false;
        }
        if (this.GID != id) {
            this.$('divLoading').style.display = '';
            this.Show();
        }
        else {
            this.$('divLoading').style.display = 'none';
            this.Show();
            return;
        }
        this.GID = id;
        var that = this;
        
        var requestUrl = getRootPath() + "/map/AjaxHandle.ashx?req=getMapNewsInfoById&id=" + id;
        downloadUrl(requestUrl, function(request) {
            //debugger;
            var json = xmlHttpRequestJson(request);
            if (json == null)
                return false;
            that.LoadPopData(json);
        });
    },
    LoadPopData: function(data) {
        //debugger;
        var o = data.MapNews[0];
        var x = o.X_coordinates, y = o.Y_coordinates, id = o.Id;
        var name = o.Title;
        var content = o.Content;

        //兼容地图初始定位移动
        if (this.IsMove) {
            MoveTo(x* 1,y*1, true);
            vM.moveEntity(this.ID,x,y);
        }
        this.$('Name_h3').innerHTML = name; //产品名称
        this.$('divContent').innerHTML = content; //产品名称

        /*
        //var imgurl = Utils.HTML.getPath() + "ReadImage.aspx?width=60&height=90&id=" + o.goodimage;
        this.$('Img_a').href = imgurl;
        this.$('Img_a').target = '_blank';
        this.$('Img_img').src = imgurl;
        this.$('Img_img').onerror = this.loadImgErr.bind(this.$('Img_img'), this.Config.SkinPath + '/Images/nophoto.jpg');
        //产品类型现价：
        this.$('Price_p').innerHTML = "<SPAN class='cur_price'>￥" + o.price2 + "元</SPAN><SPAN class='org_price'>原价：￥" + o.price1 + "元</SPAN>";
        //this.$('Type_p').innerHTML = o.category;
        this.$('Brand_p').innerHTML = "品牌：" + o.pinpai;
        //this.$('view_a').href= this.Config.HuangyeUrl+'ShopView.aspx?ID='+o.CompanyID; //Map5.0黄页的URL
        //var url = "/jxtops/company/shopShow.aspx?id=" + o.shopid + "&goodid=" + id;
        this.$('view_a').href = Utils.HTML.getPath() + o.xxxx;
        this.$('btnCavil').onclick = this.onCavil.bind(this, x, y, id, name);

        this.$('btnBusTransfer').onclick = this.onBusTransfer.bind(this, x, y, name);
        this.$('btnNearBySearch').onclick = this.onNearBySearch.bind(this, x, y, name);
        this.$('btnNearByBus').onclick = this.onNearByBus.bind(this, x, y, name);

        var gurl = 'http://' + this.Config.NodeUrl + '/?l=' + this.Config.Language + '&gid=' + id;
        this.$('txtUrl').value = gurl;
        this.$('btnCopy').onclick = this.Copy.bind(this, gurl);
        */
        this.$('divLoading').style.display = 'none';
        this.Show();

    },
    ClosePop: function() { this.Hide(); },
    Copy: function(url) { fnCopyToClipboard(url, this.CopyMsg); },
    loadImgErr: function(imgpath) {
        if (this.src == imgpath) {
            return;
            //默认图片加载失败则不再触发 , ie7光设置 this.onerror=null; 无效
        }
        this.src = imgpath;
        this.onerror = null;
        this.parentNode.href = 'javascript:;';
        this.parentNode.target = '_self';
    },
    onCavil: function(x, y, id, name) { },
    onBusTransfer: function(x, y, ocname) { },
    onNearBySearch: function(x, y, ocname) { },
    onNearByBus: function(x, y, ocname) { }
});
