$(document).ready(function() {
	
	$('#SearchKeyword').focusin(function() {
		if ($(this).val() == 'Search...') $(this).val('');
	});
	$('#SearchKeyword').focusout(function() {
		if ($(this).val() == '') $(this).val('Search...');
	});
	
	$('#SubscriberEmail').focusin(function() {
		if ($(this).val() == 'Enter your email address...') $(this).val('');
	});
	$('#SubscriberEmail').focusout(function() {
		if ($(this).val() == '') $(this).val('Enter your email address...');
	});
	
	$('.radio').click(function() {
		$('#getamount').val('');
		$('.activeradio').removeClass('activeradio').attr('checked',false);
		$(this).addClass('activeradio');
		var amount = $(this).next().next().html();
		$('.donamount').val(amount);
	});
	$('#getamount').focusin(function() {
		$('.activeradio').attr('checked',false);
	}).keypress(function(e) {
		var key = e.charCode ? e.charCode : e.keyCode;
		if (!(key>=48 && key<=57 || key==8 || key==9)) {
			e.preventDefault();
		}
	}).focusout(function() {
		var amount = parseFloat($(this).val());
		if (isNaN(amount) || amount<=0) $(this).val('');
		else $(this).val(amount.toFixed(0));
		if ($(this).val() == '') {
			if ($('.activeradio').length==1) $('.activeradio').attr('checked',true);	
			$('.donamount').val($('.activeradio').next().next().html());
		}
		else $('.donamount').val($(this).val()+'.00');
	});
	
	$('.donatebtn').click(function() {
		$('.donatebtn').each(function() {
			$(this).attr('src',$(this).attr('src').replace('active','passive'));
		});
		$(this).attr('src',$(this).attr('src').replace('passive','active'));
		$('input[name="cmd"]').val($(this).attr('alt'));
	});
	
	$('.news>div.news-image').each(function() {
		if ($('img',this).hasClass('hidden-icon')) {
			$(this).hide();
			$(this).next().css('width','280px');
		}
	});
	$('.full>div.news-image').each(function() {
		if ($('img',this).hasClass('hidden-icon')) {
			$(this).hide();
			$(this).next().css('width','620px');
		}
	});
	$('.shop>div.shop-image').each(function() {
		if ($('img',this).hasClass('hidden-icon')) {
			$(this).hide();
			$(this).next().css('width','450px');
		}
	});
	$('div.disorder-image').each(function() {
		if ($('img',this).hasClass('hidden-icon')) {
			$(this).hide();
			$(this).next().css('width','600px');
		}
	});
	
});
