$(function () {
    $('#waitPnl').bind('ajaxSend', function () { showWait(); }).bind('ajaxComplete', function () { hideWait(); });
});
function showWait(text) {
    var el = $('#waitPnl');
    el.css('top', (scrollTop() - 3));
    el.css('left', (windowSize().width / 2 - 50));
    el.show();
    el.html((text) ? text : 'Загрузка');
    window.onscroll = scrollHandler;
}
function hideWait() {
    $('#waitPnl').html('').hide();
    window.onscroll = null;
}
function scrollHandler() {
    $('#waitPnl').css('top', (scrollTop() - 3));
}
function windowSize() {
    var w = 0;
    var h = 0;
    if (!window.innerWidth) {
        if (!(document.documentElement.clientWidth == 0)) {
            w = document.documentElement.clientWidth;
            h = document.documentElement.clientHeight;
        }
        else {
            w = document.body.clientWidth;
            h = document.body.clientHeight;
        }
    }
    else {
        w = window.innerWidth;
        h = window.innerHeight;
    }
    return { width: w, height: h };
}
function scrollTop() {
    if (document.documentElement.scrollTop)
        return document.documentElement.scrollTop;
    else
        return document.body.scrollTop;
}



function ShowHelp(helpType)
{
	if (helpType == 'tutorial')
		OpenPopupWindow(document.location.protocol + '//' + document.location.host + '/help/tutorial.htm');
	else if (helpType == 'search')
		OpenPopupWindow(document.location.protocol + '//' + document.location.host + '/help/search.htm');
	else//'registration'
		OpenPopupWindow(document.location.protocol + '//' + document.location.host + '/help/registration.htm');
}



function OpenPopupWindow(url)
{
	window.open(url,'help','menubar=no,toolbar=no,resizable=yes,width=1150,location=no,status=no,scrollbars=1');
}
