dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dojox.image.Lightbox");
dojo.addOnLoad(function() {

// In field labels
    // Get all inputs supposed to have label overlapping
    var nl = dojo.query('.infieldlabel');
    // Initialize label opacity for inputs that are not empty
    nl.forEach(function(e){
        if(e.value.length > 0) {
            dojo.query('label[for="'+e.id+'"]').style({ opacity: 0 });
        }
    });
    // Define events. Focus : blur label. Keydown : invisible label. Blur : if empty, display label.
    nl.onfocus(function(e){
        if(e.target.value.length === 0) {
            dojo.query('label[for="'+e.target.id+'"]').style({ opacity: 0.5 });
        }
    });
    nl.onkeydown(function(e){
        dojo.query('label[for="'+e.target.id+'"]').style({ opacity: 0 });
    });
    nl.onblur(function(e){
        if(e.target.value.length === 0) {
            dojo.query('label[for="'+e.target.id+'"]').style({ opacity: 1 });
        }
    });

});

function infield_fixer() {

	// In field labels
	    // Get all inputs supposed to have label overlapping
	    var nl = dojo.query('.infieldlabel');
	    // Initialize label opacity for inputs that are not empty
	    nl.forEach(function(e){
	        if(e.value.length > 0) {
	            dojo.query('label[for="'+e.id+'"]').style({ opacity: 0 });
	        }
	    });
	    // Define events. Focus : blur label. Keydown : invisible label. Blur : if empty, display label.
	    nl.onfocus(function(e){
	        if(e.target.value.length === 0) {
	            dojo.query('label[for="'+e.target.id+'"]').style({ opacity: 0.5 });
	        }
	    });
	    nl.onkeydown(function(e){
	        dojo.query('label[for="'+e.target.id+'"]').style({ opacity: 0 });
	    });
	    nl.onblur(function(e){
	        if(e.target.value.length === 0) {
	            dojo.query('label[for="'+e.target.id+'"]').style({ opacity: 1 });
	        }
	    });

	}
