﻿function stopRKey(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type == "text" || node.type == "password" || node.type == "select-one")) {
        if (node.getAttribute("submitButtonID") != null) {
            var submitButtonID = node.getAttribute("submitButtonID");
            if ((submitButtonID != null) && (submitButtonID != "")) {
                $("#" + submitButtonID).click();
            }
        }
        return false;
    }
}
document.onkeypress = stopRKey; 

$(document).ready(function () {
    var weatherOpen = false;
    var conditionsOpen = false;
    $('#slidebottomWeather #homeSliderWeather').click(function () {
        if (conditionsOpen) {
            $(".innerConditions").slideToggle();
        }
        $(this).next().slideToggle();
        weatherOpen = true;
    });
    $('#slidebottomWeather #homeSliderWeatherClose').click(function () {
        $(".innerWeather").slideToggle();
        weatherOpen = false;
    });

    $('#slideBottomConditions #homeSliderConditions').click(function () {
        if (weatherOpen) {
            $(".innerWeather").slideToggle();
        }
        $('#slidebottomWeather').hide();
        $(this).next().slideToggle();
        conditionsOpen = true;
    });
    $('#slideBottomConditions #homeSliderConditionsClose').click(function () {
        $(".innerConditions").slideToggle();
        $('#slidebottomWeather').show();
        conditionsOpen = false;
    });

//    $(".ResortConditionsLink").fancybox({
//        'hideOnContentClick': false,
//        'zoomSpeedIn': 300,
//        'zoomSpeedOut': 300,
//        'overlayShow': true,
//        'width': 600,
//        'height': 400
//    });

    $("[rel=video_gallery]").fancybox({
        'titleShow': true,
        'transitionIn': 'none',
        'transitionOut': 'elastic',
        'titlePosition': 'inside',
        'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
            switch (currentOpts.type) {
                case 'swf':
                    return '<div id="fancybox-title-swf-wrapper"><div id="fancybox-title-swf">Video ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</div></div>';
                default:
                    return '<div id="fancybox-title-media-wrapper"><div id="fancybox-title-media">Video ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</div></div>';
            }
        },
        'width': 825,
        'height': 650,
        'type': 'multimedia',
        'swf': {
            'wmode': 'transparent',
            'allowfullscreen': true
        },
        'thumbMinWidth': 100
    });

    $("img.swapImage, input.swapImage").hover(
		function () {
		    this.src = this.src.replace("-0", "-1");
		},
		function () {
		    this.src = this.src.replace("-1", "-0");
		}
	);
});

function ClosePopupContent() {
    $("#fancybox-close").trigger('click');
}
