/*
 * GIGYA SHARE INTEGRATION
 *
 */
var conf = {
	// APIKey: '2_ObDFScz46Al_VL9lT7yKmCmvwplVOcML69tzh7qs7c2Pq98NS11lDfB5Tm_ASGgS' // turner.com
	APIKey: '2_wQ_qNHMqlSAtj4gTLJnfr3rN5dL5o3OvMu9KI2tkYi8nx-R6JE9LbkevojJ67HqO' // smokinggun.com
};

function onLoad(){
// get user info
gigya.services.socialize.getUserInfo(conf,{callback:renderUI});	    
// register for connect status changes
gigya.services.socialize.addEventHandlers(conf, { onConnect:renderUI, onDisconnect:renderUI}   ); 
}

// Create and Publish User's Action
// This method is associated with the "btnPublishAction" click
function showShareUI(nodetitle, subtitle, sharepath, sharephoto) {

// Constructing a UserAction Object
var act = new gigya.services.socialize.UserAction();

// Setting the default user message 
// (will be presented as default text in the edit box on the Share UI)
act.setUserMessage("Your comment here...");

// Setting the title and description 
// (will be presented in the preview on the Share UI)
act.setTitle("The Smoking Gun: "+nodetitle);
act.setDescription(subtitle);

// Setting a link back to the publishing source
act.setLinkBack(sharepath);

// Adding Action Link
act.addActionLink("Take a Look", sharepath);

// Adding an image (will be presented in the preview on the Share UI)
var image = {
src: "http://smokinggun.funnygarbage.com/sites/default/themes/bulletproof/images/logos/tsg_share.png",
href: sharepath,
type: 'image'
}
act.addMediaItem(image);

// Parameters for the showShareUI method, including the UserAction object
var params = 
{
userAction: act  // The UserAction object enfolding the newsfeed data.			                                  
,onError: onError  // onError method will be summoned if an error occurs. 
,onSendDone: onSendDone // onError method will be summoned after 
        // Gigya finishes the publishing process.
,useFBDialog: true
,defaultProviders: "facebook,twitter"
,enabledProviders: "facebook,twitter,google,yahoo,myspace"
,showMoreButton: true // Enable the "More" button and screen
,showEmailButton: true // Enable the "Email" button and screen
};

// Show the "Share" dialog
gigya.services.socialize.showShareUI(conf, params);

}

// onError event handler
function onError(event) {
alert('An error has occured' + ': ' + event.errorCode + '; ' + event.errorMessage);
}

// onSendDone event handler. 
// Displays in the status field, the list of providers to which the newsfeed has been 
// successfully published.
function onSendDone(event)
{
document.getElementById('status').style.color = 'green';
document.getElementById('status').innerHTML = 
         'The newsfeed has been posted to: ' 
+ event.providers;
}



