var c_controlAnimation = 1;
var c_controlLinearVideo = 2;

var g_ctrlLeft, g_ctrlTop, g_ctrlRight, g_ctrlBottom;
var g_mpLeft, g_mpTop;
var g_controlType;

var g_framesOfSprite;
var g_nameOfSprite;
var g_currentSprite = 1;

var g_intervalId = null;

// MAIN MENU (if appropriate) is inserted to the page.
//if(goodForMenu())
//document.write("<a href='SMBM000M.htm' target='mainFrame'><img src='../menu.gif' style='position:absolute;left:1px;top:1px;width=39px;height=39px;z-index:2;' border='0'/></a>");

function pageName()
{ 	// Will return current page name, extension stripped of.
	thePage=unescape(window.location.href);
	if(thePage.indexOf('?')!==-1)
	thePage=thePage.substring(0,thePage.indexOf('?'));
	thePage=thePage.substr(thePage.lastIndexOf('/')+1);
	thePage=thePage.substr(0,thePage.lastIndexOf('.'));
	return thePage;
}

function lastChar(aString)
{ 	// Will return the last character of the string.
	d=aString.length - 1;
	return aString.charAt(d)
}

function goodForMenu()
{ 	// Will return true, if aPage should have a main menu. The menu is inserted by this script file.
	// Pages with name ending by "M" are good for menu.
	// alert(lastChar(pageName().toUpperCase()));
	
	//return lastChar(pageName().toUpperCase()) == "M";
	if(lastChar(pageName().toUpperCase()) == "M" && pageName().toUpperCase() != "SMBM000M")
		return true;
	else
		return false;
}

function cbCopy()
{
	window.clipboardData.setData("Text", "This feature is not available in the demo version.");
	alert("The text has been copied to the clipboard.");
}

function FlashPlayer_DoFSCommand(command, args) {
	eval(command);
}

//handler called when Flash Player stops 
function onFPStop(){
	g_fp.width=1;
	g_fp.height=1;
	document.body.style.cursor = "auto";
}

function play(mediaName,w,h,l, t, r, b)
{
	g_ctrlLeft   = l - parseInt(document.FlashPlayer.style.left);
	g_ctrlTop    = t - parseInt(document.FlashPlayer.style.top);
	g_ctrlRight  = r - parseInt(document.FlashPlayer.style.left);
	g_ctrlBottom = b - parseInt(document.FlashPlayer.style.top);

	g_fp.SetVariable( "main_width", w);
	g_fp.SetVariable( "main_height", h);
	g_fp.SetVariable( "top", g_ctrlTop);
	g_fp.SetVariable( "left", g_ctrlLeft);
	g_fp.SetVariable( "bottom", g_ctrlBottom);
	g_fp.SetVariable( "right", g_ctrlRight);

	g_fp.width = w;
	g_fp.height = h;

	g_fp.SetVariable("url", mediaName);
	g_fp.SetVariable( "cmd", "play");

	document.body.style.cursor = "wait";
}

function play1(mediaName)
{
	var e = document.getElementById("vidwin");

	g_fp.SetVariable( "main_width", parseInt(e.style.width));
	g_fp.SetVariable( "main_height", parseInt(e.style.height));

	g_fp.SetVariable( "top", parseInt(e.style.top));
	g_fp.SetVariable( "left", parseInt(e.style.left));
	g_fp.SetVariable( "bottom", parseInt(e.style.bottom));
	g_fp.SetVariable( "right", parseInt(e.style.right));

	g_fp.style.top = e.style.top;
	g_fp.style.left = e.style.left;
	g_fp.width = parseInt(e.style.width);
	g_fp.height = parseInt(e.style.height);

	g_fp.SetVariable("url", mediaName);
	g_fp.SetVariable( "cmd", "play");

	document.body.style.cursor = "wait";
}

function stop()
{
	g_fp.SetVariable( "cmd", "stop");
	document.body.style.cursor = "auto";
}

function getFpId(callback)
{
	g_fp = document.FlashPlayer;
	if (g_fp.IsPlaying()){
		window.clearInterval(g_intervalId);
		callback();
	}
}

function fpInit(callback)
{
	g_intervalId = window.setInterval(function() { getFpId(callback) },100);	
}

function spriteLeft()
{
	if (g_currentSprite == 1)
	{
		g_currentSprite = g_framesOfSprite;
	}
	else
	{
		g_currentSprite--;
	}
	setCurrentSprite();
}

function spriteRight()
{
	if (g_currentSprite == g_framesOfSprite)
	{
		g_currentSprite = 1;
	}
	else
	{
		g_currentSprite++;
	}
	setCurrentSprite();
}

function setCurrentSprite()
{
	var imgname;
	var namesufix = "0000" + g_currentSprite;

	imgname = g_nameOfSprite + namesufix.substring(namesufix.length-4,namesufix.length) + ".gif";
	spriteobject.src = imgname;
}

function resizePopup(w, h)
{
	var iWidth = w - document.body.clientWidth;
	var iHeight = h - document.body.clientHeight;
	window.resizeBy(iWidth, iHeight);
}

