Login = {
    init: function() {
        var email = $('lemail');
        var password = $('lpassword');
        if (!email || !password) {
            return;
        }
        
        if (email.get('value') === '') {
            email.set('value', 'your email');
        }
        
        email.addEvent('focus', function() {
            if (this.get('value') === 'your email') {
                this.set('value', '');
            }
        });
        
        email.addEvent('blur', function() {
            if (this.get('value') === '') {
                this.set('value', 'your email');
            }
        });        
        
        
        if (!Browser.Engine.trident) { 
            if (password.get('value') === '') {
                password.set('type', 'text');
                password.set('value', 'password');
            }
            
            password.addEvent('focus', function() {
                if (this.get('value') === 'password') {
                    this.set('value', '');
                    this.set('type', 'password');     
                }
            });            
            
            password.addEvent('blur', function() {
                if (this.get('value') === '') {
                    this.set('value', 'password');
                    this.set('type', 'text');
                }
            });              
        } else {
            var pwpasswordfield = password;
            var pwtextfield = Login.buildInput('text');
            pwtextfield.set('value', 'password');            
            
            if (pwpasswordfield.get('value') === '') {
                var li = pwpasswordfield.getParent('li');
                li.innerHTML = '';
                li.adopt(pwtextfield);                
            }
            
            pwtextfield.addEvent('focus', function() {
                var li = this.getParent('li');
                li.innerHTML = '';
                li.adopt(pwpasswordfield); 
                
                (function(){ pwpasswordfield.focus() }).delay(10);
            });
            
            pwpasswordfield.addEvent('blur', function() {
                if (this.get('value') === '') {
                    var li = this.getParent('li');
                    li.innerHTML = '';
                    li.adopt(pwtextfield); 
                }
            });             

        }
    },
    
    buildInput: function (type) {
        var input = new Element('input', {
            type: type, 
            id: 'lpassword',
            name: 'password',
            size: 15
        });
        return input;
    }
};

window.addEvent('domready', function(){
    Login.init();
});