
$(function() {

	// Login form close button
	$('#login_form input[type=image]').after(' <a id="cancel" href="#"><img src="'+app_url+'/img/cancel.gif" width="60" height="25" alt="CANCEL" /></a>');

	// Login form close button event
	$('#cancel').click(function() {
		$('#login_form').hide();
		return false;
	});

	// Login form show event
	$('#head_login_a').click(function() {
		$('#login_form').fadeIn('slow');
		$('#login_form .username').focus();
		return false;
	});

	function filterPath(string) {
		return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'');
	}
	var locationPath = filterPath(location.pathname);
	$('a[href*=#]').each(function() {
		var thisPath = filterPath(this.pathname) || locationPath;
		if (  locationPath == thisPath
		&& (location.hostname == this.hostname || !this.hostname)
		&& this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html, body').animate({scrollTop: targetOffset}, 400, function() {
						location.hash = target;
					});
				});
			}
		}
	});

	// PNG transparency
	$('#header').supersleight({
		shim: app_url+'/img/x.gif',
		backgrounds: false
	});
});
$(window).load(function () {
	if (!secure_page) {
		$('#accreditation').append('<iframe src="http://www.trustlink.org/CompanyWidget.aspx?ID=4V htVkbzD4NO6Kb83cNgA==" width="140" height="70" scrolling="no" frameborder="0"></iframe>');
	}
});