	var home_slide_timer, home_slide_pause;
	Event.observe(document, 'dom:loaded', function() {
	
		// navigation functions
		$$('#nav ul li').each(function(ul) {
			ul.onmouseover = function() {
				$(this).addClassName('selected');
				//if ($(this).down('ul')) $(this).down('ul').show();
				
				if (document.all && $('film-search') && $(this).down('ul') && $(this).down('ul').getElementsBySelector('li').length > 3)
					$$('#film-search select').each(function(x) { x.hide(); });
			}
			ul.onmouseout = function() {
				$(this).removeClassName('selected');
				if (document.all && $('film-search') && $(this).down('ul'))
					$$('#film-search select').each(function(x) { x.show(); });
			}
		});
	
		// slideshow functionality
		if ($('home-slideshow')) {
			home_slide_timer = setInterval('home_slideshow()', 4500);
			home_slide_pause = false;
			$$('#home-slideshow div span').each(function(x) {
				x.onclick = function() {
					home_slideshow(x.previousSiblings().length);
					home_slide_pause = true;
				}
			});
			$('home-slide-pause').onclick = function() {
				if (home_slide_pause) {
					home_slider_timer = setInterval('home_slideshow()', 4500);
					home_slide_pause = false;		
				} else {
					clearInterval(home_slide_timer);
					home_slide_pause = true;
				}
			}
		}
		
		// search field focus/blur events
		if ($('search_text')) {
			$('search_text').observe('focus', function() { if ($(this).value == 'keyword') $(this).value = ''; });
			$('search_text').observe('blur', function() { if ($(this).value == '') $(this).value = 'keyword'; });
		}
		
		// film list detail roll-overs
		$$('#film-listing .film .desc .light').each(function(x) {
			x.onmouseover = function() { $('film-description-popup').show().down('p').update($(this).down('span').innerHTML); }
			x.onmouseout = function() { $('film-description-popup').hide(); }
			x.onclick = function() { location.href = $(this).up('.film').down('.image').down('a').readAttribute('href'); }
		});
		
		// submit the form search on dropdown change
		$$('#film_search select').each(function(x) {
			x.onchange = function() { $(this).up('form').submit(); }
		});
		
	});
	
	Event.observe(document, 'mousemove', function(event) {
		if ($('film-description-popup') && $('film-description-popup').visible()) {		
			$('film-description-popup').setStyle({
				'top': Event.pointerY(event) + 35 + 'px',
				'left': Event.pointerX(event) - 50 + 'px'
			});
		}
	});
	
	function home_slideshow(pos) {
		var current, next;
		$$('#home-slideshow a').each(function(x) {
			if ($(x).visible()) current = x
		});
		
		if (pos != undefined) {
			next = $$('#home-slideshow a')[pos];
			clearInterval(home_slide_timer);
			home_slide_pause = true;
		} else next = (current.next('a')) ? current.next('a') : $('home-slideshow').down('a');
		
		// update side by blocks
		$$('#home-slideshow div span').each(function(x) { x.removeClassName('selected'); });
		$$('#home-slideshow div span')[next.previousSiblings().length].addClassName('selected');
		
		new Effect.Fade(current, { duration: 1 });
		new Effect.Appear(next, { duration: 1 });
	}
	
	function copy_billing_to_shipping() {
		document.checkout_form.shipping_first_name.value = document.checkout_form.billing_first_name.value;
		document.checkout_form.shipping_last_name.value = document.checkout_form.billing_last_name.value;
		document.checkout_form.shipping_address_one.value = document.checkout_form.billing_address_one.value;
		document.checkout_form.shipping_address_two.value = document.checkout_form.billing_address_two.value;
		document.checkout_form.shipping_city.value = document.checkout_form.billing_city.value;
		document.checkout_form.shipping_state.value = document.checkout_form.billing_state.value;
		document.checkout_form.shipping_zip.value = document.checkout_form.billing_zip.value;
		document.checkout_form.shipping_phone.value = document.checkout_form.billing_phone.value;
		document.checkout_form.shipping_email.value = document.checkout_form.billing_email.value;
		document.checkout_form.shipping_company.value = document.checkout_form.billing_company.value;
	}