﻿var ac;

function changeType(val) {
    ac.setOptions({ params: { type: val} });
}

$(document).ready(function () {

    $('.tipsy, input[title!=""], select[title!=""], span[title!=""]').tipsy({ fade: true, html: true });

    $("#toolbar").jixedbar();

    $(function () {
        $('input.hint[title!=""]').hint();
    });

    $(".login").colorbox({
        transition: "fade",
        speed: 200,
        opacity: 0.50,
        innerWidth: 360,
        innerHeight: 340,
        iframe: true,
        scrolling: false
    });

    $(".lightbox").colorbox({
        transition: "fade",
        speed: 200,
        opacity: 0.50,
        innerWidth: 500,
        innerHeight: 400,
        iframe: true,
        scrolling: false
    });


    // Search
    $("#list").selectmenu({ width: 90, menuWidth: 90, menuHeight: 10 });

    $('#autocomplete').keydown(function (event) {
        if (event.keyCode == '13') {

            if ($("#list").val() == 'directory')
                location = 'MemberList.aspx?Keywords=' + $('#search').val();

            if ($("#list").val() == 'jobs')
                location = 'JobList.aspx?Keywords=' + $('#search').val();
        }
    });

    var onAutocompleteSelect = function (value, data) {
        if ($("#list").val() == 'directory')
            location = 'MemberList.aspx?idMember=' + data;

        if ($("#list").val() == 'jobs')
            location = 'JobDetails.aspx?idJob=' + data;
    };

    ac = $('#autocomplete').autocomplete({
        serviceUrl: '/Search.ashx',
        width: 'auto',
        delimiter: /(,|;)\s*/,
        onSelect: onAutocompleteSelect,
        deferRequestBy: 0,
        params: { type: 'directory' },
        noCache: true
    });
    // Search Ends

});
