function scaleLookup(type) {
    var ar=null;
    if (type=="apratesfc") {
        ar=new Array('None', 'Light', 'Showers', 'Rain', 'Heavy');
    }
    else if (type=="vissfc") {
        ar=new Array('Fog', 'Poor', 'Good', 'Unlim');
    }
    return ar;
}

function dataLookup(type, value) {
    var ar=null;
    if (type=="apratesfc") ar= new Array('None', 'Light Showers', 'Showers', 'Rain', 'Heavy rain');
    else if (type==="vissfc") ar=new Array('Fog', 'Poor', 'Good', 'Unlimited');
    return (ar ? $j.inArray(value, ar) : value);
}

Raphael.fn.drawGrid = function(x, y, w, h, wv, hv, color) {
    color = color || "#fff";
    var path = ["M", x, y], daypath = ["M", x, y], rowHeight = h / hv, columnWidth = w / wv;
    var strokewidth=1;
    for (var i = 0; i <= hv; i++) {
        path = path.concat(["M", x, y + i * rowHeight, "L", x + w, y + i * rowHeight]);
    }
    for (var i = 0; i <= wv; i++) {
        path = path.concat(["M", x + i * columnWidth, y, "L", x + i * columnWidth, y + h]);
    }
    this.path(path.join(",")).attr({stroke: color, fill: "#eee", "stroke-width": strokewidth}).toBack();
    strokewidth=6;
    for (var i = 4; i <wv; i+=4) {
        daypath = daypath.concat(["M", x + i * columnWidth, y, "L", x + i * columnWidth, y + h]);
    }
    this.path(daypath.join(",")).attr({stroke: color, fill: "#eee", "stroke-width": strokewidth}).toBack();       
};

Raphael.fn.arrow = function (x, y, size, dir) {
    var path = ["M", x, y, "L", x+8, y, "L", x+8, y+16, "L", x+12, y+16, "L", x+4, y+24, "L", x-4, y+16,"L", x, y+16, "L", x, y, "Z"];
    return this.path(path).rotate(dir);
};

$j.fn.stripTags = function() {
    return this.replaceWith( this.html().replace(/<\/?[^>]+>/gi, '') );
};

GraphBase = OpenLayers.Class({
    el: null, c: null, w: null, h: null,
    tg: 10, bg: 10, cols: 28, rows: 5, max: 0,
    style: {font: '11px Fontin-Sans, Arial', fill: "#fff"},
    left: null, title: null, units: null, atitle: null,
    
    initialize: function(raphael, el, width, height, left, title, units, atitle) {
        this.el = el;
        this.w=width;
        this.h=height;
        this.c=raphael;
        this.left=left;
        this.title=title;
        this.units=units;
        this.atitle=atitle;
    },
    drawGrid: function() {
        var gridh=this.h-this.tg-this.bg;
        if (this.h <=40) this.rows=1;
        this.c.drawGrid(0, this.tg, this.w, gridh, this.cols, this.rows, "#fff");
    }
});

GraphAxis = OpenLayers.Class(GraphBase, {
    length: null, 
    line: {stroke: "#fff", "stroke-width": 2, "stroke-linejoin": "round"},
    yaxis: null,
    
    draw: function(scale, max, min) {
        var that = this;
        var height = this.h-this.tg-this.bg;
        var width = (this.left) ? this.w : 0;
        var yaxis = that.c.path("M "+width+" "+that.tg+"L"+width+" "+height-that.bg+" z").attr(that.line);
        var title = (that.atitle) ? that.atitle : that.title;
        var axislabel=title+" ("+that.units+")";
        if (!scale) that.c.text((that.left) ? 12 : 36, (height/2)+that.tg, axislabel).attr(that.style).rotate((that.left) ? 270 : 90, true);
        if (scale) {
            for (var i=0; i<scale.length; i++) {
                var notch = that.tg+height-(i*(height/(scale.length-1)));
                that.c.path("M "+((that.left) ? (width-5) : width+5)+" "+(notch)+"L"+(width)+" "+(notch)+" z").attr(that.line);
                var axistag = scale[i];
                that.c.text((that.left) ? width-24 : width+24, notch, axistag).attr(that.style); 
            }
        }
        else {
            for (var i=0; i <= 5; i++) {
                var notch = i*(height/5)+that.tg;
                that.c.path("M "+((that.left) ? (width-5) : width+5)+" "+(notch)+"L"+(width)+" "+(notch)+" z").attr(that.line);
                var axisno = Math.round(((max)-(((max-min)/5))*i)*Math.pow(10,1))/Math.pow(10,1);
                that.c.text((that.left) ? width-17 : width+17, notch, axisno.toString()).attr(that.style); 
            }
        }
    }
});

StdGraph = OpenLayers.Class(GraphBase, {
    datael: null, plotted: false,
    a: null, s: null, path: null, bgpath: null, scale: null,
    f: null, fsty: {fill: "#747474", stroke: "#fff", "stroke-width": 2, "opacity": 0.8},
    label: null,
    max: 0, min: 0, wavemax: 0, count: 0, X: 0, Y: 0, elw: 0,
    gtitle: null, gunits: null, glayer: 0, layercount: 0,
    time: new Array(),
    day: new Array(),
    data: new Array(),
    path: null,
    ggrad: {
        blue: "90-#2e4771-#94a1b6",
        red: "90-#e12424-#ed9c9c",
        turq: "90-#66b2e5-#bed7e8",
        green: "90-#007f00-#6ebc5e"
    },
    color: {
        blue: "#2e4771",
        dblue: "#2e4771",
        red: "#e12424",
        turq: "#66b2e5",
        dturq: "#66b2e5",
        green: "#007f00",
        white: "#fff"
    },
    labelvis: false, moveto: false, last: 0,
 
    initGraph: function(a, s, datael, glayer, layercount) {
        var time=[];
        var day=[];
        this.a = a;
        this.s = s;
        this.datael=datael;
        this.glayer=glayer;
        this.layercount=layercount;
        this.getData();
        this.setScale();
        this.f = this.c.rect(10, 10, 180, 30, 5).attr(this.fsty).hide();
        this.X = this.w / this.data.length;
        var range = this.max-this.min;
        this.Y = (this.h-this.bg-this.tg)/range;
        this.elw = this.w/(this.cols*2);
        this.label = this.c.text(100, 40, "").attr(this.style).hide();
        this.drawAxis();        
    },
    getData: function() {
        var data=[];
        $j("."+this.datael).each(function () {
            var el = ($j(this).text());
            if (el == "--") el=0;  
            data.push(el);
        });
        this.data=data;
    },
    setScale: function() {
        var max=min=0;
        this.scale = scaleLookup(this.datael);
        if (this.scale) {
            this.max=this.scale.length-1;   
        }
        else {
            max = Math.max.apply(Math, this.data);
            min = Math.min.apply(Math, this.data);
            this.max = Math.ceil(max/5)*5;
            if (this.max <=5) {
                this.max = Math.ceil(max/2)*2;
                this.min = Math.floor(min/2)*2;   
            }
            else {
                if (this.datael != "tp") {
                    this.min = Math.floor(min/5)*5;
                }
            }
            if (this.datael == "wface") {
                this.min = 0;   
            }
        }
    },
    drawAxis: function() {
        var draw=false;
        if (this.layercount <= 2) draw=true;
        if (this.layercount == 4 && this.glayer > 1) draw=true;
        if (this.layercount == 3 && this.glayer > 0) {
            draw=true;
            this.left=(this.left) ? false : true;   
        }
        if (draw) {
            var r = Raphael(this.el+"axis", 54, this.h);
            var gaxis = new GraphAxis(r, this.el+"axis", 54, this.h, this.left, this.title, this.units, this.atitle);
            gaxis.draw(this.scale, this.max, this.min);
        }
    },
    draw: function() {
        var that=this;
        var time=[];
        var day=[];
        $j(".time").each(function() { time.push($j(this).html()); });
        $j(".day").each(function() { day.push($j(this).text()); });
        var plotObjects = new Array(this.data.length);
        var moveto=true;
        var last=0;
        that.path = that.c.path();
        that.bgpath = that.c.path().moveTo(-10, that.h-that.bg);
        for (var i = 0; i < that.data.length; i++) {
            var xb = i*that.elw;
            var val = dataLookup(that.datael, that.data[i]);
            var yb = Math.round((that.h-that.tg)-((val*that.Y))+(that.Y*that.min));
            last=yb;
            var h = Math.round(val*that.Y+(that.Y*Math.abs(that.min)));
            if (h > (that.h-that.bg) - yb) h = (that.h-that.bg) - yb;
            (function (xb, yb, data, time, day) {
                var text = that.plotlabeltxt(that, i, data, time, day);
                var pobj = that.plot(that, i, moveto, xb, yb, h);
                moveto=false;
                plotObjects[i] = (pobj) ? pobj : null;
                if (plotObjects) {
                    if (plotObjects[i]) {
                        plotObjects[i].mouseover(function() {
                            this.attr(that.styleover());
                            xb = (xb<200) ? xb+200 : xb;
                            yb = 95;
                            that.f.show().animate({x: xb-170, y: yb-90}, 200*that.labelvis);
                            that.label.attr({text: text}).show().animate({x: xb-80, y: yb-75}, 200*that.labelvis);
                        }).mouseout(function () {
                            this.attr(that.styleout());   
                            that.f.hide();
                            that.label.hide();
                        });
                    }
                }
                
            })(xb, yb, that.data[i], time[i], day[Math.ceil((i+1)/8)-1]);
        }
        that.graphend(that, last);
        if (plotObjects) that.setvisindex(plotObjects, that.path, that.bgpath);
        that.f.toFront();
        that.label.toFront();
    },
    
    plotlabeltxt: function(that, i, data, time, day) {
        return this.title+": "+data+" "+this.units+"\n @ "+time+" "+day;
    },
    
    plot: function() {
        //override
    },
    styleover: function() {
        //override   
    },
    styleout: function() {
        //override
    },
    setvisindex: function() {
    },
    graphend: function() {
        //override     
    }
});

lineGraph = OpenLayers.Class(StdGraph, {
    
    linestyle: function() {
        return {    stroke: (this.left ? this.color.blue : this.color.red),
                    "stroke-linejoin": "miter",
                    "stroke-width": 2,
                    "stroke-linecap": "butt"
        };
    },
    
    plot: function(that, i, moveto, xb, yb) {
        var pobj=null;
        if (i%2==1) pobj = that.c.circle(xb, yb, 5).attr(that.styleout());
        that.path.attr(that.linestyle());
        that.path[(i==0 || moveto==true) ? "moveTo" : "cplineTo"](xb, yb, 2);
        return pobj;
    },
    
    styleover: function() {
        return { fill: this.color.white, stroke: (this.left) ? this.color.blue : this.color.red };
    },
    
    styleout: function() {
        return { fill: this.left ? this.color.blue : this.color.red, stroke: this.color.white };
    },
    
    setvisindex: function(pobjs, path, bgp) {
    }
});

wfaceGraph = OpenLayers.Class(lineGraph, {
   
    linestyle: function() {
        return {
            stroke: (this.left ? this.color.blue : this.color.red),
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt",
            "stroke-dasharray": "- "
        };
    }
    
});

tpGraph = OpenLayers.Class(lineGraph, {
   
    linestyle: function() {
        return {
            stroke: this.color.red,
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt"
        };
    },
    
    styleover: function() {
        return { fill: this.color.white, stroke: this.color.red };
    },
    
    styleout: function() {
        return { fill: this.color.red, stroke: this.color.white };
    }
});

seachopGraph = OpenLayers.Class(lineGraph, {
   
    linestyle: function() {
        return {
            stroke: this.color.green,
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt"
        };
    },
   
    setScale: function() {
        //on the assumption that these scales are for sea and swell height only
        var data=[];
        var datael=null;
        //use hs data
        $j(".bhs").each(function () {
            var el = ($j(this).text());
            if (el == "--") el=0;  
            data.push(el);
        });
        this.max = Math.ceil(Math.max.apply(Math, data) / 5)*5;
        if (this.max <=5) this.max = Math.ceil(Math.max.apply(Math, data) / 2)*2;
        this.min=0;
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.color.green
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.color.green, stroke: this.color.white, "stroke-width": 1
        };      
    }
    
});

bhsswGraph = OpenLayers.Class(lineGraph, {
   
    linestyle: function() {
        return {
            stroke: this.color.red,
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt"
        };
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.color.red
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.color.red, stroke: this.color.white, "stroke-width": 1
        };      
    },
    
    setScale: function() {
        //on the assumption that these scales are for sea and swell height only
        var data=[];
        var datael=null;
        //we know wave face will be highest -> so use this to set scale
        if (this.layercount > 2) {
            //use wface data
            if ($j(".wface").length) datael = $j(".wface");
            else if ($j(".bhs").length) datael = $j(".bhs");
            datael.each(function () {
                var el = ($j(this).text());
                if (el == "--") el=0;  
                data.push(el);
            });
        }
        else {
            $j(".hs").each(function () {
                var el = ($j(this).text());
                if (el == "--") el=0;  
                data.push(el);
            });
        }
        this.max = Math.ceil(Math.max.apply(Math, data) / 5)*5;
        if (this.max <=5) this.max = Math.ceil(Math.max.apply(Math, data) / 2)*2;
        this.min=0;
    }
    
});

bhsGraph = OpenLayers.Class(lineGraph, {
   
    linestyle: function() {
        return {
            stroke: this.color.blue,
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt"
        };
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.color.blue
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.color.blue, stroke: this.color.white, "stroke-width": 1
        };      
    }
    
});


barGraph = OpenLayers.Class(StdGraph, {
    
    plot: function(that, i, moveto, xb, yb, h) {
            var pobj = that.c.rect(xb-(that.elw/2), yb, that.elw, h).attr(that.styleout());
            return pobj;
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: (this.left) ? this.color.blue : this.color.red, "opacity": 0.5
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.left ? this.color.blue : this.color.red, stroke: this.color.white, "opacity": 0.5
        };      
    },
    
    setvisindex: function(pobjs, path, bgpath) {
        $j.each(pobjs, function(i, value) {
            if (value != null) this.toBack();
        });
    }
});

imgGraph = OpenLayers.Class(StdGraph, {
    data2: new Array(),
    data3: new Array(),
    
    linestyle: function() {
        return { stroke: this.color.green }
    },
    
    plot: function(that, i, moveto, xb, yb, h) {
        var pobj=null;
        if (i%2==1) {
            pobj = that.c.arrow(xb, yb-15, 5, that.data3[i]).attr(that.styleout());
        }
        that.path.attr(that.linestyle());
        that.path[(i==0 || moveto==true) ? "moveTo" : "cplineTo"](xb, yb, 2);
        return (pobj) ? pobj : null;
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.color.green
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.color.green, stroke: this.color.white, "stroke-width": 1
        };      
    },
    
    getData: function() {
        var that=this;
        //ensure clear arrays
        that.data=[];
        that.data2=[];
        that.data3=[];
        
        $j("."+this.datael).each(function () {
            //check for tags and strip them
            var dstr = $j(this).text();
            var dar = dstr.split(":");
            if (dstr == "--") {
                that.data.push(0);
                that.data2.push(0);
                that.data3.push(0);
            }
            else {
                var winddat = [];
                winddat = $j("> span > span", this).attr('class').split(' ');
                that.data.push(winddat[1]);
                that.data2.push(dar[0]);
                that.data3.push(winddat.slice(-1));
            }
        });
    },
    
    plotlabeltxt: function(that, i, data, time, day) {
        return that.title+": "+that.data2[i]+":"+that.data[i]+" "+that.units+"\n @ "+time+" "+day;
    },
    
    setScale: function() {
        var max=min=0;
        this.scale = scaleLookup(this.datael);
        if (this.scale) {
            this.max=this.scale.length-1;   
        }
        else {
            max = Math.max.apply(Math, this.data);
            min = 0;
            this.max = Math.ceil(max/5)*5;
            if (this.max <=5) {
                this.max = Math.ceil(max/2)*2;  
            }
            
        }
    }
});

gstmaGraph = OpenLayers.Class(lineGraph, {
   
    linestyle: function() {
        return {
            stroke: this.color.green,
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt",
            "stroke-dasharray": "- "
        };
    },
    
    plot: function(that, i, moveto, xb, yb) {
        that.path.attr(that.linestyle());
        that.path[(i==0 || moveto==true) ? "moveTo" : "cplineTo"](xb, yb, 2);
    },
    
    setScale: function() {
        //on the assumption that these scales are for sea and swell height only
        var data=[];
        $j(".windma").each(function () {
            //check for tags and strip them
            var dstr = $j(this).text();
            var winddat = [];
            if (dstr == "--") {
                data.push(0);
            }
            else {
                winddat = $j("> span > span", this).attr('class').split(' ');
                data.push(winddat[1]);
            }
        });
        this.max = Math.ceil(Math.max.apply(Math, data) / 5)*5;
        if (this.max <=5) this.max = Math.ceil(Math.max.apply(Math, data) / 2)*2;
        this.min=0;
    }
    
});

seadirGraph = OpenLayers.Class(imgGraph, {

    plot: function(that, i, moveto, xb, yb, h) {
        var pobj=null;
        yb=(that.h-that.tg)/2-10;
        if (i%2==1) pobj = that.c.arrow(xb, yb, 5, that.data3[i]).attr(that.styleout());
        return (pobj) ? pobj : null;
    },
    
    drawAxis: function() {
        //no axis required
    },
    
    plotlabeltxt: function(that, i, data, time, day) {
        return that.title+": "+that.data2[i]+" "+that.data3[i]+" "+that.units+"\n @ "+time+" "+day;
    }
 
});

swelldirGraph = OpenLayers.Class(seadirGraph, {
   linestyle: function() {
        return { stroke: this.color.red }
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.color.red
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.color.red, stroke: this.color.white, "stroke-width": 1
        };      
    }
});

linefillGraph = OpenLayers.Class(StdGraph, {
    
    linestyle: function() {
        return {
            stroke: (this.left ? this.color.turq : this.color.blue),
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt"
        };
    },
    
    bgstyle: function() {
        return {
            stroke: "none",
            fill: (this.left ? this.color.dturq : this.color.dblue),
            "opacity": .5   
        };
    },

    plot: function(that, i, moveto, xb, yb) {
        var pobj=null;
        that.path.attr(that.linestyle());
        that.path[(i==0 || moveto==true) ? "moveTo" : "cplineTo"](xb, yb, 2);
        that.bgpath.attr(that.bgstyle());
        that.bgpath["cplineTo"](xb, yb, 2);
        if (i%2==1) {
            pobj = that.c.circle(xb, yb, 5).attr(that.styleout());
            pobj.toFront();
        }
        return (pobj) ? pobj : null;
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.left ? this.color.turq : this.color.blue
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.left ? this.color.turq : this.color.blue, stroke: this.color.white
        };     
    },
    
    graphend: function(that, last) {
        that.bgpath["cplineTo"](that.w, last, 2);
        that.bgpath["cplineTo"](that.w, that.h-that.bg, 2);
    },
    
    setScale: function() {
        //on the assumption that these scales are for sea and swell height only
        var data=[];
        var datael=null;
        //we know wave face will be highest -> so use this to set scale
        if (this.layercount > 2) {
            //use wface data
            if ($j(".wface").length) datael = $j(".wface");
            else if ($j(".hs").length) datael = $j(".hs");
            datael.each(function () {
                var el = ($j(this).text());
                if (el == "--") el=0;  
                data.push(el);
            });
        }
        else {
            $j(".hs").each(function () {
                var el = ($j(this).text());
                if (el == "--") el=0;  
                data.push(el);
            });
        }
        this.max = Math.ceil(Math.max.apply(Math, data) / 5)*5;
        if (this.max <=5) this.max = Math.ceil(Math.max.apply(Math, data) / 2)*2;
        this.min=0;
    }
    
});

rainGraph = OpenLayers.Class(StdGraph, {
    
    linestyle: function() {
        return {
            stroke: (this.left ? this.color.turq : this.color.red),
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt"
        };
    },
    
    bgstyle: function() {
        return {
            stroke: "none",
            fill: (this.left ? this.color.dturq : this.color.red),
            "opacity": .4
        };
    },

    plot: function(that, i, moveto, xb, yb) {
        var pobj=null;
        that.path.attr(that.linestyle());
        that.path[(i==0 || moveto==true) ? "moveTo" : "cplineTo"](xb, yb, 4);
        that.bgpath.attr(that.bgstyle());
        that.bgpath["cplineTo"](xb, yb, 2);
        if (i%2==1) {
            pobj = that.c.circle(xb, yb, 5).attr(that.styleout());
            pobj.toFront();
        }
        return (pobj) ? pobj : null;
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.left ? this.color.turq : this.color.red
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.left ? this.color.turq : this.color.red, stroke: this.color.white
        };     
    },
    
    graphend: function(that, last) {
        that.bgpath["cplineTo"](that.w, last, 2);
        that.bgpath["cplineTo"](that.w, that.h-that.bg, 2);
    }
});

tideGraph = OpenLayers.Class(linefillGraph, {
    
    linestyle: function() {
        return {
            stroke: this.color.blue,
            "stroke-linejoin": "miter",
            "stroke-width": 2,
            "stroke-linecap": "butt"
        };
    },
    
    bgstyle: function() {
        return {
            stroke: "none",
            fill: this.color.dblue,
            "opacity": .5   
        };
    },
    
    styleover: function() {
        return style = {
            fill: this.color.white, stroke: this.color.blue
        };
    },
    
    styleout: function() {
        return style = {
            fill: this.color.blue, stroke: this.color.white
        };
    },
    
    draw: function() {
        var that=this;
        var plotObjects = new Array(this.data.length);
        var moveto=true;
        that.path = that.c.path();
        that.bgpath = that.c.path().moveTo(-10, that.h-that.bg);
        for (var i = 0; i < that.data.length; i++) {
            var xb = that.w*that.data[i][8];
            var yb = Math.round((that.h-that.tg)-((that.data[i][6]*that.Y))+(that.Y*that.min));
            (function (xb, yb, data) {
                var text = that.plotlabeltxt(that, i, data);
                var pobj = that.plot(that, i, moveto, xb, yb);
                moveto=false;
                plotObjects[i] = (pobj) ? pobj : null;
                if (plotObjects[i]) {
                    plotObjects[i].mouseover(function () {
                        xb = (xb<200) ? xb+200 : xb;
                        yb = 95;
                        this.attr(that.styleover());
                        that.f.show().animate({x: xb-170, y: yb-90}, 200 * that.labelvis);
                        that.label.attr({text: text}).show().animate({x: xb-80, y: yb-75}, 200 * that.labelvis);
                    }).mouseout(function () {
                        this.attr(that.styleout());
                        that.f.hide();
                        that.label.hide();
                    });
                    plotObjects[i].toFront();
                }
            })(xb, yb, that.data[i]);
        }
        that.bgpath["cplineTo"](that.w+10, that.h-that.bg, 16);
        that.f.toFront();
        that.label.toFront();
    },
    
    plot: function(that, i, moveto, xb, yb) {
        var pobj=null;
        that.path.attr(that.linestyle());
        that.path[(i==0 || moveto==true) ? "moveTo" : "cplineTo"](xb, yb, 16);
        that.bgpath.attr(that.bgstyle());
        that.bgpath["cplineTo"](xb, yb, 16);
        pobj = that.c.circle(xb, yb, 5).attr(that.styleout()).toFront();
        return (pobj) ? pobj : null;
    },
 
    plotlabeltxt: function(that, i, data) {
        var text = (that.data[i][7]) ? "High tide: " : "Low tide: ";
        text+=" "+that.data[i][6]+" "+that.units+"\n @ "+that.data[i][9];
        return text;
    },
    
    getData: function() {
        var that=this;
        //make json request
        $j.ajax({
            async: false,
            data : ({'r': "weather", 'a': this.a, 's': this.s, 'x': "t"}),
            success : function (json) {
                that.data=json;
            }
        });
    },
    
    setScale: function() {
        var depths=[];
        for (var i=0; i < this.data.length; i++) {
            depths[i] = this.data[i][6];
        }
        this.max = Math.ceil(Math.max.apply(Math, depths));
        this.min = Math.floor(Math.min.apply(Math, depths));
    }
    
});