// Author: Anthony Tripaldi
function share()
{
	FB.ui(
	{
		method: 'stream.publish',
		message: 'Check out the new Neutrogena Wave!',
		attachment: {
		name: 'Neutrogena Wave',
		caption: 'Introducing the Wave Sonic',
		description: (
		'You will be 50x happier after discovering the Neutrogena Wave Sonic. Find out why!'
		),
		href: 'http://www.neutrogenawave.com'
		},
		action_links: [
		{ text: 'Check it out!', href: 'http://www.neutrogenawave.com' }
		],
		user_message_prompt: 'Share your thoughts about the Neutrogena Wave Sonic'
		},
		function(response)
		{
			if (response && response.post_id) {				
				_gaq.push(['_trackPageview', '/fbshare/publish']); //pageTracker._trackPageview("/fbshare/publish");
				//alert('Post was published.');
			} else {
				_gaq.push(['_trackPageview','/fbshare/cancel']);//pageTracker._trackPageview("/fbshare/cancel");
				//alert('Post was not published.');
		}
	});	
}

function shareGame( type, img )
{
	//alert( 'shareGame ' + type + ' ' + img );
	
	FB.ui(
	{
		method: 'stream.publish',
		message: type,
		attachment:{
			name: 'Neutrogena Wave',
			caption: 'Are you a spinner or a shaker?',
			description: (
			'Play this Neutrogena challenge to find out how you ride the WAVE. No wetsuit necessary, but you may want to do a few loose wrist turns before you start.'
			),
			href: 'http://www.neutrogenawave.com'
			},
			media: [{ 
				type: 'image', 
				src: img, 
				href: 'http://bit.ly/187gO1'}],
			action_links: [
			{ text: 'Play the game!', href: 'http://www.neutrogenawave.com' }
			],
			user_message_prompt: 'Now that you found your WAVE, share it with the world.'
		},
		function(response)
		{
			if (response && response.post_id) {
				//alert('Post was published.');
			} else {
				//alert('Post was not published.');
		}
	});		
	
}

function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function getViewportSize()
{ 
	var size = [0, 0]; 
	if (typeof window.innerWidth != "undefined") { 
		size = [window.innerWidth, window.innerHeight];
	} 
	else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
		size = [document.documentElement.clientWidth, document.documentElement.clientHeight]; 
	}
	else {
		size = [document.getElementsByTagName("body")[0].clientWidth, document.getElementsByTagName("body")[0].clientHeight]; 
	}
	return size; 
}

function createFullBrowserFlash() 
{
	swfobject.createCSS("html", "height:100%;");
	swfobject.createCSS("body", "height:100%;");
	swfobject.createCSS("#container", "margin:0; width:100%; height:95%; min-width:800px; min-height:550px;");
	window.onresize = function() {
		var el = document.getElementById("container");
		var size = getViewportSize(); 
		el.style.width = size[0] < 800 ? "800px" : "100%";
		el.style.height = size[1] < 550 ? "550px" : "95%";
	};
	window.onresize();
}	