




















var _tmp = new Image(); _tmp.src = 'images/movie-close-button.png';

function hideMoviePlayer() {
	try { $('objMoviePlayer').dispose(); } catch(e) {};
	try { $('divMoviePlayer').dispose(); } catch(e) {};

	hideOverlay();
}

function launchMoviePlayer(moviehref, width, height) {
	if($('divMoviePlayer')) $('divMoviePlayer').dispose();

	if(!width) width = 800;
	if(!height) height = (width / 1.69).toInt();


	var mvname = moviehref.match(/\/([^\/\.]+)\.[^\.]+$/)[1];
	var mvinfo = {
		'Tapped-Trailer': {
			title:		'Tapped Trailer',
			description:	'Is access to clean drinking water a basic human right, or a commodity that should be bought and sold like any other article of commerce? Stephanie Soechtig\'s debut feature is an unflinching examination of the big business of bottled water.\n\nFrom the producers of Who Killed the Electric Car and I.O.U.S.A., this timely documentary is a behind-the-scenes look into the unregulated and unseen world of an industry that aims to privatize and sell back the one resource that ought never to become a commodity: our water.\n\nFrom the plastic production to the ocean in which so many of these bottles end up, this inspiring documentary trails the path of the bottled water industry and the communities which were the unwitting chips on the table. A powerful portrait of the lives affected by the bottled water industry, this revelatory film features those caught at the intersection of big business and the public\'s right to water.'


		},
		'World-Water-Crisis': {
			title:		'World Water Crisis',
			description:	''
		},
		'Central-Valley': {
			title:		'Central Valley',
			description:	''
		},
		'Plastic-Soup': {
			title:		'Plastic Soup',
			description:	''
		},
		'Oil-in-Water': {
			title:		'Oil in Water',
			description:	''
		},
		'Infrastructure': {
			title:		'Infrastructure',
			description:	''
		},
		'Privatization': {
			title:		'Privatization',
			description:	''
		},
		'Chemicals-in-the-Water': {
			title:		'Chemicals in the Water',
			description:	''
		}

	}
	var title = '';
	var description = '';
	var author = ' Tapped: World Water Week (tappedthefilm.com)';

	if(mvinfo[mvname]) {
		title = ' ' + mvinfo[mvname].title;
		description = ' ' + mvinfo[mvname].description;
	}


	var div;
	with(div = new Element('div')) {
		id = 'divMoviePlayer';
		setStyles({
			'position':	'absolute',
			'opacity':	0,
			'z-index':	98,
			'background':	'#000',
			'border':	'none',
			'width':	width,
			'height':	height,
			'top':		0,
			'left':		0
		});
	}
	div.inject($(document.body));

	var divInner;
	with(divInner = new Element('div')) {
		id = 'divMoviePlayerGuts';
	}
	divInner.inject(div);

	var closeImage = new Element('img');
	closeImage.src = 'images/movie-close-button.png';
	closeImage.setStyle('position', 'absolute');
	closeImage.setStyle('cursor', 'pointer');
	closeImage.setStyle('opacity', 0);
	closeImage.addEvent('click', hideMoviePlayer);
	closeImage.inject(div);

	div.setStyles({
		left: ( $(document.body).getWidth() / 2 ) - (width / 2) + $(document.body).getScroll().x,
		top: ( $(document.body).getHeight() / 2 ) - (height / 2) + $(document.body).getScroll().y
	});

	var movieopts = {
		file:			moviehref,
		screencolor:		'#000000',
		autostart:		true,
		bufferlength:		1,
		image:			moviehref.replace(/Film-Clips/, 'Film-Clips/images').replace(/\.[^\.]+$/, '.jpg'),
		dock:			true,
		plugins:		'fbit-1,tweetit-1,viral',
		//backcolor:		'#1762AF',
		//frontcolor:		'#ffffff',
		lightcolor:		'#F38820',
		title:			title,
		description:		description,
		author:			author,
		date:			'March 17, 2010',
		'logo.file':		'/images/tapped-watermark-logo.png',
		'logo.position':	'bottom-left',
		'logo.link':		'http://www.tappedthefilm.com',

		'viral.onpause':	false,
		'viral.oncomplete':	true,
		'viral.allowmenu':	true,
		'viral.email_subject':	title + ' Video - Tapped: World Water Week',
		'viral.email_footer':	'------------------------\nTapped: World Water Week\nhttp://www.tappedthefilm.com',
		'viral.recommendations': '',
		'viral.functions':	'share,embed', // share,embed,info,recommendations
		//'viral.fgcolor':	'0x0096DA',
		//'viral.bgcolor':	'0x0096DA',
		foo: 'bar'
	};
	

	showOverlay();
	new Fx.Tween(div, {
		duration: 300,
		onComplete: function() {
			swfobject.embedSWF('swf/player.swf', 'divMoviePlayerGuts', width, height, '8', '', movieopts, { quality: 'high', 'bgcolor': '#000000', allowfullscreen: true, allowscriptaccess: 'always', allownetworking: 'all' }, { id: 'objMoviePlayer', 'bgcolor':'#000000' } );

			closeImage.setStyle('top', closeImage.getHeight() * -1);
			closeImage.setStyle('left', div.getWidth() - closeImage.getWidth())
			new Fx.Tween(closeImage, { duration:500 }).start('opacity', 1);
		}
	}).start('opacity', 1);



	return false;
}


function _preloadImages(imglist) {
	for(var i=0; i<imglist.length; ++i) _preloadImage(imglist[i]);
}

function _preloadImage(src) {
	if(!window.__preloadImagesList) window.__preloadImagesList = [];
	var i = window.__preloadImagesList.length;
	window.__preloadImagesList[i] = new Image();
	window.__preloadImagesList[i].src = src;
}



function menu_over(that) {
	var newsrc = that.src.replace(/-?(\.[^\.]+)$/, '-$1');
	$(that).store('oldsrc', that.src);
	that.src = newsrc;
}

function menu_out(that) {
	that.src = $(that).retrieve('oldsrc');
}












function showOverlay() {
	var div = $('divOverlay');
	if(!div) {
		with( div = $(document.createElement('div')) ) {
			id = 'divOverlay';
			setStyle('position', 'absolute');
			setStyle('display', 'none');
			setStyle('z-index', 90);
			setStyle('background', '#000000');
			setStyle('top', 0);
			setStyle('left', 0);
			setStyle('opacity', 0);
		}
		document.body.appendChild(div);

		window.addEvent('resize', function() {
			resizeOverlay();
		});
	}

	if(div.getStyle('display') == 'block') return;

	div.setStyle('opacity', 0);
	div.setStyle('display', 'block');

	resizeOverlay();


	new Fx.Tween(div, {
		duration: 500
	}).start('opacity', 0.7);
}

function resizeOverlay() {
	var div = $('divOverlay');
	if(!div || div.getStyle('display') != 'block') return;

	div.setStyle('width', $(document.body).getScrollWidth());
	div.setStyle('height', $(document.body).getScrollHeight());
}

function hideOverlay() {
	var div = $('divOverlay');
	if(!div || div.getStyle('display') == 'none' ) return;

	new Fx.Tween(div, {
		duration: 500,
		onComplete: function() {
			div.setStyle('display', 'none');
		}
	}).start('opacity', 0);

}




function test(v) {
	try { console.log(v); } catch(e) {};
}




function charityShowMore() {
	var lnk = $('spnCharityMoreLink');
	var txt = $('spnCharityMoreText');

	if(!lnk || !txt) return;

	if(txt.getStyle('display') == 'none') {
		lnk.setStyle('display', 'none');

		txt.setStyles({
			'height': 1,
			'overflow': 'hidden',
			'display': 'block'
		});

		new Fx.Tween(txt, {
			duration: 250
		}).start('height', txt.getScrollHeight());




	}

}










