/* ******************** START iOS ******************** */

// stop text enlargement when viewing on iOS devices
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPod/i))) {
	document.write('<style type="text/css">html { -webkit-text-size-adjust: none; }</style>');
}

/* ******************** END iOS ******************** */





/* ******************** START FIREFOX ******************** */

// prevents dotted border when clicking buttons in Firefox
if (navigator.userAgent.indexOf("Firefox")!=-1) {
	document.write('<style type="text/css">button::-moz-focus-inner { border: 0; }</style>');
}

/* ******************** END FIREFOX ******************** */





/* ******************** START HOME BANNER ******************** */

function homeBanner(i) {
	// Update the navigation menu
	$('li.selected', '#home-banner-nav-controls').removeClass('selected');
	$('li:eq(' + i + ')', '#home-banner-nav-controls').addClass('selected');
	
	// Animate the banner image
	$('#home-banner').animate({ "margin-left": ($('li', '#home-banner').width() * i * -1) }, 400 );	

	// Animate the banner assets, but takes three lines and a delay as we dont want to fade the link button
	$('#home-banner-assets-title, #home-banner-assets-category, #home-banner-assets-copy').animate({ opacity: 0.0 }, 120 );	
	$('#home-banner-assets').delay(120).animate({ "margin-left": ($('li', '#home-banner-assets').width() * i * -1) }, 0 );
	$('#home-banner-assets-title, #home-banner-assets-category, #home-banner-assets-copy').delay(120).animate({ opacity: 1.0 }, 120 );	
	
	return false;
}

$('li', '#home-banner-nav-controls').click(function() {
	homeBanner($('li', '#home-banner-nav-controls').index(this));
	return false;
});

/* ******************** END HOME BANNER ******************** */





/* ******************** START HOME BLOGGINS ******************** */

// Setup the bloggins controls
var homeBlogginsIndex = 0;

function homeBloggins(i) {
	// Update the navigation menu
	$('li.selected', '#home-bloggins-box-controls').removeClass('selected');
	$('li:eq(' + i + ')', '#home-bloggins-box-controls').addClass('selected');

	// Animate the bloggins box
	var totalWidth = $('li', '#home-bloggins-box').width();
	totalWidth += parseInt($('li', '#home-bloggins-box').css('padding-left'));
	totalWidth += parseInt($('li', '#home-bloggins-box').css('padding-right'));
	$('#home-bloggins-box').animate({ 'margin-left' : (totalWidth * i * -1) }, 350 );
}

$('#home-bloggins-box-prev').click(function() {
	if (homeBlogginsIndex > 0) {
		homeBlogginsIndex--;
		homeBloggins(homeBlogginsIndex);
	}
	return false;
});

$('#home-bloggins-box-next').click(function() {
	if (homeBlogginsIndex < ($('li', '#home-bloggins-box-controls').size() - 1)) {
		homeBlogginsIndex++;
		homeBloggins(homeBlogginsIndex);
	}
	return false;
});

$('li', '#home-bloggins-box-controls').click(function() {
	homeBlogginsIndex = $('li', '#home-bloggins-box-controls').index(this);
	homeBloggins(homeBlogginsIndex);
	return false;
});

/* ******************** END HOME BLOGGINS ******************** */


/* ******************** START LINK FADING ******************** 


$(".home-link-object p").hover(function(){
	//$(this).animate({backgroundColor:"#FFFFFF"}, 750)
	$(this.background).stop().animate({opacity:0.8}); 
});


/* ******************** END LINK FADING ******************** */


/* ******************** START DOCUMENT READY ******************** */

$(document).ready(function(){

});

/* ******************** END DOCUMENT READY ******************** */








