$(document).ready(function() {
	$('img[@rel=activity]').fadeOut('fast');
	$('input[@type=text]').each(function() {
		$(this).val($(this).attr('placeholder'));
	});
	$('input[@type=text]').focus(function() {
		if($(this).val() == $(this).attr('placeholder')) {
			$(this).val("");
		}
	});
	
	$('input[@type=text]').blur(function() {
		if($(this).val() == "") {
			$(this).val($(this).attr('placeholder'));
		}
	});
	
	$('#search_field').submit(function() {
		if($('#SearchQ').val() != "Search" && $('#SearchQ').val() != "") {
			window.location = '/search/'+$('#SearchQ').val();
		}
		return false;
	});
	
	$('#CategoryUrlSafeName').change(function() {
		window.location = '/categories/' + $(this).val();
	});
	
	$('a[@rel=inforequest]').click(function() {
		var req_link	= $(this).attr('href');
		var img			= $(this).siblings('img[@rel=activity]');
		var ire			= $(this).siblings('.inforequestadderror');
		$(img).fadeIn('slow', function() {
			$.ajax({
				url: req_link,
				type: 'GET',
				success: function(d) {
					$('#infoitems').empty().append(d);
					$(img).fadeOut('slow');
					$(ire).empty();
				},
				error: function(x,t,e) {
					$(img).fadeOut('slow');
					$(ire).empty().append('Error, try again soon!');
				}
			});
		});
		return false;
	});
	function removeinforequest(url) {
		$.ajax({
			url: url,
			type: 'GET',
			success: function(d) {
				$('#requestcontent').empty().append(d);
				$('a[@rel=removeinforequest]').click(function() {
					removeinforequest($(this).attr('href'));
					return false;
				})
			},
			error: function(x,t,e) {
				alert("There was an error trying to remove the item from your info request.  Please try again in a few moments.");
			}
		});
	}
	$('a[@rel=removeinforequest]').click(function() {
		removeinforequest($(this).attr('href'));
		return false;
	});
	$('#scroller').jdNewsScroll({delay: 0, step: 1});
});
