window.addEvent('domready', function(){
		
		function md(e) { 
  			try { if (event.button==2||event.button==3) return false; }  
  			catch (e) { if (e.which == 3) return false; } 
		}
		document.oncontextmenu = function() { return false; }
		document.ondragstart   = function() { return false; }
		document.onmousedown   = md;
		
		var duration   				= 4000;
		//keep duration the same for all the animation!
		
		var tickers =[
			{'q': 'James assisted me in my latest job search. He is extremely efficient, well organised and reliable. I could not have asked for better service from him. Unlike so many recruitment agents out there he actually showed interest in me as a person as well as my career development', 'cite' : 'Darren B.','type' : 'Candidate','date' : 'August 2011'},
			{'q': 'I just wanted to say a big thank you for helping me secure a permanent job.I was very impressed by the efficiency and professionalism of the consultants, who have always provided a friendly service to me and I have no hesitation in recommending them to other people looking for work', 'cite' : 'Silvia M.','type' : 'Candidate','date' : 'April 2010'},
			{'q': 'I would like to thank you very much for assisting me in getting the job at a Bank. I must admit that the service I have received from Ainsley Morgan has been really good. I also appreciate the way you helped with the on boarding process helping in getting the HR contact andmaking sure that everything is going on smoothly during the on boarding process, asking for feedback during my first week.', 'cite' : 'Jayshree J.','type' : 'Candidate','date' : 'November 2010'},
			{'q': 'Very helpful and friendly staff, great knowledge of the company and what the job involved, kept in touch throughout- good communication. Placed me into a job where I was very keen in going into, and overall a very pleasant and pleasing experience throughout!', 'cite' : 'Carmen K.','type' : 'Candidate','date' : 'March 2010'}
		];
		
		//Tel Vars';
		var tels =[
			{'no' : '020 7434 2323', 'locale': 'London'},
			{'no' : '020 8466 6661', 'locale': 'Kent'},
			{'no' : '020 8688 0505', 'locale': 'Surrey'}
		];
		var delay 					= 600;
		var telPeriodical;
		var currentTel 				= 1;
		
		var no 						= $('tel-roll-no');
		var loc 					= $('tel-roll-locale');
			
			
		var effect = new Fx.Tween('inspiration', {duration: 900}), periodical;
		
		var nextTel = function(){
			
			if ( currentTel == 2){ 
				currentTel  =  0; 
			}else{ 
				currentTel++; 
			}
			
				no.fade(0); 
				loc.fade(0);
				
			(function(){ 
				no.set('text', tels[currentTel]['no'] );
				loc.set('text', tels[currentTel]['locale'] );
				no.fade(1); 
				loc.fade(1);
			}).delay(delay);
			
		} //end nextTel()
		
		/* tel roll function */
		var telRoll = function(){
			telPeriodical = nextTel.periodical(duration);
		};
		
		
		telRoll();
		
		
		//now we get all the testimonials
		var tickerQuote 	= $('ticker-quote');
		
			if( typeOf(tickerQuote) != 'null'){
			var tickerCite 		= $('ticker-cite');
			var currentTick 	= 0;
			var tickerPeriodical;
			
			var nextTicker = function(){
				if ( currentTick == (tickers.length - 1) ){
					currentTick = 0;
				}else{
					currentTick++;	
				}
				tickerQuote.fade(0);
				tickerCite.fade(0);
				(function(){
					tickerQuote.set('text', tickers[currentTick]['q'] );
					tickerCite.set('text', tickers[currentTick]['cite'] +' - ' + tickers[currentTick]['type'] + ' ' + tickers[currentTick]['date'] );
					tickerQuote.fade(1); 
					tickerCite.fade(1);
				}).delay(delay);
			};
			
			var startTicker = function(){
				tickerPeriodical = nextTicker.periodical(duration);
				
			};
			
			startTicker();
		
		}//end ticker typeOf
		
		if ( typeOf( $('parallax-container') ) != 'null' ){
			var wrapper = $('wrapper');
			//parallax stuff
			wrapper.addEvent('mousemove', function(e){
				var docSize		= wrapper.getSize();
				
				var plx = [
					{'obj' : $('parallax-plane-0'),
					 'start_x' : 320,
					 'start_y' : 0,
					 'x_range' : 90,
					 'y_range' : 0,
					 'invert' : false
					 },
					{'obj' : $('parallax-plane-1'),
					 'start_x' : 95,
					 'start_y' : 38,
					 'x_range' : 120,
					 'y_range' : 0,
					 'invert' : false
					 },
					 {'obj' : $('parallax-plane-2'),
					 'start_x' : 230,
					 'start_y' : 90,
					 'x_range' : 140,
					 'y_range' : 0,
					 'invert' : false
					 },
					 {'obj' : $('parallax-plane-bg'),
					 'start_x' : -60,
					 'start_y' : 0,
					 'x_range' : 60,
					 'y_range' : 0
					 }
				];
				
				var x    		= e.page.x;
				var y   		= e.page.y;
				var hRatio 		= Math.round(( x /docSize.x ) * 100)/100;
				var vRatio 		= Math.round(( y /docSize.y ) * 100)/100;
				
				plx.each(function(pl){
						  //invert IF needed?
						   
							   
							   if ( pl['invert'] != true ){
									pl['obj'].setStyle('left',pl['start_x'] + ( pl['x_range']*hRatio ));
									pl['obj'].setStyle('top',pl['start_y'] + (pl['y_range'] *vRatio));
							   }else{
									pl['obj'].setStyle('left',pl['start_x'] - ( pl['x_range']*hRatio ));
									pl['obj'].setStyle('top',pl['start_y'] - (pl['y_range'] *vRatio));
							   }
						   
						   
				 });
	   
			});
	
		} //end parallax-container check
		
		//popup banner in here
		if ( typeOf( $('popup-banner') ) != 'null' ){
			var popupBanner =  $('popup-banner');
			var popupCloser = $('popup-banner-close');
			
			popupCloser.addEvent('click', function(e){
				e.stop();
				var state = popupBanner.get('data-banner-state');
				
				if (state !== 'closed'){
					popupBanner.set('data-banner-state', 'closed').fade(0);
					(function(){ popupBanner.hide();}).delay(500);
				}
				
			});
		}
		
       //initialize the news slider here
	   var splash = new ImageSlider();
	   
	});
	
	//new way of doing the news slider
	
	var ImageSlider = new Class({
	Implements: [Options],
	options: {
		sliders: 'news-ticker-list',
		transitionduration:7500,
		autorotate:true,
		transition:Fx.Transitions.linear
	},
	initialize: function(options) {
		this.setOptions(options);
		var c = this;
		var op = this.options;
		if(op.autorotate) this.animate();
		
		if ( typeOf( $(op.sliders)) == 'element' ){
			$(op.sliders).addEvent('mouseover',function(){op.SlideFX.pause();});
			$(op.sliders).addEvent('mouseleave',function(){op.SlideFX.resume();});
		}
		
	},
	animate:function(){
		var c = this;
		var op = this.options;
		var sliders = $$('#'+op.sliders+' li');
		if(sliders.length>0){
			op.SlideFX = new Fx.Tween(sliders[0],{'transition':op.transition,'duration':op.transitionduration,'onComplete':function(){
				sliders[0].inject($(op.sliders));
				sliders[0].setStyle('margin-left',0);
				c.animate();
			}});
			op.SlideFX.start('margin-left', -sliders[0].getSize().x);
		}
	}
});
