var LabelToInput = {
	init: function() {
	
		$$('.labelvalue').each( function(elmt) {
			$(elmt).hide();
			var txt = $(elmt).innerHTML;
			var chpsTxt = $(elmt).next("input");
			if(chpsTxt.readAttribute('type') == "text")
			{
				chpsTxt.setValue(txt);
				$(chpsTxt).observe('focus', function(event) {
					if(chpsTxt.getValue() == txt)
					{
						chpsTxt.setValue('');
					}
				});
				
				$(chpsTxt).observe('blur', function(event) {
					if(chpsTxt.getValue() == '')
					{
						chpsTxt.setValue(txt);
					}
				});
			}
		});
		
	}
}

var Popin = {

    init: function()
    {	
		$$('ul.messages').each( function(elmt) {
    		$('filter').show();
			Event.observe('filter', 'click', Popin.hideFilter);
			Event.observe(elmt, 'click', Popin.hideFilter);
			
			this.interval = setInterval(function(){Popin.hideFilter()}, 2000);
		});
    },
    
    hideFilter: function()
    {
    	$('filter').hide();
    	$$('ul.messages').each( function(elmt) {
    		$(elmt).hide();
    	});
    	
    	clearInterval(this.interval);
    }
}

Event.observe(window, "load", function() {
	LabelToInput.init();
	Popin.init();
});
