/* 
	Title: Lynn Shepherd - JavaScript document for splash page
	Description: Contains custom JavaScript functions
	Version: 0.2
	Author: Ben Ellis
	Author URI: http://www.hungrybrowser.co.uk
	Created: 24/11/2011
	Updated: 27/11/2011
*/

/* ------------------------------------------------------------
	Declare the global functions
---------------------------------------------------------------- */

/*
	Function to add custom event tracking to an object using Google Analytics
	@param: id = id of the object to target
	@param: category for the event
	@param: action for the event
	@param: title of the event
*/
function trackEvent(id,category, action, title){
	$(document).ready(function(){
		// Attach the event
		$(id).click(function(){
			_gaq.push(['_trackEvent', category, action, title]);
		});
	});
}

/*
	function to animate the page
	@param: id = id of the page
*/
function animateFrames(id){
	$(document).ready(function(){
		// For devices larger than an iPhone 
		if ($(window).width() > 480){
			// Add the animate class to the wrapper
			$(id).addClass('animate');
			// Hide the sections
			$('section').hide();
			// Frame 1
			$('#frame_1').delay(2000).fadeIn(2000).delay(3000).fadeOut(2000);
			// Frame 2
			$('#frame_2').delay(9000).fadeIn(2000).delay(3000).fadeOut(2000);
			// Frame 3
			$('#frame_3').delay(16000).fadeIn(2000);
		}
	});
}

/* 
	Function to fade the div
	@param: triggerId = id of the element to add the event to
	@param: parentId = id of the parent item to fade out
	@param: targetId = id of the item to fade in
*/
function finalFrame(triggerId,parentId,targetId){
	$(document).ready(function(){
		// Attach the event to the link
		$(triggerId).click(function(){
			// Hide the parent div
			$(parentId).fadeOut(1000);
			// Show the target div
			$(targetId).delay(500).fadeIn(1000);
			// Ensure that the anchors don't make the page jump 
			return false;
		});
	});
}

