document.onkeydown = function (event)
{
	if (window.event) 
    {    
        event = window.event;
    }
    if (event.ctrlKey)
    {
		switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
        {
            case 0x25:
                if (window.prev) document.location.href = document.location.protocol + '//' + document.location.host + window.prev;
                //left
            break;
            case 0x27:
                if (window.next) document.location.href = document.location.protocol + '//' + document.location.host + window.next;
                //right
            break;
        }
    }
}

get = function (id)
{
    return document.getElementById(id) || false;
}

blockEvent = function (event)
{
	event = event ? event : window.event;
	if(event.stopPropagation) event.stopPropagation();
	else event.cancelBubble = true;
	if(event.preventDefault) event.preventDefault();
	else event.returnValue = false;
}

countPerPage = function ()
{
    if (get('countPerPageForm') && get('countPerPageSubmit'))
    {
        var cold = get('countPerPage');
        var cnew = get('countPerPageJS');
        if (cold && cnew)
        {
            cold.style.display = 'none';
            cnew.style.display = '';
            get('countPerPageSubmit').style.display = 'none';
            for (var i = 0; i < cold.options.length; i++)
            {
                var a = document.createElement('A');
                a.href = '#';
                a.innerHTML = cold.options[i].value;
                if (cold.options[i].selected) a.className = 'sel';
                a.onclick = function (e)
                {
                    blockEvent(e);
                    get('countPerPage').value = this.innerHTML;
                    var links = document.getElementsByTagName('A');
                    for (var j = 0; j < links.length; j++)
                    {
                        links[j].className = links[j].className.replace('sel', '');
                    }
                    this.className = 'sel';
                    get('countPerPageForm').submit();

                }
                cnew.appendChild(a);
            }
        }        
    }
}

if (!window.funcs) window.funcs = Array();
window.funcs.push(countPerPage);
if (window.onload) window.funcs.push(window.onload);
window.onload = function ()
{
    for (var i in window.funcs)
    {
        window.funcs[i]();
    }
}
