function footer(){
	// determine the current page
	var homepage = /(\/|\/index\.html)$/.test(window.location);
	var about = /\/about\.html$/.test(window.location);
	var contact = /\/contact\.html$/.test(window.location);
	// build footer
	var footer = (homepage ? '<a href="/" class="active">Home</a>' : '<a href="/">Home</a>') + ' | ' +
		(about ? '<a href="/about.html" class="active">About Us</a>' : '<a href="/about.html">About Us</a>') + ' | ' + 
		(contact ? '<a href="/contact.html" class="active">Contact Us</a>' : '<a href="/contact.html">Contact Us</a>') + ' | ' +
		'<a href="/terms.html" onclick="window.open(\'/terms.html\',\'terms\',\'scrollbars=yes,width=660,height=640,resizeable=no\'); return false;">Terms &amp; Conditions</a> ' +
		'<br />' +
		'&reg; Registered trademarks of Cloverhill Pastry-Vend LLC ' +
		'&copy; Copyright 2010. All Rights Reserved. ' +
		'<br />' +
		'Site Created by <a href="http://www.sntialtech.com/" target="_blank">SNtial Technologies</a>.';

	return $('#footer').html(footer);
}

function leftColumn(section){
	var section = section || '';
	// preload images associated with leftNav
	new Image().src = '/images/bg_leftNav.jpg';
	new Image().src = '/images/bg_leftNav_swoosh.png';
	new Image().src = '/images/spacer.gif';
	
	return $('#leftColumn').load('/leftNavigation.html', function(){
		if(section) subNav.openSubNav($('#' + section), true);
		if($.browser.msie && $.browser.version < 7)
			$('#leftNav').css({backgroundImage: 'none'});
		fixPng('#leftNav>li');
	});	
}

var subNav = {
	current:null
};

subNav.openSubNav = function(a, immediate){
	var c = this.current = $(a).next('ul');
	return immediate ? c.css('display', 'block') : c.slideDown('slow');
}

subNav.show = function(a){
	var scope = this;
		
	if(this.current){
		this.current.slideUp('fast', function(){
			if(scope.current.get(0) === $(a).next('ul').get(0)) return scope.current = null;
			scope.openSubNav(a);
		});
	} else {
		this.openSubNav(a);
	}
};

function slideShowLinear(slides){
	var fadeInSpeed = 'slow'; 	// speed of fade-in		could be 'fast' OR 'slow' OR a number representing milliseconds (Example: 1000 = 1 second, 2000 = 2 seconds, 750 = .75 seconds, etc)
	var fadeOutSpeed = 'slow';	// speed of fade-out	could be 'fast' OR 'slow' OR a number representing milliseconds (Example: 1000 = 1 second, 2000 = 2 seconds, 750 = .75 seconds, etc)
	var hold = 2000; 				// speed to hold slide	could be a number representing milliseconds (Example: 1000 = 1 second, 2000 = 2 seconds, 750 = .75 seconds, etc)
	function runSlideshow(idx){
		slides.eq(idx).width( Math.min(214, slides.eq(idx).width()) )
			.css({'margin-left': Math.floor((214 - slides.eq(idx).width())/2),
				'margin-top': Math.floor((200 - slides.eq(idx).height())/2)});
		
		slides.eq(idx).fadeIn(fadeInSpeed, function(){
			setTimeout(function(){
				slides.eq(idx).fadeOut(fadeOutSpeed, function(){
					runSlideshow((idx + 1) % slides.length);
				});
			}, hold);
		});
	}
	
	runSlideshow(0);				
}

function slideShowBounce(slides){
	var fadeInSpeed = 2000; 	// speed of fade-in		could be 'fast' OR 'slow' OR a number representing milliseconds (Example: 1000 = 1 second, 2000 = 2 seconds, 750 = .75 seconds, etc)
	var fadeOutSpeed = 1000; 	// speed of fade-out	could be 'fast' OR 'slow' OR a number representing milliseconds (Example: 1000 = 1 second, 2000 = 2 seconds, 750 = .75 seconds, etc)
	var hold = 2000; 				// speed to hold slide	could be a number representing milliseconds (Example: 1000 = 1 second, 2000 = 2 seconds, 750 = .75 seconds, etc)
	function runSlideshow(idx){
		slides.eq(idx).width( Math.min(214, slides.eq(idx).width()) )
			.css({'margin-left': Math.floor((214 - slides.eq(idx).width())/2),
				'margin-top': Math.floor((200 - slides.eq(idx).height())/2)});
		
		slides.eq(idx).css({'width': '50%', marginLeft: '25%'});
		slides.eq(idx).animate({opacity: 'show', width: '100%', marginLeft: '0%'}, fadeInSpeed, 'easeOutBounce', function(){
			setTimeout(function(){
				slides.eq(idx).animate({opacity: 'hide', width: '50%', marginLeft: '25%'}, fadeOutSpeed, 'easeInOutQuart', function(){
					runSlideshow((idx + 1) % slides.length);
				});
			}, hold);
		});
	}
	
	runSlideshow(0);				
}

function fixPng(imgCollection){
	var imgCollection = imgCollection || 'img[@src$=.png], #logo, #highlight';
	$.ifixpng('/images/spacer.gif');
	$(imgCollection).ifixpng();
	
	$('#highlight').height(Math.max(135, $('#highlight').height()));
}