  
$(document).ready(function() {
	
//background fadein
	if($('img.bg').length) {
	var $image = $('img.bg');

	      $('img.bg').hide() //Hide it
		.one('load', function() { //Set something to run when it finishes loading
		  $image.fadeIn(2000); //Fade it in when loaded
		})
		.attr('src', $image.attr("src")) //Set the source so it begins fetching
		.each(function() {
		  //Cache fix for browsers that don't trigger .load()
		  if($image.complete) $image.trigger('load');
		});
	}


  
  
  //content fadein
  
	$('.inner-wrap').hide();
	$('.inner-wrap').fadeIn(1000);
	
	
	
	
	//cycle slideshow
	if ($('.pics').length ) {
			$('.pics').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
	}
	
	

alternatecolors(); //run it when the page loads



//anything that needs to trigger on browser resize
$(window).resize(function(){alternatecolors();});



}); //end of document ready scripts




	
//alternate box colour function
function alternatecolors() {
	if ($('#subboxes').length ) {
		/* $("#subboxes>li:nth-child(2n+1)").css("clear", "both"); */
		//checks if the boxes are in one or two columns then creates alternate div colours.
		var i = 1;
		if ($('#subboxes').width() > 1040) {
			var cols = 2;
			$('#subboxes>li').each(function() {
				if (i % 2 == (Math.ceil(i / cols) % 2 == 0) ? 0 : 1) $(".marketingbox", this).removeClass('altcolour');
				else $(".marketingbox", this).addClass('altcolour');
				i++;
			});
			$('#infobox').width(260);
		} else {
			var cols = 1;
			$('#infobox').width(180);
			$('#subboxes>li:odd>div').addClass('altcolour');
			$('#subboxes>li:even>div').removeClass('altcolour');
		}
	}
}



  

