
//setup GIGYA
						
 var conf =
{
	APIKey: '2_bWNup49k57Y9OXer8sa9aYsZfkBL2nd7wQFlnVaEFPlpxtWz36vxHlKN6EX2D1LF', 
	enabledProviders: 'facebook,twitter,google,yahoo,linkedin,myspace'
};

// Create and Publish User's Action
// This method is associated with the "btnPublishAction" click

/**

*@param (String) VidID //youtube video id 

**/
function checkQMark(arg){
if (arg.indexOf("?") != -1) {
	return arg;
		}else{
	return arg+"?";
	}
}

function showShareUI(vidID, vidTitle, vidDescript, vidUserMsg, vidThumbURL, returnURL) {
	// get current url and strip the query string
	gPage = window.location.href;
	returnURL = gPage.substring(0,gPage.indexOf("?"));
	
	
	// Constructing a UserAction Object 
	var act = new gigya.services.socialize.UserAction();
	
	//assign additional params for email
	var params = { 
    	userAction: act,
    	showEmailButton: "true",
		emailBody: "<a href='"+checkQMark(gPage)+"source=share_email'><img src='http://www.ericksonliving.com/lp/reallyliving/images/"+vidID+"-email.jpg'></a><br/><h2>"+vidUserMsg+"</h2><br />"+vidDescript+" <a href='"+checkQMark(gPage)+"source=share_email'>Watch The Video</a>",
		successMessage: "true",
		userAction:act,
		cid: "Really Living",
	};
	// Setting the User Message
	act.setUserMessage(vidUserMsg);

	// Setting the Title
	act.setTitle(vidTitle);

	// Setting the Link Back
	act.setLinkBack(gPage);

	// Setting the Description
	act.setDescription(vidDescript);

	// Build a Media Item (video)
	var video = {
		src: 'http://www.youtube.com/v/'+vidID+'&hl=en&fs=1',
		previewImageURL: vidThumbURL,
		type: 'flash'
	}
	
	//add the media to the userAction Object
	act.addMediaItem(video);

	// Adding an Action Link
	act.addActionLink("View Other Stories", "www.ericksonliving.com");

	// Setting the Action Template string
	act.setTemplate('{actor} {action} this video!');

	// Setting the {action} in the Action Template String
	act.setActionName('likes');

	// Publishing the User Action
	gigya.services.socialize.showShareUI(conf, params);
	
	// onError event handler
	function onError(event) {
		alert('An error has occured' + ': ' + event.status + '; ' + event.statusMessage);
	}

	// onSendDone event handler. 
	// Displays in the status field, the list of providers to which the newsfeed has been 
	// successfully published.
	function onSendDone(event)
	{
		alert ('This has been posted to: '+ event.providers);
	}
	
//End Gigya Setup
}


