// jQuery is loaded right before this file in templates/layout/header.php

// NOTE: This file ends with disabling jQuery's '$' alias, so in any
// callbacks you must use jQuery and not '$'.

jQuery(document).ready (function($)
{
	var $ = jQuery; // looks like '$'-argument don't work in IE8

	if ($.browser.msie) {
		var ie_ver = $.browser.version.slice (0,1);
		// @todo use jquery to insert div dynamically instead
		if (ie_ver==6) {
			var e = $('#messages');
			if (e) {
				e.css ({
					margin:		'20px',
					padding:	'5px',
					border:		'1px dashed black',
					backgroundColor: '#eee'
				});
				e.html('Please note: You have an antique version of Internet Explorer and this site is optimized for modern browsers. <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home">You can click here to download the latest version from Microsoft</a>.');
			}
		}
	}


	/* Set rounded corners */
	if (!$.browser.msie) { // @note: IE9 supports it
		$('#topbox div.login').corner('5px bottom');
		$('#searchbox').corner('5px');
		$('#newsbox').corner('5px');
		$('#newsinput').corner('3px');
	}


	/* Catalogue side menu */
	// hide via css instead?
	var menu = $('#cat_side_menu ul');
	menu.hide();
	var e = $('#cat_side_menu li.selected');
	e.next().show();


	/* News archive menu */
	// we do all the selection stuff here, since the html is cached
	var menu = $('#newsmenu ul');
	menu.hide();
	var m = document.location.href.match (/year=(\d{4})/);
	if (m) {
//		var x = $('#newsmenu > li a:contains('+year+')');
		var e = $('#newsmenu a[innerHTML='+m[1]+']');
		e.css ('background-color', '#eaeaea'); // @should set class=selected and style via css
		e.next().show();
	}

});


$.noConflict();

