$(document).ready(function(){
	
		
	// home page only
	if(jQuery.fn.showhide){
		if($('.client-list a.showhide').length > 0 ){
			$('.client-list a.showhide').showhide({
				animate:true, 
				event: 'mouseover'
			});
		}
		if($('#map a.showhide').length > 0 ){
			$('#map a.showhide').showhide({
				animate:true
			});
		}
		if($('#ourprocess ul.banner li a.showhide').length > 0 ){
			$('#ourprocess ul.banner li a.showhide').showhide({
				animate:true,
				linkOpacity:0.9
			});
		}
		if($('#movie1')){
			
			
			if((navigator.userAgent.match(/iPhone/i)) ||  (navigator.userAgent.match(/iPad/i))) {
			
				$('#showreel').hide();
				$('#movie1').css({'visibility':'visible'});
				
				if(jwplayer && Modernizr && jQuery.fn.getLoadModalFlv){
					$('#movie1 a.show-vid').loadModalFlv({
						width:'377px',
						height:'221px',
						skin:'glow_pink'
					}); 
				}
			}			
			else{
				if(jwplayer && Modernizr && jQuery.fn.getLoadModalFlv){
					$('#movie1 a.show-vid').loadModalFlv({skin:'glow_pink'}); 
				}
			}
		}
	}
	
	// home page only
	if(jQuery.fn.cycle){
	
		if($('#carousel').length > 0){
			
			// add prev and next animation  for cycle plugin
			$.fn.cycle.transitions.scrollBothWays=function($cont,$slides,opts){$cont.css('overflow','hidden');opts.before.push($.fn.cycle.commonReset);opts.fxFn=function(curr,next,opts,cb,fwd){var w=$cont.width();opts.cssFirst={left:0};opts.animIn={left:0};if(fwd){opts.cssBefore={left:w,top:0};opts.animOut={left:0-w}}else{opts.cssBefore={left:-w,top:0};opts.animOut={left:w}};var $l=$(curr),$n=$(next);var speedIn=opts.speedIn,speedOut=opts.speedOut,easeIn=opts.easeIn,easeOut=opts.easeOut,animOut=opts.animOut,animIn=opts.animIn;$n.css(opts.cssBefore);var fn=function(){$n.show();$n.animate(animIn,speedIn,easeIn,cb)};$l.animate(animOut,speedOut,easeOut,function(){if(opts.cssAfter)$l.css(opts.cssAfter);if(!opts.sync)fn()});if(opts.sync)fn()}};
								
			function onBefore(incomingSlide, outgoingSlide, options, isForwardNav) { 
			    /*$(outgoingSlide).children('div.overlay').animate({bottom:-80}, {easing: 'easeInCubic'},{duration:100}, function(){$(this).remove();});*/
				$(outgoingSlide).children('div.overlay').remove();
			} 
			function onAfter(incomingSlide, outgoingSlide, options, isForwardNav) { 
				
				var overlay = $('<div class="overlay" style="z-index:2;"><h3>'+$(this).children('a').children('img').attr('title')+'</h3> - <p>'+$(this).children('a').children('img').attr('alt')+'</p></div>');
				$(this).append(overlay);
				overlay.animate({bottom:3}, {easing: 'easeInCubic'},{duration:100});
				
			}
			
			$('#carousel').cycle({ 
			    fx:     'scrollBothWays', 
			    timeout: 8000,
			    speed: 500,
			    pause: 1, // enable pause on hover
			    next:   'a.next', 
			    prev:   'a.prev',
			    pager:  '#paging',
			    cleartype: true,
			    cleartypeNoBg: true,  
			    before:  onBefore, 
			    after:   onAfter
			});
		}
	}
	
	// about us page only
	if($('#who-box ul#accordian').length > 0){ // check if element is on page
	
		function aboutSlideDown(e){
			$(e).children('div.content').css({'visibility':'visible'});
			
			// changed speed of animation for ie6 			
			if($.browser.msie && $.browser.version=="6.0"){
				var duration = 0;
			}else{
				var duration = 500;
			}
			
			$(e).stop().animate(
				{ height: 400 }, // what we are animating
				{
					duration: duration, // how fast we are animating
					easing: 'easeInCubic', // the type of easing
					complete: function() { // the callback
						// Animation complete.
						$(this).addClass('active');
				   	}
			});
			
			// hide all others
			aboutSlideUp($(e).siblings('li.active'));
			
		}
		
		function aboutSlideUp(e){
			
			// changed speed of animation for ie6 	
			if($.browser.msie && $.browser.version=="6.0"){
				var duration = 0;
			}else{
				var duration = 500;
			}
			
			$(e).stop().animate(
				{ height: 56 }, // what we are animating
				{
					duration: duration, // how fast we are animating
					easing: 'easeInCubic', // the type of easing
					complete: function() { // the callback
						// Animation complete
						$(this).removeClass('active');
						$(e).children('div.content').css({'visibility':'hidden'});

				   	}
			});	
		}

	
		$('#who-box ul#accordian li .title').each(function(){
			
			// bind click behaviour to contact link
			$(this).bind('click', function(){
			
				if($(this).parent('li').hasClass('active')){
					// slide up if active
					aboutSlideUp($(this).parent('li'));			
				}else{
					// slide down
					aboutSlideDown($(this).parent('li'));
				}
				
				return false;
			});
            
		});
	}

});
