var Y = YUI({
	base: '/assets/javascript/yui3/'
});
Y.use('node-base', 'node-style', function(Y){
	  /**
     * Overlay Labels verwalten
     */
    var labels = Y.all('label.overlay');
    labels.each(function(label){
        var dependingInput = Y.one('#' + label.getAttribute('for'));
        if (dependingInput === null) {
            return;
        }

        if (Y.Lang.trim(dependingInput.get('value')) == '') {
            label.setStyle('display', '');
        } else {
            label.setStyle('display', 'none');
        }

        dependingInput.on('focus', function(event, label){
            label.setStyle('display', 'none');
        }, dependingInput, label);
        dependingInput.on('blur', function(event, label){
            if (Y.Lang.trim(this.get('value')) == '') {
                this.set('value', '');
                label.setStyle('display', '');
            }
        }, dependingInput, label);
    });
});
Y.use('node', function(Y) {




	Y.all('a.popup').each(function(node) {
		node.setStyle('display','inline');
		Y.on('click', function(e) {
			e.preventDefault();

			tmp = node.getAttribute('class');
			tmp2 = tmp.split(/;/);

			if ( tmp2.length > 1 )  {
				width = tmp2[1];
				height = tmp2[2];
			} else {
				width = 820;
				height = 500;
			}

			window.open(this.get('href'),
				'megadate'+this.get('id'),
				'dependent=yes,height='+height+',width='+width+',scrollbars=yes,adressbar=no');
		},node);

	});

	
});
