/*global $,window */
$(function () {
	
    $.sailtime_dialogs.init();

    $.sailtime_help.init();

    $.sailtime_video.init();
		
    // Facets - make sure a click on a facet reaches the a link
    $('li.facet, li.preference:not(.help-preference)').click(function (e) {
        var link = $(this).find('a').attr('href');
        if (typeof link !== "undefined") {
            window.location = link;
        }
        e.stopPropagation();
    });
	
    
    // Save show video on login prefs
    $('#UserShowIntro').live('click', function () {
        $.sailtime_help.saveShowIntroSettings();
    });
	

    $('.st-form-cancel-button').live('click', function() {
        window.location = '/home';
    });

    $('.st-form-save-button').live('click', function() {
        $(this).parents('form').submit();
    });

    $('.st-form-button-group, .st-buttonset').buttonset();
    
    $('button').button();


    // Display error messages if any
    $.sailtime_help.appendFlashMessageErrors();

    // show the intro video if required
    $.sailtime_video.showIntroVideo();
    
});
