// jQuery Innerfade
(function($){$.fn.innerfade=function(options){return this.each(function(){$.innerfade(this,options);});};$.innerfade=function(container,options){var settings={'animationtype':'fade','speed':'normal','type':'sequence','timeout':2000,'containerheight':'auto','runningclass':'innerfade','children':null};if(options)
$.extend(settings,options);if(settings.children===null)
var elements=$(container).children();else
var elements=$(container).children(settings.children);if(elements.length>1){$(container).css('position','relative').css('height',settings.containerheight).addClass(settings.runningclass);for(var i=0;i<elements.length;i++){$(elements[i]).css('z-index',String(elements.length-i)).css('position','absolute').hide();};if(settings.type=="sequence"){setTimeout(function(){$.innerfade.next(elements,settings,1,0);},settings.timeout);$(elements[0]).show();}else if(settings.type=="random"){var last=Math.floor(Math.random()*(elements.length));setTimeout(function(){do{current=Math.floor(Math.random()*(elements.length));}while(last==current);$.innerfade.next(elements,settings,current,last);},settings.timeout);$(elements[last]).show();}else if(settings.type=='random_start'){settings.type='sequence';var current=Math.floor(Math.random()*(elements.length));setTimeout(function(){$.innerfade.next(elements,settings,(current+1)%elements.length,current);},settings.timeout);$(elements[current]).show();}else{alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');}}};$.innerfade.next=function(elements,settings,current,last){if(settings.animationtype=='slide'){$(elements[last]).slideUp(settings.speed);$(elements[current]).slideDown(settings.speed);}else if(settings.animationtype=='fade'){$(elements[last]).fadeOut(settings.speed);$(elements[current]).fadeIn(settings.speed,function(){removeFilter($(this)[0]);});}else
alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');if(settings.type=="sequence"){if((current+1)<elements.length){current=current+1;last=current-1;}else{current=0;last=elements.length-1;}}else if(settings.type=="random"){last=current;while(current==last)
current=Math.floor(Math.random()*elements.length);}else
alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');setTimeout((function(){$.innerfade.next(elements,settings,current,last);}),settings.timeout);};})(jQuery);function removeFilter(element){if(element.style.removeAttribute){element.style.removeAttribute('filter');}}
// Document Ready
$(document).ready(function(){
		var home_text = $("#homecontenttext > .homeabouttext");
		var web_design_text = $("#homecontenttext > .webdesigntext");
		var seo_text = $("#homecontenttext > .seotext");
		
		web_design_text.hide();
		seo_text.hide();
		
		// Whole area clickable
		$("#webheading,#seoheading").click(function(){
			window.location=$(this).find("a").attr("href");return false;
		});
		
		// Homepage hover effects
		$("#webheading,#seoheading,#wearesingle").css("cursor","pointer");
				
		$(".serviceslist").hover(function() {
		  $(this).addClass("serviceslisthover");
		}, function() {
		  $(this).removeClass("serviceslisthover");
		});
		
		$(".hoveroutfix").hover(function() {
			home_text.animate({opacity: "hide", bottom: "30"}, "fast");
		}, function() {
			home_text.animate({opacity: "show", bottom: "20"}, "slow");
		});
		
		$("#webheading").hover(function() {
			web_design_text.animate({opacity: "show", bottom: "20"}, "slow");
		}, function() {
			web_design_text.animate({opacity: "hide", bottom: "30"}, "fast");
		});
		
		$("#seoheading").hover(function() {
			seo_text.animate({opacity: "show", bottom: "20"}, "slow");
		}, function() {
			seo_text.animate({opacity: "hide", bottom: "30"}, "fast");
		});
		
		// Portfolio rotating images		
		$('#rotator').innerfade({ 					
			speed: 800,
			timeout: 4500,
			type: 'sequence',
			containerheight: '480px'

		});
		
		//Fade in links$
		$(".portfoliohover").fadeTo(300, 0); // This sets the opacity of the thumbs to fade down to 30% when the page loads
		$(".portfoliohover").hover(function(){
			$(this).fadeTo(300, 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo(300, 0); // This should set the opacity back to 30% on mouseout
		});

		
});

// Scroll Same Page Links
$(function(){
    $('a.scroll[href*=#]').click(function() {    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {        
            var $target = $(this.hash);            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');            
            if ($target.length) {            
                var targetOffset = $target.offset().top;                
                $('html,body').animate({scrollTop: targetOffset}, 1000);                    
                return false;                
            }            
        }        
    });    
});

// Cufon with ie bug fix
if (typeof is_ie_6 == "undefined") {
	var is_ie_6 = false;
}
if (!is_ie_6) {
	Cufon.replace('h1', {hover: true})('p.headingone', {hover: true})('.blogpost p:first-child', {hover: true})('.wide-main-text p:first-child', {hover: true})('span.day', {hover: true})('.narrow-main-text p:first-child', {hover: true})('p.bigtelephoneno', {hover: true})('#nav li', {hover: true})('h2', {hover: true})('h3', {hover: true})('h4', {hover: true}); 
} else {
	Cufon.replace('h1', {hover: true})('p.headingone', {hover: true})('h2', {hover: true})('h3', {hover: true})('h4', {hover: true}); 
}
