function PageState() {
    this.lat = 0.0;
    this.lon = 0.0;
    this.stop = "";
    this.scale = 2;
    this.addr = "";
}

function PageState_clearStop() {
    this.stop = "";
}

PageState.prototype.clearStop = PageState_clearStop;

function PageState_hasStop() {
    return ((this.stop) && (this.stop.length > 0));
}

PageState.prototype.hasStop = PageState_hasStop;

function PageState_store() {
    cookie = new cookieObject("pagestate", 365, "/", "lat", "lon", "stop", "scale", "addr");
    cookie.put("lat", this.lat);
    cookie.put("lon", this.lon);
    cookie.put("stop", this.stop);
    cookie.put("scale", this.scale);
    cookie.put("addr", this.addr);
    cookie.write();
}

function PageState_load() {
    cookie = new cookieObject("pagestate", 365, "/", "lat", "lon", "stop", "scale", "addr");
    this.lat = parseFloat(cookie.get("lat"));
    this.lon = parseFloat(cookie.get("lon"));
    this.stop = cookie.get("stop");
    if (!this.stop) {
        this.clearStop();
    }
    if (cookie.get("scale")) {
        this.scale = parseInt(cookie.get("scale"));
    }
    if (cookie.get("addr")) {
        this.addr = cookie.get("addr");
    }
}

PageState.prototype.save = PageState_store;
PageState.prototype.load = PageState_load;

function PageState_setLocation(loc) {
    if (loc instanceof GPoint) {
        this.lat = loc.y;
        this.lon = loc.x;
    }
}

PageState.prototype.setLocation = PageState_setLocation;

function PageState_hasValidLocation() {
    return (!isNaN(this.lat) && !isNaN(this.lon));
}

PageState.prototype.hasValidLocation = PageState_hasValidLocation;

function PageState_getLocation() {
    return new GPoint(this.lon, this.lat);
}

PageState.prototype.getLocation = PageState_getLocation;

