var PV = {
    postToServer: function(method, cityDomain, postdata, callback, error) {
        var url = "http://hangzhou.fangtoo.com/services/PVService.svc/" + method;
        jQuery.ajax({
            url: url,
            type: "POST",
            contentType: "text/json",
            timeout: 10000,
            dataType: "text",
            data: JSON.stringify({ city: cityDomain, data: postdata }),
            success: callback,
            error: function(a, b, c) {
            }
        });
    },
    trade: function(city, tradeId, custId, shopId, companyId, custType, regionCode, regionName, buildingId, buildingName, houKind, roomCount, hollCount, cookroom, looCount, terrace, area, price, unitPrice, floor, floorCount, qcpass, expert, createtime) {
        var tradePv = {
            TradeId: tradeId,
            CustId: custId,
            StoreId: shopId,
            CompanyId: companyId,
            CustType: custType,
            RegionCode: regionCode,
            RegionName: regionName,
            BuildingId: buildingId,
            BuildingName: buildingName,
            HouKind: houKind,
            RoomCount: roomCount,
            HollCount: hollCount,
            Cookroom: cookroom,
            LooCount: looCount,
            Terrace: terrace,
            Area: area,
            Price: price,
            UnitPrice: unitPrice,
            Floor: floor,
            FloorCount: floorCount,
            QCPass: qcpass,
            Expert: expert,
            HouseCreateTime: createtime
        };
        PV.postToServer("trade", city, tradePv);
    },
    lease: function(city, leaseId, custId, shopId, companyId, custType, regionCode, regionName, buildingId, buildingName, houKind, roomCount, hollCount, cookroom, looCount, terrace, area, price, unitPrice, floor, floorCount, leaseWay, qcpass, expert, createtime) {
        var leasePv = {
            LeaseId: leaseId,
            CustId: custId,
            StoreId: shopId,
            CompanyId: companyId,
            CustType: custType,
            RegionCode: regionCode,
            RegionName: regionName,
            BuildingId: buildingId,
            BuildingName: buildingName,
            HouKind: houKind,
            RoomCount: roomCount,
            HollCount: hollCount,
            Cookroom: cookroom,
            LooCount: looCount,
            Terrace: terrace,
            Area: area,
            Price: price,
            UnitPrice: unitPrice,
            Floor: floor,
            FloorCount: floorCount,
            LeaseWay: leaseWay,
            QCPass: qcpass,
            Expert: expert,
            HouseCreateTime: createtime
        };
        PV.postToServer("lease", city, leasePv);
    },

    biz: function(city, bizId, custId, companyId, storeId, custType, regionCode, regionName, buildingId, buildingName, bizHouKind, showWay, area, paybackRate, floor, floorCount, qcPass, expert, tradePrice, singlePrice, leaseDayPrice, leasePrice, createTime) {
        var bizPv = {
            BizId: bizId,
            CustId: custId,
            CompanyId: companyId,
            StoreId: storeId,
            CustType: custType,
            RegionCode: regionCode,
            RegionName: regionName,
            BuildingId: buildingId,
            BuildingName: buildingName,
            BizHouKind: bizHouKind,
            ShowWay: showWay,
            Area: area,
            PaybackRate: paybackRate,
            Floor: floor,
            FloorCount: floorCount,
            QCPass: qcPass,
            Expert: expert,
            TradePrice: tradePrice,
            SinglePrice: singlePrice,
            LeaseDayPrice: leaseDayPrice,
            LeasePrice: leasePrice,
            HouseCreateTime: createTime
        };
        PV.postToServer("biz", city, bizPv);
    },

    tradeReq: function(city, tradeReqId, reqTime) {
        var tradeReqPv = {
            TraReqId: tradeReqId,
            ReqTime: reqTime
        };
        PV.postToServer("tradereq", city, tradeReqPv);
    },
    leaseReq: function(city, leaseReqId, reqTime) {
        var leaseReqPv = {
            LeaReqId: leaseReqId,
            ReqTime: reqTime
        };
        PV.postToServer("leasereq", city, leaseReqPv);
    },
    leaseSH: function(city, sHId, shTime, custId, regionCode, boardIds, hollCountL, hollCountH, areaL, areaH, priceL, priceH) {
        var leaseSHPv = {
            SHId: sHId,
            ShTime: shTime,
            CustId: custId,
            RegionCode: regionCode,
            BoardIds: boardIds,
            HollCountL: hollCountL,
            HollCountH: hollCountH,
            AreaL: areaL,
            AreaH: areaH,
            PriceL: priceL,
            PriceH: priceH
        };
        PV.postToServer("leasesh", city, leaseSHPv);
    },
    broker: function(city, custId, custName, companyId, companyName, storeId, storeName) {
        var brokerPv = {
            CustId: custId,
            CustName: custName,
            CompanyId: companyId,
            CompanyName: companyName,
            StoreId: storeId,
            StoreName: storeName
        };
        PV.postToServer("broker", city, brokerPv);
    },
    building: function(city, buildingId, buildingName, regionCode, regionName) {
        var buildingPv = {
            BuildingId: buildingId,
            BuildingName: buildingName,
            RegionCode: regionCode,
            RegionName: regionName
        };
        PV.postToServer("building", city, buildingPv);
    },
    company: function(city, companyId, companyName) {
        var companyPv = {
            CompanyId: companyId,
            CompanyName: companyName
        };
        PV.postToServer("company", city, companyPv);
    },
    store: function(city, companyId, companyName, storeId, storeName) {
        var storePv = {
            CompanyId: companyId,
            CompanyName: companyName,
            StoreId: storeId,
            StoreName: storeName
        };
        PV.postToServer("store", city, storePv);
    },

    ad: function(city, adPosition, adId, adName) {
        var adPv = {
            AdPosition: adPosition,
            AdID: adId,
            AdName: adName
        };
        PV.postToServer("ad", city, adPv);
    },

    common: function(city, category, target) {
        var commonPv = {
            Category: category,
            Target: target
        };
        PV.postToServer("common", city, commonPv);
    }
}

$(function() {//广告统计事件绑定
    $("[adcode]").bind("mousedown", function() { PV.ad("<%=CityDomain %>", $(this).attr("adcode"), $(this).attr("adid"), $(this).attr("adname")); });
})
