$(function() {

	$('#section_nav li a').autoscroll();

	$('.slide_panel').css({
		'display': 'none'
	});

	$('#branding').cycle();

	$('.lightbox').lightbox();

	$('#sliding_panels h3 a').bind('click', function(event) {
   		$(this).parent('h3').next('div').slideToggle();
		event.preventDefault();
	});

	$('form#enquiry, form#brochure_request, form#quote_request').submit(function() {
		return CheckForm($(this).attr('id'));
	});

	$('#other-find-us').hide();
	$('#find-us').change(function() {
		if ($(this).val() === 'Other') {
			$('#other-find-us').show();
		} else {
			$('#other-find-us').hide();
		}
	});

	var captcha = $('#captchacode');

	$('#refresh').click(function(event) {
		captcha.attr('src', '/lib/captcha/generate.php');
		event.preventDefault();
	});

	$('body').delegate('a:external, a[href$=".pdf"]', 'click', function(event) {
		window.open(this.href);
		event.preventDefault();
	});

});

function open_in_popup_window(url, name, width, height) {
	window.open(url.href, name, 'width=' + width + ', height=' + height + ', toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes');
	return false;
}

function open_in_new_window(url) {
	window.open(url.href, 'external_link', 'toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes');
	return false;
}
