﻿/**
 * FIX IE6 IMAGE FLICKER PROBLEM
 *
 */
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

$(document).ready(Init);

function Init()
{
	/*
	Determine if content body needs to be stretched
	*/
	var browserHeight = $(window).height();
	var documentHeight = $(document).height();
	var contentHeight = $('#content').height();
	
	if(documentHeight == browserHeight)
	{
		$('#content').css({
			height: (documentHeight - 310) + 'px',
			minHeight: (documentHeight - 310) + 'px'
		});
	}
	
	/*
	Activate the "Print this page" function.
	*/
	$('#printpage').css('display', 'inline').click(function(e){
		window.print();
		return false;
	});
	
	/*
	Rollover effect for image submit buttons.
	*/
	$('input.btnToggles').hover(	
		function(){
			var buttonState = $(this).attr('src').replace(new RegExp('.png'), '_ro.png');			
			$(this).attr('src', buttonState);
		},
		function(){
			var buttonState = $(this).attr('src').replace(new RegExp('_ro.png'), '.png');			
			$(this).attr('src', buttonState);
		}
	);

	/*
	Custom quotes for blockquotes within the sidebar.
	*/
	$('#content-sidebar blockquote').each(function(i){
		$('p:first', this).prepend('<img alt="&#8220;" src="/_images/icons/quote_green_begin.gif" />&#160;');
		$('p:last', this).append('&#160;<img alt="&#8221;" src="/_images/icons/quote_green_end.gif" />');
	});
	
	/*
	Random banner image for non-Flash users.
	*/
	var bannerClassName = new Array('dairy', 'fruit_vegetable', 'wine', 'poultry', 'meat', 'bakery');
	$('#banner').attr('class', bannerClassName[Math.floor(Math.random() * bannerClassName.length)]);	
	
	/*
	Enable edit mode, if activated.
	*/
	if(location.search.indexOf('edit=1') > -1)
	{
		alert('edit mode');
		
		$('#content-body').append('<div class="overlay"></div>');
	}
}
