$(document).ready(function(){ 	


		//imagefade

		$('#teamimage').innerfade({
			animationtype: 'fade', 
			speed: 'slow', 
			timeout: 10000, 
			type: 'sequence', 
			containerheight: '246px' 
		}); 
		$('.contenthome').innerfade({
			animationtype: 'fade', 
			speed: 'slow', 
			timeout: 10000, 
			type: 'random', 
			containerheight: '386px' 
		}); 

		
		//gets round IE8 displaying fixed position on startup
		$(".goto2").click(function () {
			$(".textbox2").toggle();
		});


		//fades in pages - where JS is not present it will be disabled.		
		$('#fadein').hide();
		$('#fadein').fadeIn(1500);
		$('#usuallyhidden').hide(); //only shows navigation if js is disabled on browser

		
	
		//scrollers
		
		$('#slide').cycle({
			cleartypeNoBg:  true,
			cleartype: true,
			prev: '#left-arrow',
			next: '#right-arrow',
			pause: 1,
			fx: 'scrollHorz',
			timeout: 0 
		});
			$('.goto1').click(function() { 
			$('#slide').cycle(0); 
			return false; 
		});
		$('.goto2').click(function() { 
			$('#slide').cycle(1); 
			return false; 
		});
		$('.goto3').click(function() { 
			$('#slide').cycle(2); 
			return false; 
		});


		$('.servicesimg').cycle({
			pause: 1,
			fx: 'fade',
			random:  1
		});
		$('.servicesimg2').cycle({
			pause: 1,
			fx: 'fade',
			random:  1
		});		
		
		$('#newsitem').cycle({ 
			fx: 'fade',
			timeout: 0, 
			next:   '#next2', 
			prev:   '#prev2' 
		});

			$("a[rel=services_group]").fancybox({
				'iframe' : true, 
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'titlePosition' 	: 'inside',
				'overlayOpacity'	: 0.7,
				'overlayColor'		: '#000'
			});
			
		$(".iframe").fancybox({
			'width'				: '75%',
			'height'			: '75%',
			'autoScale'     	: false,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'type'				: 'iframe',
			'titlePosition' 	: 'inside',
			'overlayOpacity'	: 0.7,
			'overlayColor'		: '#000'
		});
			
		//tooltip

		$('img[title]').qtip({
			show: 'mouseover',
			hide: 'mouseout',
			tip: 'topright',
			position: {
			target: 'mouse',
			adjust: { screen: true }
			},
			style: { 
			  padding: 5,
			  background: '#000',
			  color: 'white',
			  textAlign: 'center',
			  'font-size': 14,
			border: {
				width: 1,
				radius: 5,
				color: '#FFF'
			  }
			  
			}

		});
		
		//navigation bg position
	
		$('.nav ul li a')
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate(
				{backgroundPosition:"(-184px 00)"}, 
				{duration:500})
			})
		.mouseout(function(){
			$(this).stop().animate(
				{backgroundPosition:"(0 0)"}, 
				{duration:500})
			})
			
		//gallerypop
		
		$("ul.thumb li").hover(function() {


	$(this).css({'z-index' : '10'
				}); /*Add a higher z-index value so this image stays on top*/ 
	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
			marginTop: '-100px', /* The next 4 lines will vertically align this image */ 
			marginLeft: '-100px',
			top: '100%',
			left: '50%',
			width: '180px', /* Set new width */
			height: '108px', /* Set new height */
			padding: '6px'
		}, 300); /* this value of "200" is the speed of how fast/slow this hover animates */

	
	} , function() {


		$(this).css({'z-index' : '0'
		}); /* Set z-index back to 0 */
		$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '0', /* Set alignment back to default */
				marginLeft: '0',
				top: '0',
				left: '0',
				width: '120px', /* Set width back to default */
				height: '72px', /* Set height back to default */
				padding: '6px'
			}, 600);
			
	});
	
}); 
