function formInputFocusAndBlur () {
	if($$('form')[0]){
		$$('form')[0].getInputs('text').each(function(input) {
			input.observe('focus', function(){
				this.setStyle({
					border: '1px solid #963e06',
					width: '216px',
					height: '21px'
				});
			});
			input.observe('blur', function(){
				this.setStyle({
					border: 'none',
					borderTop: '1px solid #4f5249',
					width: '218px',
					height: '22px'
				});
			});
		});
	}
}

var Donors = Class.create();
Donors.prototype = {
	initialize: function(donors){
		this.donors = donors;
		this.min = 0;
		this.max = donors.size()-1;
	},
	getRand: function (min, max){
		var randomNum = Math.random() * (max-min); 
		return(Math.round(randomNum) + min);
	},
	changeDonors: function(){
		this.donors.each(function(donor){
			donor.setStyle({display: 'none'});
		});
		this.donors[this.getRand(this.min,this.max)].setStyle({display: 'block'});
	}
};

function disableMoneyChecks(){
	if($('donating_user_donated_money_other')){
		$('donating_user_donated_money_other').disable();
		var moneyChecks = $('donating_user_donated_money_other').up().previous().select('[name="donating_user_donated_money"]');
		moneyChecks.each(function(chk){
			chk.observe('click', function(){
				$('donating_user_donated_money_other').value='';
				$('donating_user_donated_money_other').disable();
			});
		});
		$('donating_user_donated_money_other').observe('focus', function(){
			moneyChecks.each(function(check){
				check.checked=false;
			});
		});
		if ( $('donating_user_donated_money_7').checked ) {
			$('donating_user_donated_money_other').enable();
		}
		$('donating_user_donated_money_7').observe('click', function(){
			$('donating_user_donated_money_other').enable();
			$('donating_user_donated_money_other').focus();
		});
	}
}

function siteInit(){
    modalLinksCollect();
}

document.observe("dom:loaded", function(){
	siteInit();
	formInputFocusAndBlur();
	disableMoneyChecks();
	$('money').update($('money').innerHTML.split('').reverse().join('').replace(/([0-9]{3})/g, '$1.').split('').reverse().join('').replace(/^\./, ''));
	if ($('donationBox')) {
		var siteDonors = new Donors($('donationBox').select('h4'));
		new PeriodicalExecuter( function(){
			siteDonors.changeDonors();
		}, 5);
	}
});