/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var CTAccueil = Class.create({
    initialize: function() {
        this.carteSelectionne = "PreviTemps";
        this.echeance = "06";
    },


    typeCarte: function () {
        $("MapCTVille").hide();
        new Action ("click", "TempsCTId", function () {
            $("MapCTAccueil").src = "http://88.190.18.22/CT/CartePreviTempsDuGrib" + this.echeance + ".png";
            this.carteSelectionne = "PreviTemps";
        }.bind(this));
        new Action ("click", "TemperatureCTId", function () {
            $("MapCTAccueil").src = "http://88.190.18.22/CT/CarteTMP2mDuGrib" + this.echeance + ".png";
            this.carteSelectionne = "TMP2m";
        }.bind(this));
        new Action ("click", "VentCTId", function () {
            //$("MapCTAccueil").src = "http://88.190.18.22/Libgfs/Grandes/CarteVent2mDuGrib" + this.echeance + ".gif";
            //this.carteSelectionne = "Vent2m";
        }.bind(this));
        new Action ("click", "RegionCTId", function () {
            if (Element.visible($("MapCTRegion"))) {
                $("MapCTRegion").hide();
            } else {
                $("MapCTRegion").show();
            }
        }.bind(this));
        new Action ("click", "VilleCTId", function () {
            if (Element.visible($("MapCTVille"))) {
                $("MapCTVille").hide();
            } else {
                $("MapCTVille").show();
            }
        }.bind(this));
    },
    
    slide: function () {
        var slider = new Control.Slider("HeureCTTotal", "SlideCTTotal", {
            range: $R(5, 95),
            values: [5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,92,95],
            axis: "vertical",
            onChange: function(v){
                $$(".hh").each(function (j) {
                    $(j).setStyle({
                        fontWeight : "normal"
                    });
                });
                var li = v - 5;
                if ($(li + "h") != null) {
                    $(li + "h").setStyle({
                        fontWeight : "bold"
                    });
                }
                if (v<10) {
                    this.echeance = "0"+(v+1);
                } else {
                    this.echeance = (v+1);
                }
                $("MapCTAccueil").src = "http://88.190.18.22/CT/Carte" + this.carteSelectionne + "DuGrib" + this.echeance + ".png?"+ new Date().getHours();
            }.bind(this),
            onSlide:  function(v){
                $$(".hh").each(function (j) {
                    $(j).setStyle({
                        fontWeight : "normal"
                    });
                });
                var li = v - 5;
                if ($(li + "h") != null) {
                    $(li + "h").setStyle({
                        fontWeight : "bold"
                    });
                }
                if (v<10) {
                    this.echeance = "0"+(v+1);
                } else {
                    this.echeance = (v+1);
                }
                $("MapCTAccueil").src = "http://88.190.18.22/CT/Carte" + this.carteSelectionne + "DuGrib" + this.echeance + ".png?"+ new Date().getHours();
            }.bind(this)
        });
    }

});

