function modalResize(content, w, h){
	SqueezeBox.applyContent(content, {"x":w, "y":h});
}
function addCloseEvents() {
	var closers = $$('.closeWindow');
	if (closers) {
		$each(closers, function(elm) {
			elm.addEvent('click', function(e) {
				e.stop();
				var foo = $(this.getAttribute('rel'));
				if (foo) {
					foo.fade("out");
					foo.activeBubble = false;
					foo.morph({
						'opacity' :0,
						'margin-top' :0
					});
				}
			});
		}, this);
	}
}
window.addEvent('domready', function(event) {
	var loginAccordion = new Fx.Accordion($$('.toggler'), $$('.accElement'), {
		display:-1,
	    alwaysHide: true
	});
	if(document.id('email'))
		new OverText('email');
	if(document.id('password'))
		new OverText('password');
	var loginForm = document.id('loginForm');
	if(loginForm){
		var log = document.id('log_res');
		loginForm.addEvent('submit', function(e){
			if(!$defined(this.flag) || !this.flag){
				e.stop();
			}
			new Request({
				url: Constants.pathDomain+"login/check",
				onSuccess: function(response){
					var data = JSON.decode(response);
					log.empty();
					log.set('html', data.msj);
					log.position({
					    relativeTo: document.id('email'),
					    position: 'centerTop',
					    edge: 'centerBottom'
					});
					log.show();
					if(!data.error){
						loginForm.flag = true;
						loginForm.submit();
							
					}else{
						loginForm.flag = false;
						//Not Activated Yet
					}
				},
				onFailure: function(){
					var log = document.id('log_res').empty();
					log.set('text', Messages.requestFailed);
					e.stop();
				}
			}).send(loginForm.toQueryString());
		});
	}
	if($('destaque-holder')){
		$f("player", {src: "/flash/flowplayer-3.0.7.swf", wmode: 'transparent'} ,{
			clip: {
				scaling:'fit',
				bgcolor: '#000000',
				// use baseUrl so we can play with shorter file names
				baseUrl: 'http://blip.tv/file/get',

				// use first frame of the clip as a splash screen
				autoPlay: false,
				autoBuffering: false
			}
			
		});
		
		// get all links that are inside div#clips
		if(document.id('firstImage'))document.id('firstImage').addEvent('click', function(e){
			$f().play(this.getParent().getAttribute("href", 2));
		});
		if(document.id('sndImage'))document.id('sndImage').addEvent('click', function(e){
			$f().play(this.getParent().getAttribute("href", 2));
		});
		
		$$('a.playable').each(function(btn){
				btn.addEvent('click', function(e){
						e.stop();
						var data = JSON.decode(btn.get("href"));
						document.id('titulo').set('html', data.title);
						document.id('horario').set('html', data.length);
						document.id('texto').set('html', data.description);
						$f().play(data.url);
				});
			});
	}
});
