
	// Detects when SlideShowPro is ready for listening. Attach events here.
	// Method receives string from SWF containing the flashvar id (which must match attribute id for the swf to be found).
	// Full list of events here: http://wiki.slideshowpro.net/SSPfl/API-Introduction
    function onSlideShowProReady(swf) {
		if (swf) {
			ssp = document.getElementById(swf);
			ssp.addEventListener("albumData","onAlbumData");
			ssp.addEventListener("galleryInfo","onGalleryInfo");
			ssp.addEventListener("imageData","onImageData");
      
		}
	}
	 			
	// Event receivers
	function onImageData(o) {    
		//if there are child nodes in the 'slideshowContent' div, loop through each one and remove it
		var outputDiv = document.getElementById("dataContent");    
		var linkDiv = document.getElementById("linkContent");    
		if( outputDiv.hasChildNodes() )
		{
			while ( outputDiv.childNodes.length >= 1 )
			{
				outputDiv.removeChild(outputDiv.firstChild);       
			} 
		}
		writeTextOutput("Photographer", o.data.title);	
		writeTextOutput("Non-profit", o.data.tags);	
		writeTextOutput("Location", o.data.caption);
		
			if( linkDiv.hasChildNodes() )
		{
			while ( linkDiv.childNodes.length >= 1 )
			{
				linkDiv.removeChild(linkDiv.firstChild);       
			} 
		}
		writeLinkOutput("", o.data.link);
	}

	
	// Write text output
	function writeTextOutput(prefix,value) {
	  
		var outputDiv = document.getElementById("dataContent");    
		var lineItem = outputDiv.appendChild(document.createElement('span'));
		lineItem.innerHTML = '<h3> ' + prefix + '</h3>' + '<p>' + value + '<\p> ';
		alert('ready')
	}
	// Write link output
	function writeLinkOutput(prefix,value) {
		var outputLink = document.getElementById("linkContent");    
		var lineItem = outputLink.appendChild(document.createElement('span'));
		lineItem.innerHTML = '<a href="' + value + '">' + prefix + '<img style="border:none;" src="http://photophilanthropy.org/blogmedia/wp-content/themes/photophil/images/view_essay.jpg" width="141" height="45" alt="VIEW ESSAY"/></a>' ;
	}

  // SWFObject embed - Note the inclusion of useExternalInterface to turn on event listening.
  var flashvars = {
    paramXMLPath: "param.xml",
    id: "ssp_g_frontpageslideshow",
    initialURL: escape(document.location),
    useExternalInterface: "true"
  }
  
  var params = { 
    bgcolor: "#121212",
    allowfullscreen: "true"
  } 
                 
  var attributes = {
    id: "ssp_g_frontpageslideshow"
  }  
  
  swfobject.embedSWF("http://photophilanthropy.org/blogmedia/wp-content/themes/photophil/SlideShowPro_Standalone_1985/Examples/assets/slideshowpro.swf", "flashcontent", "542", "441", "10.0.0", false, flashvars, params, attributes);

