(function () {
	var resetInput = function () {
		var element = (typeof $(this).hasClassName === 'function') ? $(this) : $(arguments[0]);
		if (!element.hasClassName('prefilled') && element.getValue() === element.defaultValue) {
			element.setValue('');
		}
		return element;
	};
	var clearForms = function () {
		var form_elements = $$('input[type=text]', 'textarea');
		form_elements.invoke('observe', 'focus', resetInput);
		form_elements.invoke('observe', 'blur', function () {
			if ($F(this).blank()) {
				this.setValue(this.defaultValue);
			}
		});
		$$('form').invoke('observe', 'submit', function () {
			this.select('input[type=text]', 'textarea').map(resetInput);
		});
	};

	document.observe('dom:loaded', clearForms);
})();

document.observe('dom:loaded', function () {
	try {
		var location_sub = /([^\/]+?)\/([^\/]+?)\.asp$/;
		var folder_name, file_name, window_location;
		window.location.href.gsub(location_sub, function (match) {
			window_location = match[0];
			folder_name = match[1];
			file_name = match[2];
		});


		$$('.vx_menu a').each(function (element) {
			$(element).readAttribute('href').gsub(location_sub, function (match) {
				if (match[2] !== 'home') {
					if (match[0] === window_location) {
						element.addClassName('selected');
					}

					if (match[2] === folder_name) {
						element.addClassName('selected');
					}
				}
			});
		});
	} catch (err) {}
	
	$$('.highlight_box.half_block + .highlight_box.half_block').each(function (box) {
		var original_box = box.previous('.highlight_box.half_block');
		if (box.positionedOffset().top === original_box.positionedOffset().top) {
			var height = $(box, original_box).inject(0, function (h, el) {
				return (h > el.clientHeight) ? h : el.clientHeight;
			});
			
			$(box, original_box).invoke('setStyle', 'height:'+height+'px');
		}
	});
});