$().ready(function () {
    $("ul.dropdown > li > a").each(function (i, el) {
        var s = $(el).html();
        $(el).html("<span>" + s + "</span>");
    });
    $('.subject-select').selectmenu();

    //Show popup on click on the link
    $('.login-button').click(function (event) {
        if ($(".login_form").css("display") == "none") {
            $(".login_form").show();
            event.stopPropagation();
        }
    });

    $('*').click(function (event) {
        
        if ($(this).hasClass('login-button')) return;

        // if the click was not within login form - Hide the form
        var $box = $('.login_form');
        if ($box.has(this).length == 0) {
            if ($box.css("display") != "none") {
                $box.hide();
            }
        }
        // if click inside
        else {
            event.stopPropagation();
        }
    });



    $('body').disableTextSelect();
    $('body').disableCntrlPlus(65);

});



function CU_CheckCaption(controlId, isFocus, text) {
	var c = document.getElementById(controlId);
	if (isFocus) {
		if (c.value == text) { c.value = ""; }
	}
	else {
		if (c.value == "") { c.value = text; }
	}
}


function $$$(el_name) {

	alert(el_name + ", " + document.getElementsByName(el_name).item);

	return document.getElementsByName(el_name)[0];
}


function sendLogin() {
    $('#sendLoginName').val($('#loginName').val());
    $('#sendLoginPass').val($('#loginPassword').val());
    document.frmLogin.submit();
}
