var hdcolourise = {
		
	setcolour: function(colourhex) {
		$('#content h1, #content h2, #content h3, #content h4, #content h4 a').css({color:'#'+colourhex});
		$('div.pagetitle p').css({backgroundColor:'#'+colourhex});
	}
		
};

$(function() {

	$('form#fileupload input').live('change', function() {
		$(this).hide();
		$('#fileprocessing').show();
		$('form#fileupload').submit();
	});
	
	$("#control").bind('dblclick', function() {
		$("#control").fadeOut();
		return false;
	});
	
	$('.clickable').click(function() {
		if ($('a', this).attr('target')) {
			window.open($('a', this).attr('href'), $('a', this).attr('target'));
		} else {
			location.href = $('a', this).attr('href');
		}
		return false;
	}).css('cursor', 'pointer');
	
	$( ".tabset" ).tabs();	
	
	$('form.searchfilter fieldset.sortby div.button.sortby input').live('change', function() {
		$('form.searchfilter fieldset.sortby div.button.sortby').removeClass('selected');
		if ($(this).has(':selected')) {
			$(this).parent().addClass('selected')
		}
	});
	
	$('img.polaroid').each(function() {
		var image = $(this).clone();
		image.addClass('subject');
		var polaroid = $('<div class="polaroid" />');
		polaroid.append('<img src="/template/theme/bettert/image/polaroid.png" class="frame" />');
		polaroid.append(image);
		$(this).replaceWith(polaroid);		
	});	
	
	$.ajaxSetup({
		type: 'POST',
		cache: false
	});
	
	$("body").ajaxStart(function () {
		$('body').addClass('loading');
	});
	
	$("body").ajaxStop(function () {
		$('body').removeClass('loading');
		$('.ajaxtrigger').removeClass('ajaxtrigger');
	});
	
});
