window.addEvent('domready', function(){
	
		
		
	if($('ukOrAbroad')){
		var locationChooser = $('ukOrAbroad');
		locationChooser.setStyle('display','block');
		var restOfForm = $('contactForm');
		restOfForm.fade('hide');
		var locationInputs = $$('ul#areaChooser li input');
		var locationSelected = $('geogchoice');
		var locationOptions = $$('select#geogchoice option');
		locationInputs.each(function(el){
			if(Browser.Engine.name=='trident'){
				//alert('this is IE');			
				el.set('selected','');
				el.addEvent('click',function(el){
					restOfForm.fade('in');
					var selectedValue = this.get('value');
					if(selectedValue=='int'){
						locationOptions.each(function(item){
							var selectionValue = item.get('value');
							if(selectionValue=='int'){
								item.set('selected','selected');
							};
						});
						
					}else{
						locationOptions.each(function(item){
							var selectionValue = item.get('value');
							if(selectionValue=='uk'){
								item.set('selected','selected');
							};
						});
						
					};
					locationSelected.set('disabled','disabled');
				});
			}else{
				el.addEvent('change',function(el){
					restOfForm.fade('in');
					var selectedValue = this.get('value');
					if(selectedValue=='int'){
						locationOptions.each(function(item){
							var selectionValue = item.get('value');
							if(selectionValue=='int'){
								item.set('selected','selected');
							};
						});
						locationSelected.set('disabled','disabled');
					}else{
						locationOptions.each(function(item){
							var selectionValue = item.get('value');
							if(selectionValue=='uk'){
								item.set('selected','selected');
							};
						});
						locationSelected.set('disabled','disabled');
					};
				});
			};

			
			
		});
	};
	
	
	function doHomeAnim(div){	
		//slide in
		var myFx = new Fx.Tween(div, {transition: 'sine:out', duration: 1500});
		myFx.start('margin-top', '-50', '0');
		
		//set opacity to 0 and fade
		div.set('opacity',0).fade('in');
	}
	
	//check for intro container on home page only
	if($$('div.home div.container')[ 0]){
		//pause before displaying intro container
		var seconds = 2;
		var div = $$('div.home div.container')[0];
		setTimeout(function(){
			div.setStyles({"visibility" : "visible"});
			doHomeAnim(div);
		}, seconds*1000);
	};
});

function equalSelector(colour)
{
	var baseColour = colour;
	
	if($$('div.equal')[0]){
		// SET THE HEIGHT OF THE WHY WE'RE BETTER BOXES 
		var heightDiv  = $$('dl.better dd');
		var maxHeight = 0;
		if(heightDiv){
			heightDiv.each(function(item) { maxHeight = (Math.max(maxHeight, item.getSize().y)); });
			heightDiv.setStyle('height', maxHeight);
		};

		
		// SET UP VARIABLES 
		var columnContainer = $('product-comparison');
		var columns = columnContainer.getChildren('li');
		var allDds = $$('ul#product-comparison dd');
		var allLis = $$('dd ul li');
		var contentMask = new Element('div',{
			 'styles': {
			 	'position': 'absolute',
			 	'background-color': '#FFFFFF',
			 	'width':'626px',
			 	'height':'294px',
			 	'top':'116px',
			 	'left':'155px'
			 },
			 'events': {
			 	
			 	'mouseover': function(el){
			 		contentMask.fade('0');
			 }}
		});

		// MOUSEOUT 		
		// COLUMN HIGHLIGHTING
		columns.each(function(el){
			el.setStyles({
				'position':'relative',
				'top':'0'
			});
			
			var thisDls = el.getChildren('dl');
			var thisDDs = thisDls.getChildren('dd');
			var thisDts = thisDls.getChildren('dt');
			thisDts.each(function(dt){dt.setStyle('visibility','hidden');});

			var columnMask = new Element('div',{
				 'class':'mask',
				 'styles': {
				 	'position': 'absolute',
				 	'background-color': '#FFFFFF',
				 	'width':'146px',
				 	'height':'394px',
				 	'top':'1px',
				 	'right':'14px'
				 },
				 'events': {
				 	
				 	'mouseover': function(el){
				 		columnMask.fade('0');
			 	}}
			});
			columnMask.inject(el,'inside').fade('0');
				 
			el.addEvents({
				'mouseenter': function(){
					contentMask.fade(0);
					var previousLis = el.getAllPrevious('li');
					previousLis.each(function(el){
						var thisMask = el.getChildren('div.mask');
						thisMask.fade(0.9);
					});
					
					var subsequentLis = el.getAllNext('li');
					subsequentLis.each(function(el){
						var thisMask = el.getChildren('div.mask');
						thisMask.fade(0.9);
					});
					
					allDds.each(function(el){
						el.setStyles({
							'color':'#000000'
						})
					});
					var childDl = el.getChildren('dl.better');
					var childDd = childDl[0].getChildren('dd');
					childDd[0].tween('background-color',baseColour);
					var childDlP = el.getChildren('dl');
					var productDd = childDlP.getChildren('dd.product');
					productDd[0].tween('background-color','#CACBCD');
				},
				'mouseleave': function(){
					columnMask.fade('0.9');
					var childDl = el.getChildren('dl.better');
					var childDd = childDl[0].getChildren('dd');
					childDd[0].tween('background-color','#FFFFFF');
					var childDlP = el.getChildren('dl');
					var productDd = childDlP.getChildren('dd.product');
					productDd[0].tween('background-color','#FFFFFF');
				}
			});
		});
			
		var thisDls = columns[0].getChildren('dl');
		var thisDDs = thisDls.getChildren('dd');
		var thisDts = thisDls.getChildren('dt');
		thisDts.each(function(dt){
			dt.setStyles({
				'visibility':'visible',
				'left':'-156px'
			});
		});
			
		contentMask.inject(columnContainer,'inside').fade('0.9');
		
		
		// RESET COLOURS ON LOAD AND MOUSEOUT
		function resetColours(){
			allDds.each(function(el){
				if(el.hasClass('company')){}else{
					el.tween('background-color','#FFFFFF');
				};
			})
		};
		
		columnContainer.addEvents({
			'mouseenter': function(){
				contentMask.fade(0);
			},
			'mouseleave': function(){
				resetColours();
				var masks = $$('div.mask');
				masks.each(
					function(el){
						el.fade(0);
				});
				contentMask.fade(0.9);
			}
		});
			
			// LOAD
			resetColours();
			
		};
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
}
