$(document).ready(function() {
	//For OO JS Goodness
	var that = this;
	// Configuration area
	this.searchElement = 'input#q';
	this.searchValue = 'Search the site';
	this.menuElement = 'div.menu';
	this.apop = 'a.newwindow';
	// End configuration area
	
	// Search remove and reapply text
	if ($(that.searchElement)) {
		$(that.searchElement).val(that.searchValue);
		$(that.searchElement).focus(function () {
			if ($(this).val() == that.searchValue) {
				$(this).val('');
			}
		});
		$(that.searchElement).blur(function () {
			if ($(this).val() == '') {
				$(this).val(that.searchValue);
			}
		});
	}
	// Menu system
	if ($(that.menuElement)) {
		$(that.menuElement + ' ul.main').children('li').each(function () {
			$(this).children('a').each(function () {
				$(this).mouseover(function () {
					if (!$(this).parent().hasClass('active')) {
						$(that.menuElement + ' ul.main').children('li').each(function () {
							if ($(this).hasClass('active')) {
								$(this).removeClass('active');
								$('div.submenu ul.' + $(this).attr('class')).hide();
							}
						});
						$('div.submenu ul.' + $(this).parent().attr('class')).show();
						$(this).parent().addClass('active');
					}
				});
			});
		});
	}
	$(that.apop).click(function(){
		window.open(this.href);
		return false;
	});
});