﻿//document.domain = "88488.com";
function _GetCookieVal(offset) {
    var c = document.cookie;
    var endstr = c.indexOf(";", offset);
    if (endstr == -1) {
        endstr = c.length;
    }
    return unescape(c.substring(offset, endstr));
}

function g_cookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var c = document.cookie;
    var clen = c.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (c.substring(i, j) == arg) {
            return _GetCookieVal(j);
        }
        i = c.indexOf(" ", i) + 1;
        if (i == 0) {
            break;
        }
    }
    return null;
}

function getWeather() {
    var wea = g_cookie('8cityno')
    var hf = 'http://www.88488.com/d/'
    if (wea) {
        if (wea == 1)
            hf += 'if/54511.html';
        else {
            wea = wea + '';
            if (wea.indexOf(',') == -1)
                hf += 'if/' + wea + '.html';
            else {
                var t = wea.split(',');
                hf += 'if/' + t[0] + '.html';
            }
        }
    } else {//根据IP显示天气
        var ipea = g_cookie('8ipcityno');
        if (ipea) {
            hf += "if/" + ipea + ".html";
        } else {
            hf = 'http://tianqi.88488.com/index.jsp';
        }

    }

    document.getElementById("weather").src = hf;
}


//getWeather();

function checkweather() {
    if (!g_cookie('8cityno')) {
        var time = g_cookie('8time');

        if (time) {
            var ctime = new Date().getTime();
            var de = 2 * 60 * 60 * 1000 - (ctime - time);
            if (de < 60 * 1000) {
                document.getElementById("weather").src = "http://tianqi.88488.com/index.jsp";
            }
        } else {
            document.getElementById("weather").src = "http://tianqi.88488.com/index.jsp";
        }
    }
}

//window.setInterval("checkweather()", 60 * 1000);

