/*
====================================================================
/// Name: jquery.snow-weather.js
/// Description: This jQuery file is associated with the Snow and Weather Page.
				It helps to switch between inches->cms and F->C
/// Construction Date: 04/29/2009
/// Author: Abhay Dubey
====================================================================
/// Copyright (C) 2008 - 2009 Vail Resort  All Rights Reserved.
====================================================================
*/

$(document).ready(function() {
//ski snow hover
// Show/Hide Weather report on day wise *****
$("#WR1").hide();
$("#WR2").hide();
$("#WR3").hide();
$("#WR4").hide();
$("#WR5").hide();
$("#WR6").hide();
function getPosition(no) {
    //var pos = $("#weatherReportData").position();
    var defaultLeft = -85
    if (no == 0) {
        $(".WinfoBox1").css({ "left": "0px" });
    } else {
        if ($.browser.version == "6.0") {
            $(".WinfoBox1").css({ "left": (defaultLeft * no) + "px" });
        } else {
            $(".WinfoBox1").css({ "left": ((defaultLeft * no) - no) + "px" });
        }
    }
}
$(".detailedForecast ul li[id$=liDayone]").hover(
		function() {
		    $("#WR1").show();
		    $(this).children(":first").addClass("snowShadowOn");
		    getPosition(0)
		},
		function() {
		    $("#WR1").hide();
		    $(this).children(":first").removeClass("snowShadowOn");
		});

$(".detailedForecast ul li[id$=liDaytwo]").hover(
		function() {
		    $("#WR2").show();
		    $(this).children(":first").addClass("snowShadowOn");
		    getPosition(1)
		},
		function() {
		    $("#WR2").hide();
		    $(this).children(":first").removeClass("snowShadowOn");
		});

$(".detailedForecast ul li[id$=liDaythree]").hover(
		function() {
		    $("#WR3").show();
		    $(this).children(":first").addClass("snowShadowOn");
		    getPosition(2)
		},
		function() {
		    $("#WR3").hide();
		    $(this).children(":first").removeClass("snowShadowOn");
		});

$(".detailedForecast ul li[id$=liDayfour]").hover(
		function() {
		    $("#WR4").show();
		    $(this).children(":first").addClass("snowShadowOn");
		    getPosition(3)
		},
		function() {
		    $("#WR4").hide();
		    $(this).children(":first").removeClass("snowShadowOn");

		});

$(".detailedForecast ul li[id$=liDayfive]").hover(
		function() {
		    $("#WR5").show();
		    $(this).children(":first").addClass("snowShadowOn");
		    getPosition(4)
		},
		function() {
		    $("#WR5").hide();
		    $(this).children(":first").removeClass("snowShadowOn");

		});

$(".detailedForecast ul li[id$=liDaysix]").hover(
		function() {
		    $("#WR6").show();
		    $(this).children(":first").addClass("snowShadowOn");
		    getPosition(5)
		},
		function() {
		    $("#WR6").hide();
		    $(this).children(":first").removeClass("snowShadowOn");

		});	
		
    $(".units li a").live("click", function(event) {
        event.preventDefault();

        var eleClass = $(this).parent().attr("class");
        if (eleClass == "centimeters" || eleClass == "celsius") {


            var currentTxt = $(this).parent().prev().text()
            var conTxt = '<a href="#">' + currentTxt + '</a>'
            $(this).parent().prev().text("");
            $(this).parent().prev().append(conTxt);
            if (eleClass == "centimeters") {
                $(this).parent().text("cm");
                $("span.centimeters").removeClass("hide");
                $("span.centimeters").show();
                $("span.inches").hide()
            } else {
                $(this).parent().html("&deg;C");
                $("span.fahrenheit").hide();
                $("span.celsius").removeClass("hide");
                $("span.celsius").show();
            }
        } else {


            var currentTxt = $(this).parent().next().text()
            var conTxt = '<a href="#">' + currentTxt + '</a>'
            $(this).parent().next().text("");
            $(this).parent().next().append(conTxt);
            if (eleClass == "unitBorder inches") {
                $(this).parent().text("inches");
                $("span.inches").show();
                $("span.centimeters").hide()
            } else {
                $(this).parent().html("&deg;F");
                $("span.fahrenheit").show();
                $("span.celsius").hide()
            }

        }

    });
});
