$(document).ready
(
	
	function()
	{
		var formValue;
		$('.clearForm').bind('focus', function(){
			formValue = $(this).attr('value');
			$(this).attr('value', '');
		});
		$('.clearForm').bind('blur', function(){
			var currentValue = $(this).attr('value');
			if (currentValue.length == 0) {
				$(this).attr('value', formValue);
			}
		});
		$('#faders').innerfade({
			 animationtype: 'fade', 
			 speed: 2000, 
			 timeout: 5000, 
			 type: 'sequence', 
			 containerheight: '1em' 
		});
	
		$('#Area-element label[for="Area"]').before("<img src=\"/images/app/expand_button.png\" class=\"slide\" />");
		$('#education-element label[for="qualifications"]').before("<img src=\"/images/app/expand_button.png\" class=\"slide\" />");
		$('#religion-element label[for="religion"]').before("<img src=\"/images/app/expand_button.png\" class=\"slide\" />");
		$('#interests-element label[for="interests"]').before("<img src=\"/images/app/expand_button.png\" class=\"slide\" />");
		$('#special_needs-element label[for="special_needs"]').before("<img src=\"/images/app/expand_button.png\" class=\"slide\" />");
		
		$('.slide').click(function() {
			var wrapper = $('#' + $(this).parent().attr('id') + ' .multiwrapper');
			if (wrapper.is(":hidden")) 
			{
				$('.multiwrapper').each(function (){
					$(this).slideUp("slow");
					$(this).siblings(".slide").attr('src', '/images/app/expand_button.png');
					
				})
				wrapper.slideDown("slow");
				$(this).attr('src', '/images/app/retract_button.png');
			} else
			{
				wrapper.slideUp("slow");
				$(this).attr('src', '/images/app/expand_button.png');
			}
		})
		
		$('.external_link').click(function(e) {
			window.open($(this).attr("href"), '_blank');
			e.preventDefault();
		});	
		/** Lightboxy stuff **/
		$('.request_details').each(function(){
			$(this).colorbox({
				href:		$(this).attr('href') + '?ajax=true',
				iframe:		true,
				width:		'700px',
				height:		'90%'
			});
		});
		
		
	}
	
);
