// Author: Anthony Tripaldi

function fbconnectlogin()
{
	FB.Bootstrap.requireFeatures(["Connect"], function() {
		FB.Connect.requireSession(function(exception) {
			var sessionData = FB.Facebook.apiClient.get_session();
			var flashVars = {
				as_swf_name: "flashcontent",
				session_key: sessionData.session_key,
				secret:sessionData.secret,
				uid:sessionData.uid,
				api_key:api_key
			};	
			
			flashcontent.onSession(flashVars);
		});
	});
};

function post(name, url, img)
{
	FB.ensureInit(function ()
	{
		var attachment = { 'name': name + ' - custom cocktail by Hendrick\'s Gin', 'href': url, 'description':'Check out HendricksGin.com for more recipes like this one!', 'media': [{'type': 'image', 'src': 'http://photos-f.ak.fbcdn.net/photos-ak-sf2p/v27562/157/105228779513413/app_1_105228779513413_8661.gif', 'href': url }] };
		var actionLinks = [{'text': 'Get the recipe!', 'href': url}];
		
		FB.Connect.streamPublish('Who’s for a cocktail? I’m using Hendrick’s Gin to mix up a ' + name, attachment );
	});
}


function logout(){
	FB.Connect.logout();
}

function setCookies( country, bday )
{
/*
	setCookie( "country", country, 12, "/" );
	setCookie( "day", bday.d, 12, "/" );
	setCookie( "month", bday.m, 12, "/" );
	setCookie( "year", bday.y, 12, "/" );
*/
}

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:100%; min-width:1024px; min-height:768px;");
	window.onresize = function() {
		var el = document.getElementById("container");
		var size = getViewportSize();		
		el.style.width = size[0] < 1024 ? "1024px" : "100%";
		el.style.height = size[1] < 768 ? "768px" : "100%";
	};
	window.onresize();
}	

