$(function() {
    $('#navigation a:not(.current)').mouseover(function() {
        $(this).fadeTo(100, 1);
    }).mouseout(function() {
        $(this).fadeTo(300, 0);
    });

    $('#linkPager a').click(function(evt) {
        evt.preventDefault();
        evt.stopPropagation();
        if (!$(this).hasClass('selected')) {
            var id= this.id;
            $('#linkPager a').each(function() {
                if (this.id != id) {
                    $(this).removeClass('selected');
                }
            })
            var leftTo = (parseInt(this.id.slice(4)) - 1) * 642;
            $('#listContainer').animate({'left': -leftTo}, 300);
            $(this).addClass('selected');
        }
    })

	// dialog functionality
	$('a.dialog').click(function(evt) {
		evt.preventDefault();
        evt.stopPropagation();
		$('#dialog').load(this.href, null, loadComplete)
		$('#screen').css({'width': $(document).width(), 'height': $(document).height()})
		if ($.browser.msie) {
			$('#screen').show();
		} else {
			$('#screen').fadeIn(300);
		}
	});
})

function loadComplete() {
	var dlg = $('#dialog');
	var width = dlg.width() / 2;
	var height = dlg.height() /2;
	dlg.css({marginLeft: -width, marginTop: $(window).scrollTop() - height});
	if ($.browser.msie) {
		$('#dialog').show();
	} else {
		$('#dialog').fadeIn(600);
	}
}
