/* *********************************************************************

Source Code Copyright © 2007 Congruent Media, LLC.  All rights reserved.
 
This source code is the intellectual property of Congruent Media, LLC., 
except where otherwise noted, and may not be copied in whole or in part, 
except for backup purposes. You may not resell or otherwise distribute 
this source code, or any code derived from this source code, without 
express written permission from Congruent Media, LLC.
 
This source code is sold "as is" and WITHOUT ANY WARRANTY; without even 
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
http://www.CongruentMedia.com | info@CongruentMedia.com | +1 410-534-6800

************************************************************************* */

// Dependencies:
//   activeXFlashFix.js

function FlashImageRotator(playerPath, width, height, categoryId, gatewayURL, flashServiceClassPath)
{
	this._playerPath = playerPath;
	this._width = width;
	this._height = height;
	this._categoryId = categoryId;
	this._gatewayURL = gatewayURL;
	//this._gatewayURL = window.location.protocol + '//' + window.location.host + '/flashservices/gateway';
	this._flashServiceClassPath = flashServiceClassPath;
	
	this._flashContainer = null;
	this._flashObject = null;
};

FlashImageRotator.prototype.render = function()
{
	var fObjContainerId = 'FIR_container_' + this._categoryId;
	var fObjId = 'FIR_' + this._categoryId;
	var fObjSId = 'FIRobj_' + this._categoryId;
	
	document.write('<div id="' + fObjContainerId + '"><' + '/div>');
	document.write('<script type="text/javascript">var ' + fObjSId + ' = new Flash("' + this._playerPath + '", "high", "' + this._width + '", "' + this._height + '", "8");');
	document.write(fObjSId + '.setId("' + fObjId + '");');
	document.write(fObjSId + '.setParam("FlashVars", "CategoryId=' + this._categoryId + '&GatewayURL=' + this._gatewayURL + '&FlashServiceClassPath=' + this._flashServiceClassPath + '");');
	document.write(fObjSId + '.setParam("wmode", "transparent");');
	document.write(fObjSId + '.render("' + fObjContainerId + '");</' + 'script>');
	
	this._flashContainer = document.getElementById(fObjContainerId);
	this._flashObject = document.getElementById(fObjId);
}

FlashImageRotator.prototype.start = function()
{
	this._flashObject.FIR_start();
}

FlashImageRotator.prototype.pause = function()
{
	this._flashObject.FIR_pause();
}

FlashImageRotator.prototype.resume = function()
{
	this._flashObject.FIR_resume();
}

FlashImageRotator.prototype.stop = function()
{
	this._flashObject.FIR_stop();
}

FlashImageRotator.prototype.playNext = function()
{
	this._flashObject.FIR_playNext();
}

FlashImageRotator.prototype.playPrevious = function()
{
	this._flashObject.FIR_playPrevious();
}

FlashImageRotator.prototype.getImageCount = function()
{
	return this._flashObject.FIR_getImageCount();
}

FlashImageRotator.prototype.getCurrentIndex = function()
{
	return this._flashObject.FIR_getCurrentIndex();
}

FlashImageRotator.prototype.setCurrentIndex = function(currentIndex)
{
	this._flashObject.FIR_setCurrentIndex(currentIndex);
}

/*
FlashImageRotator.prototype.getDebugText = function()
{
	return this._flashObject.FIR_getDebugText();
}
*/

FlashImageRotator.prototype.getInfo = function()
{
	return this._flashObject.FIR_getInfo();
}

function GoToTarget(targetUrl, openInNewWindow)
{
	if (openInNewWindow)
	{
		window.open(targetUrl, 'FIRTarget', 'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes');
	}
	else
	{
		window.parent.location.href=targetUrl;
	}
}