
$(document).ready(function () {
    $('.slider').jcarousel({
        initCallback: slider_initCallback,
        itemFirstInCallback: slider_firstInCallback,
        scroll: 1,
        auto: 8, // seconds
        size: 5,
        wrap: 'last',
        animation: 'slow',
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null, 
        // vertical alignment.
        vertical: true
    });
});


function slider_initCallback(carousel) {
    $('.slider-nav a').bind('click', function () {
        carousel.options.animation = 'fast';
        carousel.scroll($.jcarousel.intval($(this).text()));
        carousel.options.animation = 'slow';
        return false;
    });
}


function slider_firstInCallback(carousel, item, idx, state) {
    $('.slider-nav a').removeClass('active');
    $('.slider-nav a').eq(idx - 1).addClass('active');
    if (idx == 5) {
        carousel.options.animation = 0;
        carousel.scroll(1);
        carousel.options.animation = 'slow';
    }
}


//General Functions
$(function () {
    // Tabs
    $('#tabs').tabs();
    //hover states on the static widgets
    $('#dialog_link, ul#icons li').hover(
function () { $(this).addClass('ui-state-hover'); },
function () { $(this).removeClass('ui-state-hover'); }
);
});

$(function () {
    // Accordion
    $("#accordion").accordion({ header: "h3" });
    //hover states on the static widgets
    $('#dialog_link, ul#icons li').hover(
function () { $(this).addClass('ui-state-hover'); },
function () { $(this).removeClass('ui-state-hover'); }
);
});

$(document).ready(function () {
    function callToFocus() {
        $("#txtBoxUserName").children(":input").focus();
    }
    window.setTimeout(callToFocus, 100);
});

function callMouseEvent(evname, elm) {
    if (document.all) {
        elm.fireEvent("on" + evname);
    }
    else {
        var evt = document.createEvent("MouseEvents");
        evt.initMouseEvent(evname, true, true, window,
    0, 0, 0, 0, 0, false, false, false, false, 0, null);

        elm.dispatchEvent(evt);
    }
}

//////////////////
// Added scripts for login input boxes;
function registerEnterToInputBox(ctrl, boxID) {
    ctrl.onkeypress = function (e) {
        if (e == null)
            e = event;
        if (e.keyCode == 13) {
            var o = $("#" + boxID);
            if (o != null) {
                // activating the enter to the place.
                window.eval(o.attr("href").split(':')[1] + ";");
            }
            return false;
        }
    }
    ctrl.onkeypress(window.event);
}

function registerMoveFocusToControl(ctrl, boxID,e) {
    ctrl.onkeypress = function (e) {
        if (e == null)
            e = event;
        if (e.keyCode == 13) {
            var o = document.getElementById(boxID);
            if (o != null) {
                o.focus();
            }
            return false;
        }
    }

    ctrl.onkeypress(window.event);
}
