﻿(function($) {
    var Me = null;
    var timerIn = 0;
    var timerOut = 0;

    function init() {
        Me = this;
        initEvents();
    }

    function initEvents() {
        $("#accountMenu").mouseenter(
            function() {
                if (timerOut) {
                    timerOut = clearTimeout(timerOut);
                } else {
                    timerIn = setTimeout(function() {
                        showMe();
                    }, 300);
                }
            }).mouseleave(
            function() {
                if (timerIn) {
                    timerIn = clearTimeout(timerIn);
                } else {
                    timerOut = setTimeout(function() {
                        hideMe();
                    }, 1000);
                }
            });
    }
    function showMe() {
        $("#accountMenuDrop").fadeIn("slow");
        timerIn = clearTimeout(timerIn);
        $("#mainMenu .pnt").addClass("disabled");
    }
    function hideMe() {
        $("#accountMenuDrop").hide();
        timerOut = clearTimeout(timerOut);
        $("#mainMenu .pnt").removeClass("disabled");
    }    

    $(document).ready(function() {
        init();
    });
})(jQuery)

function LoginToTradeRoom() {    
    var qstring = window.location.search.replace(/\?/, '')    
    
    if (qstring == '') qstring += '?troom=true&type=' + tRoomType;
    else {
        var arr = qstring.split(/&/);

        var i = 0;
        while (i < arr.length) {
            if (/(troom)|(type)/.test(arr[i]))
                arr.splice(i, 1);
            else i++;
        }

        qstring = '?troom=true&type=' + tRoomType;
        if (arr.length > 0) qstring += "&" + arr.join("&");
    }
    window.location.href = window.location.pathname + qstring;
}