﻿/// <reference path="jquery-1.4.1-vsdoc.js" />

function doCufon() {
    Cufon.replace('.label, .CufonAvenir, #thankyoutext, .checkbox label, .DrinkList label, .radiobutton label, h1, h2');
}
doCufon();

function init() {
    doCufon();

    $('input').checkBox();

    $(".ValidateArea").each(function () {
        var group = $(this);
        var control = $(".Input", group);
        var controlInput = $(".Input input.riTextBox, .Input input.textbox", group);
        var isFocused = false;
        // when a Notifications item is clicked or focused, we want to move the z-index to behind
        // the input control, and then give focus to this control.

        var setFocus = function () {
            // reset z-indices for all other  controls
            $(".ValidateArea .Input").css("z-index", 50);
            control.css("z-index", 100);
            if (!isFocused) {
                controlInput.focus();
                controlInput.select();
            }
        };
        group.click(setFocus);

        controlInput.focus(function () {
            isFocused = true;
            setFocus();
        });

        // When the control loses focus, return the z-index
        controlInput.blur(function () {
            isFocused = false;
            control.css("z-index", 50);
        });
    });
}

$(function () {
    init();
});

function pageLoad() {
    init();
}
