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);

	});

	
});
//Y.use('node', 'async-queue', 'anim',  function(Y) {
//
//	Y.on('domready', function(o) {
//
//		var counts = 0;
//		var start = 1;
//		var cPosition = 1;
//		var timeout = 2000;
//		var startNext = 1;
//
//		Y.all('#slider div').each(function(node) {
//			if ( counts == 0 ) {
//				start = counts+1;
//			} else if ( counts == 1 ) {
//				startNext = counts+1;
//			}
//			counts++;
//		});
//
//
//		window.setTimeout(switchR, timeout ,startNext,start);
//
//		function switchR (current, previous) {
//			var currentNode = Y.one('div#r' + current),
//			previousNode = Y.one('div#r' + previous);
//
//			currentNode.setStyle('opacity', '0');
//
//			var anim = new Y.Anim({
//				node: previousNode,
//				easing: Y.Easing.easeOut,
//				to: {
//					opacity: 0
//				}
//			});
//
//			anim.run();
//			anim.on('end', function(){
//				previousNode.removeClass('active');
//
//				currentNode.setStyle('opacity', 0);
//				currentNode.addClass('active');
//
//				var scrollNode = Y.one('li#s' + current);
//				Y.all('ul#scroll li').removeClass('active');
//				scrollNode.addClass('active');
//
//				var anim = new Y.Anim({
//					node: currentNode,
//					easing: Y.Easing.easeIn,
//					to: {
//						opacity: 100
//					}
//				});
//				anim.run();
//
//				anim.on('end', function(){
//					var next = 0;
//					if ( (current+1) > counts) {
//						next = 1;
//					} else {
//						next = current+1;
//					}
//
//					window.setTimeout(switchR, timeout ,next,current);
//				});
//			});
//		}
//
//
//	});
//
//
//});
