﻿
jQuery(document).ready(function () {
    setupOnBehalfFor();
});

function setupOnBehalfFor() {
    var objOnBehalf = jQuery("#onBehalfOfForm");

    if (objOnBehalf.length == 1) {

        var objEmpList = objOnBehalf.closest("div.employeeList");
        var arrRadioBtns = objOnBehalf.find('input:radio');
        arrRadioBtns.change(function () { objOnBehalf.submit(); });
        arrRadioBtns.each(function () {
            jQuery(this).siblings("label").attr("for", hLib.setID(jQuery(this), "shoppingForList"));
            jQuery(this).siblings("label").change(function () { objOnBehalf.submit(); });
        });

        /*
        objOnBehalf.find('label').click(function () {
        objEmpList.find("div.singleEmp.selected").removeClass("selected");
        jQuery(this).closest("div.singleEmp").addClass("selected");
        });*/

        // Scrolls to correct employee
        var objEmpListSel = objEmpList.find("div.singleEmp.selected");
        if (objEmpListSel.length > 0) objEmpList.scrollTo(objEmpListSel);

        // iPad / iPhone scroll fix
        //var myScroll = new iScroll('onBehalfOfForm');
    }
}
