var Mouse = {
	screen:{
	  x:0, 
	  y:0
	},
	scroll:{
	  x:0, 
	  y:0
	},	
	init: function(){
		document.addEvent('mousemove',this.update.bindWithEvent(this));
	},	
	update: function(ev){
		this.screen.x = ev.client.x;
		this.screen.y = ev.client.y;
		this.scroll.x = ev.client.x + window.getScroll().x;
		this.scroll.y = ev.client.y + window.getScroll().y;
		
	}
	
}
Mouse.init();
//document.addEvent('mousemove',function(ev){ console.log(ev); })
//load google analytics

var analytics = new GoogleAnalytics('UA-6065516-3',{log:true});
window.addEvent('domready',function(){

	if($('login-box'))
		initLoginBox();
		
	
	/*if($('home-latest')){
		var container = new Element('div').inject($('home-latest-highlight'));
		$$('#home-latest .movielist-thumb').each(function(el){
			var cont = new Element('div').inject(container)
			el.clone().inject(cont);
		});
		$$('#home-latest .movielist-item').each(function(el){
			el.dispose();
		});
			var mf = new MooFlow(container, {
				startIndex: 5,
				useSlider: true,
				useAutoPlay: true,
				useCaption: false,
				useResize: false,
				useWindowResize: true,
				useMouseWheel: false,
				useKeyInput: true,
				offsetY:-20,
				factor:80,
				heightRatio:0.4
			});

	}*/
	

	
	/*if($$('.movielist')){
		MovieInfo.init();
		
		$$('.movielist-thumb').each(
			function(el){
				var movietitle = el.getParent('a').getProperty('title');
				coords = el.getCoordinates();

				var movieid = el.getProperty('rel');
				
				el.addEvent('mouseenter',function(ev){
					target = ev.target;
					//console.log(target);
					if(target.getProperty('class') != 'movielist-thumb'){
						target = target.getParent('.movielist-thumb');
					}
					
					var targetCoords = target.getCoordinates();
					
					setTimeout(function(){
						if(Mouse.scroll.x < targetCoords.right && Mouse.scroll.x > targetCoords.left && Mouse.scroll.y > targetCoords.top && Mouse.scroll.y < targetCoords.bottom){	
							MovieInfo.open(target,movietitle,movieid);
						}
					},450);
					
					//delayOpen.delay(500);
				
				});
			}
		);
	}*/
	
	initSearchBox('search-box');
//	initWatchButtons();
	//var modal = new Modal();
	//$('test-link').addEvent('click',function(){ modal = new Modal(); modal.open('test'); return false; });
	//until a solution to the http > https problem is found, we can't modal this...
	//initTopUpModal();
});



function initLoginBox(){
	$('login-box').setStyle('height','auto');
	$('login-form').setStyle('display','block');
	var loginform = new Fx.Slide('login-form').hide();
	$('login-box-link').addEvent('click',function(event){
		event.stop();
		loginform.toggle();
	});
}

function initSearchBox(element){
	$(element).setStyles({
		color: '#787878',
		textAlign: 'center'
	}).addEvent('focus',
	
		function(e){
			if(this.value=='search...'){
				this.value='';
				this.style.color='#000000';
				this.style.textAlign = 'left';
			}
		}
	
	).addEvent('blur',
	
		function(e){
			if(this.value==''){
				this.style.color='#787878';
				this.style.textAlign = 'center';
				this.value = 'search...';
			}
		}
	
	);
	
}

/*function initWatchButtons(){
	$$('.watch-now-button').addEvent('click',function(event){
		event.stop();
		el = event.target;
		if(el.get('class') != 'movielist-watch'){
			el = el.getParent('a.movielist-watch');
		}
		playerurl = el.href;
		MOOdalBox.open(playerurl,{width:885, height:510});
		//window.addEvent('modalcomplete',function(){console.log('modal complete');});
	});
	
	window.addEvent('modalplayer_menuloaded',function(menu){
		ModalPlayerMenu.init();	
	});
}*/




/*
function initTopUpModal(){
	$('topup-account-link').addEvent('click',function(event){
		event.stop();
		el = event.target;
		//if(el.class != 'watch-now-button'){
		//	el = el.getParent('a.watch-now-button');
		//}
		url = el.href;
		MOOdalBox.open('/en/add_credit',{width:800});
	});
}*/