/*@compressme*/

var isLoggedIn = false;

jQuery(document).ready(function() {
    var inputIdentity   = jQuery('#ondemand_loginform #identity, #topbox_loginform #identity, #content_loginform #identity, #default_loginform #identity, #blanklogin_loginform #identity');
    var inputCredential = jQuery('#ondemand_loginform #credential, #topbox_loginform #credential, #content_loginform #credential, #default_loginform #credential, #blanklogin_loginform #credential');

    inputIdentity
		.blur(function() {
			if (this.value == '') {
				this.value = "Username";
			}
		})
		.focus(function() {
			if (this.value == "Username") {
				this.value = '';
			}
		});
	
	if (inputIdentity.val() == '') {
		inputIdentity.val("Username");
	}


    inputCredential.hide();
    inputCredential.parent().append('<input type="text" value="Passwort" id="credentialPlaceholder" class="credentialClass" />');

    jQuery('.credentialClass').each(function() {
        jQuery(this).focus(function() {
            jQuery(this).hide().prev().show().focus();
        });
    });

    inputCredential.each(function() {
        jQuery(this).blur(function() {
            if (this.value == '') {
                jQuery(this).hide().next().show();
            }
        })
        ;
    });

	jQuery('a.needlogin').click(function() {
		if( TB_lastResult == 'loggedin') {
			isLoggedIn = true;
		}
		if( isLoggedIn) {
			return true;
		}
		
		var url = 'auth/login/thickbox/?KeepThis=true&TB_iframe=true&height=388&width=662&TB_window_class=loginthickbox';
		tb_show('Login', url, null);
		return false;
	});
});
