function addRollovers() {
	$(".menu ul li, .button").mouseover( function() {
		$(this).addClass("selected");
	});
	$(".menu ul li, .button").mouseout( function() { 
		$(this).removeClass("selected");
	});

	$(".sidebar_photo").hover( function() {
		$height = $("div.photo_description").height()+10 + "px";
		
		$(this).children('div.photo_description').slideDown("fast");
		$(this).children('img.i').animate({
			bottom: $height
		}, "fast" );
	},
	function() {
		$(this).children('div.photo_description').slideUp("fast");
		$(this).children('img.i').animate({
			bottom: "0"
		}, "fast" );
	});

	img = new Image();
	img.src = "/media/template/menu_bg_selected.png";
}

function grid() {
	$("div.grid").toggle()
	window.resizeTo(1015,800)
}

$(document).ready(function() {
	addRollovers();
	
	// e-mail newsletter form
	$('.email_input').focus(function() {
		if($(this).is('.inactive')) {
			$(this).val('').removeClass('inactive');
		}
	});
	
});

function validateAmount(amount){
	if(amount.value.match( /^[0-9]+(\.([0-9]+))?$/)){
		return true;
	}else{
		alert('You must enter a valid donation.');
		amount.focus();
		return false;
	}
}

function check_mail(object) {
	var parent = $(object).parents('form');
	
	if($('.email_input', parent).val() == 'Your e-mail address' || $('#news_email').val() == '') {
		alert('Please enter your email address before registering');
		return false;
	}
	
	return true;
}

var api;

// video gallery
function start_video_gallery(obj) {
	var media_id = $('input[@name=media_id]', obj.parent()).val();
	var media_type = $('input[@name=media_type]', obj.parent()).val();
	
	var extension = (media_type == 'video') ? 'mov' : 'mp3';
	
	$(obj).show();
	
	api = flashembed($(obj).attr('id'),
		/* 
			first argument supplies standard Flash parameters. See full list:
			http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701
		*/
		{
			src:'/firefly/global/flowplayer/FlowPlayerDark.swf',
			width: 320, 
			height: 268
		},

		/*
			second argument is Flowplayer specific configuration. See full list:
			http://flowplayer.org/player/configuration.html
		*/
		{config: {
			loop: false,
			showMenu: false,
			initialScale: 'fit',
			showFullScreenButton: true,
			autoPlay: false,
			autoBuffering: false,
			initialVolumePercentage: 90,
			videoFile: '/medialibrary/file/' + media_id + '/video.'+extension
		}}
	);
}

function play_video_gallery(id, obj) {
	var media_id = $('input[@name=media_id]', $(obj).parents('li')).val();
	var name = $(obj).text();
	var description = $('input[@name=description]', $(obj).parents('li')).val();
	var media_type = $('input[@name=media_type]', $(obj).parents('li')).val();
	
	var extension = (media_type == 'video') ? 'mov' : 'mp3';
	
	var container = $('#' + id).parents('div.three');
	
	$('h2', container).text(name);
	$('p.description', container).text(description);
	
	$('li', $(obj).parents('ul')).removeClass('active');
	$(obj).parents('li').addClass('active');
	
	var new_video = '/medialibrary/file/' + media_id + '/video.' + extension;
	
	api.Reset();	
	api.setConfig({
		loop: false,
		showMenu: false,
		initialScale: 'fit',
		showFullScreenButton: true,
		autoPlay: false,
		autoBuffering: false,
		initialVolumePercentage: 90,
		videoFile: new_video
	});
	
}

// ========
// = sifr =
// ========

// var arno = { src: '/sifr/arno.swf' };
// var myriad = { src: '/sifr/myriad.swf' };
//sIFR.useStyleCheck = true;
//sIFR.activate(myriad);
/*
function sifr_replace_all() {
	sIFR.replace(myriad, {
		selector: '.mainbody h1',
		wmode: 'transparent',
		tuneHeight: '-2px',
		css: [
	      '.sIFR-root { color: #5c513c; }'
		]
	});
	sIFR.replace(myriad, {
		selector: '.footer h1',
		wmode: 'transparent',
		tuneHeight: '-2px',
		css: [
	      '.sIFR-root { color: #ffffff; }'
		]
	});
	sIFR.replace(arno, {
		selector: '.feature h2',
		wmode: 'transparent',
		tuneHeight: '-6px',
		css: [
	      '.sIFR-root { color: #e96d20; letter-spacing: 0.25; }'
		]
	});
	sIFR.replace(arno, {
		selector: 'h2',
		wmode: 'transparent',
		tuneHeight: '-6',
		offsetTop: '-1',
		css: [
	      '.sIFR-root { color: #e96d20; letter-spacing: 0.25; }'
		]
	});
	sIFR.replace(arno, {
		selector: 'h3',
		wmode: 'transparent',
		tuneHeight: '-6',
		offsetTop: '-1',
		css: [
	      '.sIFR-root { color: #e96d20; letter-spacing: 0.25; }'
		]
	});
	sIFR.replace(arno, {
		selector: '#home .submenu blockquote',
		wmode: 'transparent',
		tuneHeight: '-4',
		css: [
	      '.sIFR-root { color: #5c513c; leading: 16; letter-spacing: 0.5; }'
		]
	});
	sIFR.replace(arno, {
		selector: '.mainbody blockquote',
		wmode: 'transparent',
		offsetTop: '5',
		css: [
	      '.sIFR-root { color: #9e9385; leading: 12; letter-spacing: 0.5; }'
		]
	});
}

sifr_replace_all();
*/

// ============
// = end sifr =
// ============