window.addEvent('domready', function()
{

	// Begin Issue Assets - UNIQUE TO INDIVIDUAL ISSUES
	
	//Fall 2010
	/*if ($('hometitle'))
	{
		var titlex = 1200 - $('hometitle').getStyle('right').toInt() - 476; // Calculate Left value
		var titley = $('hometitle').getStyle('top').toInt();
		
		var coffeex = 1200 - $('coffee').getStyle('right').toInt() - 225; // Calculate Left value
		var coffeey = $('coffee').getStyle('top').toInt();
		
		var brunchx = $('brunch').getStyle('left').toInt();
		var brunchy = $('brunch').getStyle('top').toInt();
		
		var dinnerx = $('dinner').getStyle('left').toInt();
		var dinnery = $('dinner').getStyle('top').toInt();
	}*/
	//Fall 2011
	/*
	if ($('hometitle'))
	{
		var titlex = 1200 - $('hometitle').getStyle('right').toInt() - 350; // Calculate Left value
		var titley = $('hometitle').getStyle('top').toInt();
		
		var carrotsx = 1200 - $('carrots').getStyle('right').toInt() - 210; // Calculate Left value
		var carrotsy = $('carrots').getStyle('top').toInt();
		
		var cauliflowerx = $('cauliflower').getStyle('left').toInt();
		var cauliflowery = $('cauliflower').getStyle('top').toInt();
		
		var sproutsx = $('sprouts').getStyle('left').toInt();
		var sproutsy = $('sprouts').getStyle('top').toInt();
	}
	*/
	//Winter 2011
	/*
	if ($('hometitle'))
	{
		var titlex = $('hometitle').getStyle('left').toInt();
		var titley = $('hometitle').getStyle('top').toInt();
		
		var turkeyx = $('turkey').getStyle('left').toInt();
		var turkeyy = $('turkey').getStyle('top').toInt();
		
		var sweetpotatox = $('sweetpotato').getStyle('left').toInt();
		var sweetpotatoy = $('sweetpotato').getStyle('top').toInt();
		
		var cranberryx = $('cranberry').getStyle('left').toInt();
		var cranberryy = $('cranberry').getStyle('top').toInt();
		
		var gingerbreadx = $('gingerbread').getStyle('left').toInt();
		var gingerbready = $('gingerbread').getStyle('top').toInt();
	}
	if ($('holiday_cheer_intro'))
	{
		var introx = 330 + $('holiday_cheer_intro').getStyle('left').toInt(); // Account for left margin (330)
		var introy = $('holiday_cheer_intro').getStyle('top').toInt();
	}
	*/
	//Spring 2012
	if ($('hometitle'))
	{
		var titlex = $('hometitle').getStyle('left').toInt();
		var titley = $('hometitle').getStyle('top').toInt();
		
		var scrambledeggsx = $('scrambledeggs').getStyle('left').toInt();
		var scrambledeggsy = $('scrambledeggs').getStyle('top').toInt();
		
		var pancettax = $('pancetta').getStyle('left').toInt();
		var pancettay = $('pancetta').getStyle('top').toInt();
		
		var potatoesx = $('potatoes').getStyle('left').toInt();
		var potatoesy = $('potatoes').getStyle('top').toInt();
		
		var tomatoesx = $('tomatoes').getStyle('left').toInt();
		var tomatoesy = $('tomatoes').getStyle('top').toInt();
	}
	// End Issue Assets
	
	
	// Determine IE as browser
	if (Browser.Engine.trident) var isIE = true;
		else var isIE = false;
	
	// Determine iPad as a browser
	var isiPad = navigator.userAgent.match(/iPad/i) != null;

	// Resize images to fill space
	function resize()
	{
		if ($('backgroundfill'))
		{
			var minw = 1200;
			var minh = 900;
			var initw = 1200;
			var inith = 900;
			
			if (window.innerHeight) { // Firefox
				var docheight = window.innerHeight;
				var docwidth = window.innerWidth;
			} else if (document.all) { // IE
				var docheight = document.body.clientHeight;
				var docwidth = document.body.clientWidth;
			};
					
			var docratio = docwidth/docheight;
			var ratio = minw/minh;
			
			// Propose scaling to full width
			propw = docwidth;
			proph = docwidth / ratio;
			
			// If scaling to full width causes height cut...
			if (proph < docheight)
			{
				// Propose scaling to full height instead
				propw = docheight * ratio;
				proph = docheight;
			}
			
			// If proposed width is smaller than minimum
			if (propw < minw || proph < minh)
			{
				propw = minw;
				proph = minh;
				
				// But make sure width and height aren't cropped
				if (propw < docwidth)
				{
					// Propose scaling to full width
					propw = docwidth;
					proph = docwidth / ratio;
				}
				if (proph < docheight)
				{
					// Propose scaling to full height instead
					propw = docheight * ratio;
					proph = docheight;
				}
			}
			
			//Scale background to fill
			$('background').setStyle('width', propw);
			$('background').setStyle('height', proph);
			
			//Prevent sidebar collapse
			if (docheight < 745) $('sidebar').setStyle('height', 745);
				else $('sidebar').setStyle('height', '100%');
			
			// Keep top menu width from collapsing
			if (docwidth < $('container').getScrollSize().x)
			{
				$('topmenu').setStyle('width', $('container').getScrollSize().x);
				$('topbar').setStyle('width', $('container').getScrollSize().x);
			}
			else
			{
				$('topmenu').setStyle('width', '100%');
				$('topbar').setStyle('width', '100%');
			}
							
			//Lock credit to prevent unreadability
			if ($('credit'))
			{
				if (docheight < 820)
				{
					$('credit').setStyles({'top': 760, 'bottom': 'auto'});
					$('language_select').setStyles({'top': 760, 'bottom': 'auto'});
				}
				else
				{
					$('credit').setStyles({'top': 'auto', 'bottom': 17});
					$('language_select').setStyles({'top': 'auto', 'bottom': 35});
				}
			}
			
						
			// Begin issue asset repositioning
			// Fall 2010
			/*if ($('hometitle'))
			{
				$('hometitle').setStyle('left', propw / initw * titlex);
				$('coffee').setStyle('left', propw / initw * coffeex - 150 + 150 * propw / initw); // Add slight modification to bump further right
				
				$('brunch').setStyle('left', propw / initw * brunchx);
				$('dinner').setStyle('left', propw / initw * dinnerx);
				
				// Reposition elements proportionally to top
				$('hometitle').setStyle('top', proph / inith * titley);
				$('coffee').setStyle('top', proph / inith * coffeey);
				$('brunch').setStyle('top', proph / inith * brunchy);
				$('dinner').setStyle('top', proph / inith * dinnery);
				
				//Prevent home layout from scrolling
				$('container').setStyle('overflow', 'hidden');
				
				if (docheight < 820)
				{
					$(document.body).setStyle('height', 820);
					$('backgroundfill').setStyle('height', 820);
				}
				else
				{
					$(document.body).setStyle('height', '100%');
					$('backgroundfill').setStyle('height', '100%');
				}
					
			}*/
			// Fall 2011
			/*if ($('hometitle'))
			{
				$('hometitle').setStyle('left', propw / initw * titlex);
				$('carrots').setStyle('left', propw / initw * carrotsx - 150 + 150 * propw / initw); // Add slight modification to bump further right
				
				$('cauliflower').setStyle('left', propw / initw * cauliflowerx);
				$('sprouts').setStyle('left', propw / initw * sproutsx);
				
				// Reposition elements proportionally to top
				$('hometitle').setStyle('top', proph / inith * titley);
				$('carrots').setStyle('top', proph / inith * carrotsy);
				$('cauliflower').setStyle('top', proph / inith * cauliflowery);
				$('sprouts').setStyle('top', proph / inith * sproutsy);
				
				//Prevent home layout from scrolling
				$('container').setStyle('overflow', 'hidden');
				
				if (docheight < 820)
				{
					$(document.body).setStyle('height', 820);
					$('backgroundfill').setStyle('height', 820);
				}
				else
				{
					$(document.body).setStyle('height', '100%');
					$('backgroundfill').setStyle('height', '100%');
				}
					
			}*/
			// Winter 2011
			/*
			if ($('hometitle'))
			{
				$('hometitle').setStyle('left', propw / initw * titlex);
				$('hometitle').setStyle('top', proph / inith * titley);
				$('turkey').setStyle('left', propw / initw * turkeyx);
				$('turkey').setStyle('top', proph / inith * turkeyy);
				$('sweetpotato').setStyle('left', propw / initw * sweetpotatox);
				$('sweetpotato').setStyle('top', proph / inith * sweetpotatoy);
				$('cranberry').setStyle('left', propw / initw * cranberryx);
				$('cranberry').setStyle('top', proph / inith * cranberryy);
				$('gingerbread').setStyle('left', propw / initw * gingerbreadx);
				$('gingerbread').setStyle('top', proph / inith * gingerbready);
				
				//Prevent home layout from scrolling	
				$('container').setStyle('overflow', 'hidden');
							
				if (docheight < 820)
				{
					$(document.body).setStyle('height', 820);
					$('backgroundfill').setStyle('height', 820);
				}
				else
				{
					$(document.body).setStyle('height', '100%');
					$('backgroundfill').setStyle('height', '100%');
				}
					
			}
			if ($('holiday_cheer_intro'))
			{
				$('holiday_cheer_intro').setStyle('left', propw / initw * introx - 330);
				$('holiday_cheer_intro').setStyle('top', proph / inith * introy);
				console.log(proph / inith * introy);
			}
			*/
			// Spring 2012
			if ($('hometitle'))
			{
				$('hometitle').setStyle('left', propw / initw * titlex);
				$('hometitle').setStyle('top', proph / inith * titley);
				$('scrambledeggs').setStyle('left', propw / initw * scrambledeggsx);
				$('scrambledeggs').setStyle('top', proph / inith * scrambledeggsy);
				$('pancetta').setStyle('left', propw / initw * pancettax);
				$('pancetta').setStyle('top', proph / inith * pancettay);
				$('tomatoes').setStyle('left', propw / initw * tomatoesx);
				$('tomatoes').setStyle('top', proph / inith * tomatoesy);
				$('potatoes').setStyle('left', propw / initw * potatoesx);
				$('potatoes').setStyle('top', proph / inith * potatoesy);
				
				//Prevent home layout from scrolling	
				$('container').setStyle('overflow', 'hidden');
							
				if (docheight < 820)
				{
					$(document.body).setStyle('height', 820);
					$('backgroundfill').setStyle('height', 820);
				}
				else
				{
					$(document.body).setStyle('height', '100%');
					$('backgroundfill').setStyle('height', '100%');
				}
					
			}
			// End issue asset repositioning
			
			// Begin iPad correction
			if (isiPad)
			{
				$(document.body).setStyle('width', 1200);
				$('topmenu').setStyle('width', 1200);
				$('topbar').setStyle('width', 1200);
				$('sidebar').setStyle('height', 745);
				
				$(document.body).setStyle('height', '100%');
				$('backgroundfill').setStyle('height', '100%');
				
				if ($(document.body).getElement('div.intro')) $('container').setStyle('height', $(document.body).getElement('div.intro').getScrollSize().y + 16);
				else if ($('inner')) $('container').setStyle('height', $('inner').getScrollSize().y + 16);
				
				// Move background with scroll
				window.addEvent('scroll', function()
				{
					$('backgroundfill').setStyle('top', $(document.body).getScroll().y);
					$('logo').setStyle('top', $(document.body).getScroll().y + 75);
					$('sidebar').setStyle('top', $(document.body).getScroll().y);
					$('topbar').setStyle('top', $(document.body).getScroll().y);
					$('topmenu').setStyle('top', $(document.body).getScroll().y);
				});
			}
		}
	}
		
	// Bind the function to window on resize & then run it on DOM load
	window.onresize = resize;
	resize();
		
	// Set focus for scrolling at load (mostly for IE)
	document.getElementById("container").focus();
			
	// Prepare elements for summaries
	var sideitems = $('sidebar').getElements('.mainmenu li.tip, .mainmenu div.carousel_item');
	var sidesummaries = $('sidebar').getElements('.summary');
	
	// Prepare summaries
	sidesummaries.each(function(summary,i)
	{
		if (!isIE) summary.set('tween', {duration: 350, transition: Fx.Transitions.Quad.easeOut});
		summary.setStyle('opacity', 0);
		summary.setStyle('top', sideitems[i].getPosition().y + (sideitems[i].getScrollSize().y - summary.getScrollSize().y)/2);
	});
	
	// Allow summary visibility after preparation (above)
	$('summaries').setStyle('visibility', 'visible');
	
	// Rotating video features
	if ($('sidebar').getElements('div.carousel_item'))
	{		
		// Prepare counting
		var current = 0;
					
		// Define all slates and selectors
		var slates = $('sidebar').getElements('div.carousel_item');
		var selectors = $('sidebar').getElements('div.selector');
		
		// Setup tweening properties
		slates.each(function(slate,i){ slate.set('tween', {duration: 500, transition: 'quad:in:out'}); });
		
		// Declare periodic variable
		var carousel;
		
		// Incrementing
		var increment = function()
		{
			// Reset current slate's display property
			slates[current].setStyle('display','none');
			
			// Increment available slates, or re-init count
			if (current == slates.length-1) current = 0;
				else current++;
		}
		
		// Jumping
		var jump = function(which)
		{
			// Reset current slate's display property
			slates[current].setStyle('display','none');
			
			// Set current to arg
			current = which;
		}
		
		// Get next slate
		var getSlate = function()
		{
			// Reset the new current slate's styles
			slates[current].setStyles({
				'opacity': 0,
				'display': 'block'
			});
	
			// If necessary, hide all summaries during transition, and fix summary positions
			sidesummaries.each(function(summary,i)
			{
				summary.fade('hide');
				summary.setStyle('top', sideitems[i].getPosition().y + (sideitems[i].getScrollSize().y - summary.getScrollSize().y)/2);
			});			
			
			// Now fade in new
			if (!isIE) slates[current].fade('in');
				else slates[current].fade('show');
			
			// Update selectors
			selectors.each(function(selector,i)
			{
				if (i==current) selector.addClass('current');
					else selector.removeClass('current');
			});
		}
		
		// Build carousel periodical
		var startCarousel = function()
		{
			carousel = (function()
			{
				// Fade out current, then prep next and fade in
				if (!isIE)
				{
					slates[current].fade('out').get('tween').chain(function()
					{
						increment();
						getSlate(); 
					});
				}
				else
				{
					slates[current].fade('hide');
					increment();
					getSlate();
				}
			}).periodical(7500); // Define length of periodic interval
		}
		
		// Start it!
		startCarousel();
	}
	
	// Interactivity for selectors
	selectors.each(function(selector,i)
	{
		selector.addEvents({
			'click': function()
			{
				jump(i); // Define preferred slate
				getSlate();
				$clear(carousel); // Stop carousel
			}
		});
	});
	
	// Interactivity controls for sidebar menus
	sideitems.each(function(link,i)
	{
		link.getElement('a').set('tween', {duration: 350});
		link.addEvents({
			'mouseenter': function()
			{
				this.getElement('a').tween('color', '#ef4023');
				if (!isIE) sidesummaries[i].tween('opacity', 0.9);
					else sidesummaries[i].fade('show');
				$clear(carousel); // Stop carousel
			},
			'mouseleave': function()
			{
				if (!this.hasClass('sel')) this.getElement('a').tween('color', '#5a481c');
				if (!isIE) sidesummaries[i].tween('opacity', 0);
					else sidesummaries[i].fade('hide');
				startCarousel(); // Resume carousel
			}
		});
	});
	
	// Prepare submenu for animation
	var submenuheight = $('topmenu').getElement('.submenu').getScrollSize().y;
	
	$('topmenu').getElement('.submenu').set('tween', {duration: 350, transition: Fx.Transitions.Quad.easeOut});
	$('topmenu').getElement('.submenu').setStyles({
		'opacity': 0,
		'visibility': 'visible',
		'height': 0
	});
	
	// Prepare search menu for animation
	var searchmenuheight = $('topmenu').getElement('.searchmenu').getStyle('height');
	$('topmenu').getElement('.searchmenu').set('tween', {duration: 350, transition: Fx.Transitions.Quad.easeOut});
	$('topmenu').getElement('.searchmenu').setStyles({
		'visibility': 'visible',
		'height': 0
	});
	if (isIE) $('topmenu').getElement('.searchmenu').setStyle('right', '7px');
	$('topmenu').getElement('.closesearch').set('tween', {duration: 350});
	$('topmenu').getElement('.closesearch').setStyle('opacity', 0.3);
	var searchshowing = false;
	
	// Top Menu interactivity
	$('topmenu').getElements('li').each(function(link,i)
	{
		link.getElement('a').set('tween', {duration: 350});
		link.addEvents({
			'mouseenter': function()
			{
				if (this.hasClass('aboutcp')) this.tween('background-color', '#ef4023');
				else if (this.getParent('.submenu')) this.getElement('a').tween('color', '#ef4023');
				else this.getElement('a').tween('color', '#ef4023');
				
				// Show submenu?
				if (this.hasClass('aboutcp'))
				{
					//Fix size if necessary
					var submenuwidth = $('topmenu').getElement('.aboutcp').getScrollSize().x - 215 - 12;
					if (this.getElement('.submenu').getScrollSize().x < submenuwidth + 12 + 12) this.getElement('.submenu').setStyle('width', submenuwidth);
					
					this.getElement('.submenu').get('morph').cancel();
					this.getElement('.submenu').fade('show');
					this.getElement('.submenu').setStyle('opacity', 1);
					this.getElement('.submenu').tween('height', submenuheight);
				}
			},
			'mouseleave': function()
			{
				if (!this.hasClass('sel'))
				{
					if (this.hasClass('aboutcp')) this.tween('background-color', '#bed738');
					else if (this.getParent('.submenu')) this.getElement('a').tween('color', '#fff');
					else this.getElement('a').tween('color', '#5a481c');
				}
				
				// Hide submenu?
				if (this.hasClass('aboutcp'))
				{
					this.getElement('.submenu').get('morph').cancel();
					this.getElement('.submenu').tween('height', 0).get('tween').chain(function()
					{
						$('topmenu').getElement('.submenu').fade('hide');
					});
				}
			},
			'click': function()
			{
				// Show/hide search menu?
				if (this.hasClass('search'))
				{
					if (!searchshowing)
					{
						this.getElement('.searchmenu').fade('show');
						this.getElement('.searchmenu').get('tween').cancel();
						this.getElement('.searchmenu').tween('height', searchmenuheight);
						this.addClass('sel');
						searchshowing = true;
					}
				}
			}
		});
	});
	
	// Close search
	$('topmenu').getElement('.closesearch').addEvents({
		'mouseenter': function()
		{
			this.tween('opacity', 1);
		},
		'mouseleave': function()
		{
			this.tween('opacity', 0.3);
		},
		'click': function()
		{
/* 			$('topmenu').getElement('.searchmenu').fade('out'); */
			$('topmenu').getElement('.searchmenu').tween('height', 0).get('tween').chain(function()
			{
				$('topmenu').getElement('.searchmenu').fade('hide');
				$('topmenu').getElement('.search').removeClass('sel');
				$('topmenu').getElement('.search').getElement('a').tween('color', '#5a481c');
				clearInput($('topmenu').getElement('.searchmenu .textinputcore'));
				searchshowing = false;
			});
			
		}
	});
	
	// Prepare search button functionality
	$('topmenu').getElement('.searchbutton').set('tween', {duration: 350})
	$('topmenu').getElement('.searchbutton').setStyle('opacity',0.5);
	
	//Search button interactivity
	$('topmenu').getElement('.searchbutton').addEvents({
		'mouseenter': function()
		{
			this.tween('opacity',1);
		},
		'mouseleave': function()
		{
			this.tween('opacity',0.5);
		}
	});
	
	// Prepare input clearing
	$('topmenu').getElement('.searchmenu .inputclear').set('tween', {duration: 350});
	$('topmenu').getElement('.searchmenu .inputclear').fade('hide');

	//Search input clearing interactivity
	$('topmenu').getElement('.searchmenu .inputclear').addEvent('click', function(){
		clearInput(this.getParent().getElement('.textinputcore'));
	});
	
	
	// Share icon interactivity
	if ($('share'))
	{
		$('share').getElements('a').each(function(link)
		{
			link.set('tween', {duration: 350});
			link.addEvents({
				'mouseenter': function()
				{
					this.get('tween').cancel();
					this.tween('color', '#5a481c')
				},
				'mouseleave': function()
				{
					this.get('tween').cancel();
					this.tween('color', '#fff')
				}
			});
		});
		
		// Prepare background toggling
		var bgshowing = false;
		
		// Background imagery toggle
		$('showbg').addEvent('click', function(e)
		{
			e.stop();
			if (!bgshowing)
			{
				bgshowing = true;
				$('inner').get('tween').cancel();
				$('inner').fade('out');
				$('overlay').get('tween').cancel();
				$('overlay').fade('out');
				if ($('productshelf'))
				{
					$('productshelf').get('tween').cancel();
					$('productshelf').fade('out');
				}
				if (this.hasClass('fr')) this.innerHTML = 'Cacher l\'Image de Fond';
				else this.innerHTML = 'Hide Background';
			}
			else
			{
				bgshowing = false;
				$('inner').get('tween').cancel();
				$('inner').fade('in');
				$('overlay').get('tween').cancel();
				$('overlay').fade('in');
				if ($('productshelf'))
				{
					$('productshelf').get('tween').cancel();
					$('productshelf').fade('in');
				}
				if (this.hasClass('fr')) this.innerHTML = 'Montrer l\'Image de Fond';
				else this.innerHTML = 'Show Background';
			}
		});
	}
	
	// Recipe filtering interactivity
	if ($('filter'))
	{
		$$('#filter>ul>li').each(function(filter)
		{
			filter.getElement('ul').set('tween', {duration: 350, transition: Fx.Transitions.Quad.easeOut});
			filter.getElement('ul').setStyles({
				'opacity': 0,
				'display': 'block'
			});
			filter.addEvents({
				'mouseenter': function()
				{
					this.getElement('ul').get('tween').cancel();
					if (!isIE) this.getElement('ul').fade('in');
						else this.getElement('ul').fade('show');
				},
				'mouseleave': function()
				{
					this.getElement('ul').get('tween').cancel();
					if (!isIE) this.getElement('ul').fade('out');
						else this.getElement('ul').fade('hide');
				}
			});
		});
	}
	
	// Recipe "item" highlighting
	if ($('grid'))
	{
		var items = $('grid').getElements('.item');
		items = items.concat($('grid').getElements('.listeditem'));
		
		items.each(function(item)
		{
			item.set('tween', {duration: 350});
			item.addEvents({
				'mouseenter': function()
				{
					this.get('tween').cancel();
					this.tween('border-color', '#bed738');
				},
				'mouseleave': function()
				{
					this.get('tween').cancel();
					this.tween('border-color', '#efefef');
				}
			})
		});
	}
	
	// Preview "item" highlighting
	if ($('inner') && $('inner').getElement('.previewlist'))
	{
		var items = $('inner').getElements('.preview');
		
		items.each(function(item)
		{
			// Prepare icon if needed
			if (item.getElement('.image').getElement('.icon'))
			{
				if (!isIE) item.getElement('.image').getElement('.icon').set('tween', {duration: 350});
				item.getElement('.image').getElement('.icon').setStyles({
					'opacity': 0,
					'visibility': 'visible'
				});
			};
			
			item.set('tween', {duration: 350});
			item.addEvents({
				'mouseenter': function()
				{
					this.get('tween').cancel();
					this.tween('border-color', '#bed738');
					if (this.getElement('.icon'))
					{
						this.getElement('.icon').get('tween').cancel();
						if (!isIE) this.getElement('.icon').fade('in');
							else this.getElement('.icon').fade('show');
					}
				},
				'mouseleave': function()
				{
					this.get('tween').cancel();
					this.tween('border-color', '#efefef');
					if (this.getElement('.icon'))
					{
						this.getElement('.icon').get('tween').cancel();
						if (!isIE) this.getElement('.icon').fade('out');
							else this.getElement('.icon').fade('hide');
					}
				}
			});			
		});
	}	
	
	// Product shelf rollovers
	if ($('productshelf'))
	{
		// Prepare tips
		$('productshelf').getElements('.tip').each(function(tip,i)
		{
			if (!isIE) tip.set('tween', {duration: 350, transition: Fx.Transitions.Quad.easeOut});
			tip.setStyles({
				'opacity': 0,
				'visibility': 'visible'
			});
		});
		var summaryinit = sidesummaries[0].getStyle('left').toInt();
		
		
		// Interactivity controls for product tips
		$('productshelf').getElements('.product').each(function(item)
		{
			item.addEvents({
				'mouseenter': function()
				{
					this.getElement('.tip').get('tween').cancel();
					if (!isIE) this.getElement('.tip').fade('in');
						else this.getElement('.tip').fade('show');
				},
				'mouseleave': function()
				{
					this.getElement('.tip').get('tween').cancel();
					if (!isIE) this.getElement('.tip').fade('out');
						else this.getElement('.tip').fade('hide');
				}
			});
		});
	}
	
	// FAQ Interactivity
	if ($('faqs'))
	{
		$('faqs').getElements('.question').each(function(question,i)
		{
			question.set('tween', {duration: 350, transition: Fx.Transitions.Quad.easeOut});
			question.addEvents({
				'mouseenter': function()
				{
					this.getElement('a').tween('color', '#ef4023');
				},
				'mouseleave': function()
				{
					if (!this.hasClass('sel')) this.getElement('a').tween('color', '#5a481c');
				}
			});
		});
		
		if ($('faqs').getElement('.morequestions'))
		{
			$('faqs').getElement('.morequestions').addEvents({
				'mouseenter': function()
				{
					this.tween('color', '#ef4023');
				},
				'mouseleave': function()
				{
					this.tween('color', '#a99c7e');
				},
				'click': function()
				{
					this.setStyle('display', 'none');
					$('faqs').getElement('.more').setStyle('display', 'block');
				}
			});
		}
	}
	
	// Hide Apple "add this" notification if already running fullscreen
	if (window.navigator.standalone && $('apple_device'))
	{
		$('apple_device').setStyle('display','none');
	}

});

// Set initial variable to cleared
var textToClear = false;
	
// Clear input and reset
function clearInput(which)
{
	textToClear = false;
	which.value = "";
	which.getParent().getElement('.inputclear').get('tween').cancel();
	which.getParent().getElement('.inputclear').fade('out');
}

// Search input length detection (determines clear button visibility)
function detectClear(which)
{
	if (which.value.length > 0 && !textToClear)
	{
		textToClear = true;
		which.getParent().getElement('.inputclear').get('tween').cancel();
		which.getParent().getElement('.inputclear').fade('in');
	} else if (which.value.length < 1) {
		clearInput(which);
	}
}

// Get scrollbar width
function scrollWidth()
{
	document.body.style.overflow = 'hidden'; 
	var width = document.body.clientWidth;
	document.body.style.overflow = 'scroll'; 
	width -= document.body.clientWidth; 
	if(!width) width = document.body.offsetWidth - document.body.clientWidth;
	document.body.style.overflow = 'hidden'; 
	return width; 
}

// Popup window for printing
function popup(page)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(page, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=680,height=700,left = 620,top = 250');");
}


function introOut()
{
	$('content').getElement('div.intro').fade('out').get('tween').chain(function()
	{
		$('content').getElements('div.afterintro').each(function(element)
		{
			element.setStyles({
				'opacity': 0,
				'display': 'block'
			});
			element.fade('in');
		});
		
	});
}
