/*
 * Top Dog Security (2011) functions
 * 
 * Copyright (c) 2011 The Little Hippo Company (www.thelittlehippocompany.co.uk)
 * MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

$(document).ready(function() {
	// Bind items
	bindContentItems();
	bindNavigationItems();
});

// Function to augment actions inside the content
function bindContentItems(){
	// Change gallery "zoomed image" when hovering over thumbnail
	$('#gallery_images img').mouseover(function (){
		var new_img = $(this).attr('src');
		var new_alt = $(this).attr('alt');
		$('#zoomed_image img').attr('src',new_img);
		$('#zoomed_image img').attr('alt',new_alt);
		$('#zoomed_image p').html(new_alt);
	});

	// Prevent link taking you to new page (redundant due to above)
	$('#gallery_images a').click(function (event){
		event.preventDefault();
	});
}

// Function to augment actions inside the content
function bindNavigationItems(){
	// Grab page info
	var pathname = window.location.pathname;
	var pathname = pathname.split('/');
	var here = '/' + pathname[pathname.length-1];
	var old_class = $("#container").attr('class');

	// This sets the background image depending on which menu item is hovered over
	$('#navigation li').mouseover(function () {
		var new_class = $(this).attr('id').substring(4);
		$("#container").removeClass();
		$("#container").addClass(new_class);
		// IE7 fix (due to z-index not working)
		$(".section_header").hide();
	});

	// This restores background image when not hovering over menu item
	$('#navigation li').mouseout(function () {
		$("#container").removeClass();
		$("#container").addClass(old_class);
		// Undo IE7 fix
		$(".section_header").show();
	});
}
