﻿//
// Methods and events used by Lenovo AMP
//

function onFlashEvent()
{
	var sEvent = arguments[ 0 ];
	
//alert( "onFlashEvent:" + sEvent );
	switch ( sEvent )
	{
		case "browseAll" :
			popUpUrl( arguments[ 1 ], "width=930,height=620,scrollbars=no,toolbar=0,resizable=0,status=1" );
		break;
		
		case "shareThis" :
//			addThis( "http://www.acgmultimedia.com", "My Title" );
			shareThis( arguments[ 1 ], arguments[ 2 ] );
		break;
		
		case "onstandardmode" :
		case "onstandardmode_film" :
		case "onminimode" :
		case "onminimode_film" :
		
			var oContainer = document.getElementById( "flashcontainer" );
			if ( oContainer != null )
			{
				var sClip = "";
				switch ( sEvent )
				{
					case "onstandardmode" :
						sClip = "rect(0px, 632px, 451px, 0px )";
					break;
					case "onstandardmode_film" :
						sClip = "rect(0px, 632px, 538px, 0px )";
					break;
					case "onminimode" :
						sClip = "rect(0px, 632px, 306px, 257px )";
					break;
					case "onminimode_film" :
						sClip = "rect(0px, 632px, 392px, 257px )";
					break;
				}
				oContainer.style.clip = sClip;
			}
			
		break;
		
		default :
//alert( "Unknown event:" + sEvent );		
		break;
	}
}

function popUpUrl( sUrl, sOptions )
{
	window.open( sUrl, "amppopup", sOptions );
}

var addthis_url = "";
var addthis_title = "";
var addthis_pub = 'jbruce';
function addThis( sUrl, sTitle )
{
	addthis_url = sUrl;
	addthis_title = sTitle;
	addthis_click();
}

/*
var oShareThis = SHARETHIS.addEntry({
title:'Share me',
summary:'Sharing is good for the soul.',
icon: 'http://path.to/icon'
}, {button:false, popup:true} );
*/
var oShareThis = SHARETHIS.addEntry({}, {button:false, popup:true});

function shareThis( sUrl, sTitle )
{
//alert( "shareThis:" + sUrl );
/*	
	oShareThis.properties[ "url" ] = encode_utf8( sUrl );
	oShareThis.properties[ "title" ] = encode_utf8( sTitle );
*/
	oShareThis.properties[ "url" ] = sUrl;
	oShareThis.properties[ "title" ] = sTitle;
	oShareThis.properties[ "icon" ] = "";
	oShareThis.properties[ "summary" ] = "";
	oShareThis.properties[ "content" ] = ""; // must be embeddable
	oShareThis.properties[ "updated" ] = "";
	oShareThis.properties[ "published" ] = "";
	oShareThis.properties[ "author" ] = "";
	oShareThis.properties[ "category" ] = "";
	oShareThis.popup();
}

function encode_utf8( s )
{
	return unescape( encodeURIComponent( s ) );
}
function decode_utf8( s )
{
	return decodeURIComponent( escape( s ) );
}

