
	/* Sleight for PNGs
	--------------------------------------------------------*/
	if (navigator.platform == 'Win32' && navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.indexOf ('MSIE 7') == -1 && window.attachEvent)
		window.attachEvent ('onload', alphaBackgrounds);

	function alphaBackgrounds ()
	{
		var rslt = navigator.appVersion.match (/MSIE (\d+\.\d+)/, '');
		var itsAllGood = (rslt != null && Number (rslt[1]) >= 5.5);
		for (i = 0; i < document.all.length; i++)
		{
			var bg = document.all[i].currentStyle.backgroundImage;
			var img = document.all[i].src;
			if (itsAllGood)
			{
				if (bg && bg.match (/\.png/i) != null)
				{
					var mypng = bg.substring (5, bg.length-2);
					document.all[i].style.zoom = '1.0';
					document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + mypng + "', sizingMethod='crop')";
					document.all[i].style.backgroundImage = "url('/assets/images/x.gif')";
				}
				else if (img && img.match (/\.png/i) != null)
				{
					img = document.all[i];
					img.style.width = img.width + 'px';
					img.style.height = img.height + 'px';
					img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='crop')";
					img.src = '/images/spacer.gif';
				}
			}
		}
	}

	comments_effect = false;
	prompts_show_effect = false;
	prompts_hide_effect = false;

	window.addEvent ('load', function () {
		if ($('comment_form'))
		{
			// Effect used to slide the comment form
			comments_effect = new Fx.Style ('comment_form', 'margin-top', {duration: 1000, wait: false, transition: Fx.Transitions.Elastic.easeOut});

			// Call it once on load
			reposition_comments ();

			// Call it whenever the window is scrolled
			window.addEvent ('scroll', reposition_comments);
		}

		if ($('prompts'))
		{
			prompts_show_effect = new Fx.Style ('prompts', 'top', {duration: 1000, wait: false, transition: Fx.Transitions.Elastic.easeOut});
			prompts_hide_effect = new Fx.Style ('prompts', 'top', {duration: 400, wait: false, transition: Fx.Transitions.Quad.easeIn});
			$('prompts').addEvent ('click', hide_prompts);
			$('prompt_closer').onclick = function () { return false; };
			(function () { show_prompts (); }).delay (250);
		}

		if ($('comment_form'))
		{
			$('author').addEvent ('focus', function () {
				this.value = this.value == 'Your Name' ? '' : this.value;
			});
			$('author').addEvent ('blur', function () {
				this.value = this.value.trim () == '' ? 'Your Name' : this.value;
			});
			$('email').addEvent ('focus', function () {
				this.value = this.value == 'Your E-Mail Address (Optional)' ? '' : this.value;
			});
			$('email').addEvent ('blur', function () {
				this.value = this.value.trim () == '' ? 'Your E-Mail Address (Optional)' : this.value;
			});
			$('url').addEvent ('focus', function () {
				this.value = this.value == 'Your Website URL (Optional)' ? 'http://' : this.value;
			});
			$('url').addEvent ('blur', function () {
				this.value = this.value.replace ('http://', '').trim () == '' ? 'Your Website URL (Optional)' : this.value;
			});
			$('body_raw').addEvent ('focus', function () {
				this.value = this.value == 'Your Comments Here' ? '' : this.value;
			});
			$('body_raw').addEvent ('blur', function () {
				this.value = this.value.trim () == '' ? 'Your Comments Here' : this.value;
			});
			if ($chk ($('antispam')))
			{
				$('antispam').addEvent ('focus', function () {
					this.value = this.value == 'Type the word you see below:' ? '' : this.value;
				});
				$('antispam').addEvent ('blur', function () {
					this.value = this.value.trim () == '' ? 'Type the word you see below:' : this.value;
				});
			}

			$$('#comment_form input.button').addEvent ('click', function () {
				$('author').value = $('author').value == 'Your Name' ? '' : $('author').value;
				$('email').value = $('email').value == 'Your E-Mail Address (Optional)' ? '' : $('email').value;
				$('url').value = $('url').value == 'Your Website URL (Optional)' ? '' : $('url').value;
				$('body_raw').value = $('body_raw').value == 'Your Comments Here' ? '' : $('body_raw').value;
			});

			$('comment_form').addEvent ('click', function (event) {
				if (!$('comment_form').hasClass ('pinned'))
				{
					window.removeEvent ('scroll', reposition_comments);
					$('comment_form').addClass ('pinned');
				}
				event.stopPropagation ();
			}).setStyle ('z-index', 10000000);
			$(document.body).addEvent ('click', function () {
				if ($('comment_form').hasClass ('pinned'))
				{
					$(window).addEvent ('scroll', reposition_comments);
					reposition_comments ();
					$('comment_form').removeClass ('pinned');
				}
			}).setStyle ('z-index', 1);

			$$('#comment_form textarea').addEvent ('keyup', function () {
				var new_line_count = this.value.match (/\n/g);
				new_line_count = (new_line_count && new_line_count.length > 0) ? new_line_count.length : 0;
				this.rows = Math.min (Math.max (3, Math.ceil (this.value.length / 38) + new_line_count), 20);
			});
		}

		if ($('password'))
		{
			$('password').focus ();
		}
	});

	function reposition_comments ()
	{
		// Get location of top edge of description object
		var coords = $('description').getCoordinates ();

		// If we've scrolled further than the top edge of the description object...
		if (window.getScrollTop () > coords.top)
		{
			// Move the comments to the top edge of the screen, plus 15px for margin
			comments_effect.start (window.getScrollTop () - coords.top + 15);
		}

		// If we haven't scrolled past the top edge and there's still a gap, close it
		else if ($('comment_form').getStyle ('margin-top').toInt () > 0)
		{
			comments_effect.start (0);
		}
	}

	function show_prompts ()
	{
		// Get size of prompts
		var prompts_size = $('prompts').getSize ();

		// Vertically center prompts
		final_location = Math.round ((window.getHeight () / 2) - (prompts_size.size.y / 2));

		prompts_show_effect.start (final_location + window.getScrollTop ().toInt ());
	}

	function hide_prompts ()
	{
		prompts_hide_effect.start (-400);
	}