using jQuery inside a .js file

using jQuery inside a .js file

Hi 

I have to use a javascript functions on multiple pages. Hence I have created a separate file with extension .js so that I can include it directly where I need it in my code.

function ClosePopup(ctrl, ctrlid, btype) {
    var input = document.getElementsByTagName("a");
    var n = '';

    for (var i = 0; i < input.length; i++) {
        if (btype == 1) {
            n = input[i].id.indexOf("popClose");
            currentpading = input[i].id.replace("popClose", "");
        }
        else {
            n = input[i].id.indexOf("ppclosebk");
            currentpading = input[i].id.replace("ppclosebk", "");
        }
        if (n > -1) {
            if (input[i].id == ctrlid) {
                document.getElementById(currentpading + 'MaskedDivback').style.display = 'none';
                document.getElementById(currentpading + 'ModalPopupDivback').style.display = 'none';

                $('#mycarousel').jcarousel({
                    scroll: 1                     
                });
            }
        }
    }

Here I am getting error 

TypeError: $(...).jcarousel is not a function

Please help me out to get rid of this problem

Any help will be much appreciated.