var winlist = new Array();

function openWindow(url, name, w, h)
{
    if (typeof(winlist[name]) == 'undefined' || winlist[name].closed) {
        var xy = '';
        var x  = (screen.availWidth - w) / 2;
        var y  = (screen.availHeight - h) / 2;
        winlist[name] = window.open(url, name,
                'toolbar=no,status=no,resizable=yes,scrollbars=yes,width=' +
                w + ',height=' + h + ',top=' + y + ',left=' + x);
    } else {
        winlist[name].focus();
        if (url && winlist[name].location.href != url) {
            winlist[name].location = url;
        }
    }
}

function toggleSection(id)
{
    var obj = document.getElementById(id);
    if (obj.style.display == 'none') {
        obj.style.display = '';
    } else {
        obj.style.display = 'none';
    }
}

$(document).ready(function(){
    var labels = new Array();
    var loginLabel = $('#loginField').attr('value');
    var passwordLabel = $('#passwordField').attr('value');

    $('#loginField')
    .focus(function(){
        if($(this).attr('value') == loginLabel) {
            $(this).attr('value', '');
        }
    })
    .blur(function(){
        if($(this).attr('value') == '') {
            $(this).attr('value', loginLabel);
        }
    })

    $('#passwordField')
    .focus(function(){
        if($(this).attr('value') == passwordLabel) {
            $(this).attr('value', '');
        }
    })
    .blur(function(){
        if($(this).attr('value') == '') {
            $(this).attr('value', passwordLabel);
        }
    })

    var menuItems = $('#userMenu li');

    var firstElement = $(menuItems)[0];
    var lastElement = $(menuItems)[menuItems.get().length-1];

    $(firstElement)
	    .mouseover(function(){
            $('#userMenu .decorTL').css('background-image', 'url("i/box-cornerDark-tl_nr.jpg")');
	        $('#userMenu .decorTR').css('background-image', 'url("i/box-cornerDark-tr_nr.jpg")');
	    })
	    .mouseout(function(){
	        $('#userMenu .decorTL').css('background-image', 'url("i/box-corner-tl_nr.jpg")');
            $('#userMenu .decorTR').css('background-image', 'url("i/box-corner-tr_nr.jpg")');
	    });


    $(lastElement)
        .mouseover(function(){
            $('#userMenu .decorBL').css('background-image', 'url("i/box-cornerDark-bl_nr.jpg")');
            $('#userMenu .decorBR').css('background-image', 'url("i/box-cornerDark-br_nr.jpg")');
        })
        .mouseout(function(){
            $('#userMenu .decorBL').css('background-image', 'url("i/box-corner-bl_nr.jpg")');
            $('#userMenu .decorBR').css('background-image', 'url("i/box-corner-br_nr.jpg")');
        });

    menuItems = $('#leftMenu li');

    firstElement = $(menuItems)[0];
    lastElement = $(menuItems)[menuItems.get().length-1];

    $(firstElement)
	    .mouseover(function(){
            $('#leftMenu .decorTL').css('background-image', 'url("i/box-cornerDark-tl_nr.jpg")');
	        $('#leftMenu .decorTR').css('background-image', 'url("i/box-cornerDark-tr_nr.jpg")');
	    })
	    .mouseout(function(){
	        $('#leftMenu .decorTL').css('background-image', 'url("i/box-corner-tl_nr.jpg")');
            $('#leftMenu .decorTR').css('background-image', 'url("i/box-corner-tr_nr.jpg")');
	    });


    $(lastElement)
        .mouseover(function(){
            $('#leftMenu .decorBL').css('background-image', 'url("i/box-cornerDark-bl_nr.jpg")');
            $('#leftMenu .decorBR').css('background-image', 'url("i/box-cornerDark-br_nr.jpg")');
        })
        .mouseout(function(){
            $('#leftMenu .decorBL').css('background-image', 'url("i/box-corner-bl_nr.jpg")');
            $('#leftMenu .decorBR').css('background-image', 'url("i/box-corner-br_nr.jpg")');
        });

})