$(document).ready(function(){    
	$('#video-selectors').enable_video_switcher();
	$('body.page-template-page_donate-php').donation_form();
});

$.fn.donation_form = function(){
	return this.each(function(){
		var our_form = this;

		if ($("input#other-amount-radio", this).attr('checked') != true) $('#other-amount', this).hide();
		
		if ($("input[name='honor-gift']", this).attr('checked') == false) $('.honoree-row', this).hide();
		
		$("input[name='donation-level']", this).change(function(){
			if ($(this).val() == '1673') $('#other-amount').fadeIn('fast').attr('disabled', '').focus();
			else $('#other-amount').val('').fadeOut('fast').attr('disabled', 'disabled');
		});
		
		$("input[name='honor-gift']", this).change(function(){
			if ($(this).attr('checked')) $('.honoree-row').fadeIn('fast');
			else  $('.honoree-row').fadeOut('fast');
		});

	});
};

$.fn.enable_video_switcher = function()
{	
	return this.each(function(index){
		var ele = this;
		var i = 1;
		
		$('li.vimeo-video', ele).each(function(){
			this.video_number = i;
			i++;
		});
		
		ele.video_count = $('li.vimeo-video', ele).length;
		
		ele.switch_to_video = function(video_number)
		{
			$('li.on').removeClass('on');
			ele.currentVideo = $('li:nth-child('+video_number+')', ele).get(0);
			$(ele.currentVideo).addClass('on');
			ele.set_text_for_video($('h5 a', ele.currentVideo).html(), $('p', ele.currentVideo).html());
		}
		
		ele.set_text_for_video = function(title, description)
		{
			swfobject.embedSWF("/dreambig/wp-content/themes/dreambigcom/assets/swf/Video_text.swf", "lighttheway", "275", "231", "9.0.0", "expressInstall.swf", {header:title, body:description}, {"wmode":"transparent"}, {});
		}
		
		ele.switch_to_video(1);	
		
		$('li.vimeo-video', ele).each(function(){
			var ele_video = this.video_number;
			$('a', this).click(function(){
				ele.switch_to_video(ele_video);
				return false;
			});
		});
		
		$('li.disabled a', ele).click(function(){
			return false;
		});
	});
};   
