// Aristocrat Javascript

/*Left Nav toggle - end*/
/*A to Z index*/
//image icon path
var iconExpand = '/_layouts/images/ewr078.gif';
var iconCollapse = '/_layouts/images/ewr079.gif';
 
function ToggleDiv(id) {
    var element = document.getElementById(id);
    if (element == null)
        element = document.getElementById('&#xD;&#xA;   ' + id);
 
    if (element != null) {
        if (element.style.display == 'none') {
            element.style.display = 'block';
            SwitchIcon(id + '_Icon', iconCollapse);
        }
        else {
            element.style.display = 'none';
            SwitchIcon(id + '_Icon', iconExpand);
        }
    }
}
 
function SwitchIcon(id, img) {
    var element = document.getElementById(id);
    if (element != null) {
        element.src = img;
    }
}
/*A to Z index - end*/
function initMenus() {

    $('ul.menu ul').hide();
    $.each($('ul.menu'), function() {
        $('#' + this.id + '.menu ul.expand').show();
    });
    $('ul.menu li a').click(
		function() {
		    var checkElement = $(this).next();
		    var parent = this.parentNode.parentNode.id;

		    if ($('#' + parent).hasClass('noaccordion')) {
		        $(this).next().slideToggle('normal');
		        return false;
		    }
		    if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
		        if ($('#' + parent).hasClass('collapsible')) {
		            $('#' + parent + ' ul:visible').slideUp('normal');
		        }
		        return false;
		    }
		    if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		        $('#' + parent + ' ul:visible').slideUp('normal');
		        checkElement.slideDown('normal');
		        return false;
		    }
		}
	);
}

$(document).ready(function() {

    //Accordian Menus
    initMenus();

    //Disable right click
    $(document).bind("contextmenu", function(e) {
        return false;
    });

    //Game search results sorting
    if ($('#gameSearch').length)
        $('#gameSearch').jTPS({ perPages: [5, 10, 15, 20, 'ALL'] });
});