﻿$(function()
{
	var item;
	var targetItem;
	var totalHeight;
	$('.companies a.company').each(function()
	{
		item		= $(this);
		targetItem	= $(item.attr('class') + ' div');
		
		totalHeight		=	targetItem.height();
		totalHeight		+=	parseInt(targetItem.css("padding-top"), 10)		+ parseInt(targetItem.css("padding-bottom"), 10);
		totalHeight		+=	parseInt(targetItem.css("margin-top"), 10)		+ parseInt(targetItem.css("margin-bottom"), 10);
		totalHeight		+=	parseInt(targetItem.css("borderTopWidth"), 10)	+ parseInt(targetItem.css("borderBottomWidth"), 10);

		var ops	= 
		{
			'padding'				: 20,
			'overlayShow'			: true,
			'overlayOpacity'		: '0.5',
			'frameWidth'			: 800,
			'frameHeight'			: 360,
			'hideOnOverlayClick'	: true,
			'hideOnContentClick'	: false
		};
		
		item.fancybox(ops);
		
		item.click(function(event)
		{
			setupPaging();
			$('div#fancy_outer, div#fancy_title').hide();
			$('div#fancy_outer').fadeIn(800);
			setTimeout("$('#fancy_title').fadeIn(1600);", 800);
			setTimeout('setupVideo();', 800);
		});
	});
	
	$('#fancy_overlay, #fancy_close').click(function(event)
	{
	});
});
	
function setupPaging()
{
	$('div#fancy_div .navButtons a.part1').click(function(event)
	{
		event.preventDefault();
		$(this).parent().find('a.part2').removeClass('selected');
		$(this).addClass('selected').parent().parent().find('div.part2').fadeOut(500, function()
		{
			$(this).parent().find('div.part1').fadeIn(800);
		});
	});
	
	$('div#fancy_div .navButtons a.part2').click(function(event)
	{
		event.preventDefault();
		$(this).parent().find('a.part1').removeClass('selected');
		$(this).addClass('selected').parent().parent().find('div.part1').fadeOut(500, function()
		{
			$(this).parent().find('div.part2').fadeIn(800);
		});
	});
}
	
function setupVideo()
{
	var vars =
	{
		file				: 'manitoba_health.flv',
		width				: '400',
		height				: '225',
		controlbar			: 'over',
		autostart			: 'false',
		repeat				: 'none',
		linktarget			: '_self',
		quality				: 'true',
		screencolor			: '000000',
		skin				: '/flash/modieus.swf',
		image				: '/images/TheWork/manitoba_health_video.png',
		bufferlength			: '15',
		javascriptid			: 'video',
		abouttext			: 'Powered by Anvil Digital',
		aboutlink			: 'http://www.anvildigital.com/'
	};

	var params =
	{
		allowscriptaccess		: 'always',
		allowfullscreen			: 'true',
		wmode				: 'transparent'
	};
			
	$('div#fancy_div div.healthVideo').flash(
	{
		swf				: '/flash/player_fullscreen.swf',
		width				: vars.width,
		height				: vars.height,
		flashvars			: vars,
		params				: params
	});
	
	vars.file	= 'price_case_study_v2.flv';
	vars.image	= '/images/TheWork/price_video.png';
	vars.height	= '293';
			
	$('div#fancy_div div.priceVideo').flash(
	{
		swf				: '/flash/player_fullscreen.swf',
		width				: vars.width,
		height				: vars.height,
		flashvars			: vars,
		params				: params
	});

	vars.file	= 'Anvil_CS_HRMAM.flv';
	vars.image	= '/images/TheWork/HRMAM_video.png';
	vars.height	= '240';
			
	$('div#fancy_div div.HRMAMVideo').flash(
	{
		swf				: '/flash/player_fullscreen.swf',
		width				: vars.width,
		height				: vars.height,
		flashvars			: vars,
		params				: params
	});
}