﻿var InitIndexCityImageByAreaId=function(AreaId){
    var imgurl="http://img1.ucar.cn/ucar/image/ucar/ucar2010/index/site_logo/"+IpLocation.GetImageName(AreaId);
    $("strongCityImg").style.background="url("+imgurl+") no-repeat";
    $("strongCityImg").update(IpLocation.GetAreaName(AreaId));
}
var InitIndexCityImage=function(){
    var AreaId=IpLocation.GetAreaId();
    InitIndexCityImageByAreaId(AreaId);
}


var OnMouseDelay=function(ControlId,delay,callback,para){
    var timeint;
    $(ControlId).observe("mouseover",function(){
        var fn = callback || function(){}
        timeint=setTimeout(function(){
            fn.apply(this,para);
        },delay);    
    });
    $(ControlId).observe("mouseout",function(){
        clearTimeout(timeint);
    });
}

var UcarBlockIndexUrl="/";
var UcarBlockText = Class.create({
    initialize: function(ControlId, WebSite, BlockName, IsUserIp) {//构造函数
        this.Control = $(ControlId);
        this.WebSite = WebSite;
        this.BlockName = BlockName;
        this.IsUserIp = IsUserIp;
    },
    UcarLoadingText: "loading....",
    WebSite: "ucar",
    Control: null,
    BlockUrl: "",
    BlockName: "",
    IsUserIp: false,
    BlockModel: "inc/ucar2010/index/{0}/a{1}/",
    GetBlockFullUrl: function() {
        var AreaId = IpLocation.GetAreaId();
        var BlockUrl = this.BlockModel.replace(/\{0}/g, this.WebSite.toString());
        if (this.IsUserIp) {
            BlockUrl = BlockUrl.replace(/\{1}/g, AreaId.toString());
        }
        else {
            BlockUrl = BlockUrl.replace(/\{1}/g, "0");
        }
        return UcarBlockIndexUrl + BlockUrl + this.BlockName;
    },
    InitBlockHidDivSuccess: function(response) {
        var result = response.responseText;
        if (!!this.Control) {
            if (result.length < 10)
            { this.Control.style.display='none'; }
            this.Control.update(result);
        }
    },
    InitBlockSuccess: function(response) {
        var result = response.responseText;
        if (!!this.Control) {
            this.Control.update(result);
        }
    },
    InitBlockLoaded: function() {
        if (!!this.Control) {
            this.Control.update(this.UcarLoadingText);
        }
    },
    InitBlockFailure: function() { },
    InitBlock: function() {
        var rom = Math.random();
        var url = this.GetBlockFullUrl();
        new Ajax.Request(url, { method: "get",
            onSuccess: this.InitBlockSuccess.bind(this),
            onFailure: this.InitBlockFailure.bind(this),
            onLoaded: this.InitBlockLoaded.bind(this),
            evalScripts: true,
            asynchronous: true
        });
    },
     InitBlockHidDiv: function() {
        var rom = Math.random();
        var url = this.GetBlockFullUrl();
        new Ajax.Request(url, { method: "get",
        onSuccess: this.InitBlockHidDivSuccess.bind(this),
            onFailure: this.InitBlockFailure.bind(this),
            onLoaded: this.InitBlockLoaded.bind(this),
            evalScripts: true,
            asynchronous: true
        });
    }
});







