$(function () {
	
	// blur all links as soon as you click on them
	
	$('a').click(
		function (e) {
			this.blur();
		}
	);
	
	// section nav hover
	
	$('div#section-nav ul li').hover(
		function (el) { $(this).addClass('hover'); },
		function (el) { $(this).removeClass('hover'); }	
	);
	
	// submit buttons
	
	$('input.submit').hover(
		function (el) { $(this).addClass('submit-hover'); },
		function (el) { $(this).removeClass('submit-hover'); }
	);	
	
	// email to a friend
	
	$('a.email-friend').click(
		function (e) {
		}
	);
	
	// map

	$('a.map').click(
		function (e) {
			$('#map').show();
			return false;
		}	
	);	
	
	$('a.delivery-rates-map').click(
		function (e) {
			$('#map').show();
			return false;
		}	
	);	
	
	// print buttons
	
	$('a.print').click(
		function (el) {
			window.print();
			return false;	
		}	
	);
	
	// close buttons
	
	$('a.close').click(
		function (el) {
			if (this.className.indexOf('no-js') == -1) {
				$(this.parentNode.parentNode).hide();
				return false;
			}
		}	
	);
	
	// sql profiler table
	
	$('div.sql-profiler').click(
		function () {
			this.style.display = 'none';
		}
	
	);
	
	// lightbox
	
	$('a.lightbox').lightBox();
	
	// materials	
	
	$('a.material').click(
		function () {
			var id = this.id;
			id = id.replace('material-', '');
			var overlayId = '#material-overlay-' + id;
			var overlay = $(overlayId);
			
			overlay.show();
			
			return false;
		}
	);
	
	// do home page banners
	
	var len = $('a.home-banner').length;
	var idx = 0;
	
	if (len > 1)
	{
		$('a.home-banner:gt(0)').hide();		
		
		setTimeout(function () { fade(idx) }, 7000);		
	}	
	
	function fade (i)
	{
		// fading from idx to idx + 1
		var from = i;
		var to = i + 1 == len ? 0 : i + 1;
		
		$('a.home-banner:eq(' + from + ')').fadeOut('slow');		
		setTimeout(function () { $('a.home-banner:eq(' + to + ')').fadeIn('slow') }, 750 );
		
		idx = to;		
		
		setTimeout(function () { fade(idx) }, 7000);
	}
});

// room recipe gateway functions

function onProductRollOver (id) {
	$('#product-listing-' + id + ' h4').css('text-decoration', 'underline');
}

function onProductRollOut (id) {
	$('#product-listing-' + id + ' h4').css('text-decoration', 'none');
}