/**
* tourplayer.js
* Ryan Lord 2008
* Version 1.0 - 25 Apr 2008
*
* Manages multiple player instances on a single page for the sponsor tailer templates
*/
var TourPlayer = {
	players : [],
	sponsor : '',
	gallery : '',
	skin : '',
	linkURL : '',
	width : null,
	height : null,
	intialized : false,
	
	init : function(width,height,numPlayers,skin,linkURL)
	{
		try
		{
			if ( !this.intialized )
			{
				if ( !this.sponsor && !this.gallery )
				{
					var loc = location.href.replace(/((http\:\/\/(www\.)?(.+)\/galleries\/)|((\/)?index\.html(\/)?)$)/gi,'').split('/');
					this.sponsor = loc[0];
					this.gallery = loc[1];
				}
				this.skin = skin ? skin : this.sponsor ;
				if ( linkURL ) this.linkURL = linkURL;
				this.width = width;
				this.height = height;
			
				for ( var i=1; i<=numPlayers; i++)
				{
					this.players[i] = this.createPlayer(i);
				}
				this.intialized = true;
			}
			
		}
		catch(e) {alert(e);};
	},
	
	createPlayer : function(targetID)
	{
		if ( targetID < 10 ) targetID = '0'+targetID;
		
		var so = new SWFObject('/players/'+this.skin+'/player.swf','so_'+targetID,this.width,this.height,'8');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','true');
		so.addVariable('height',this.height);
		so.addVariable('width',this.width);
		so.addVariable('banner','/players/'+this.skin+'/banner.png');
		if ( this.linkURL ) so.addVariable('sponsorLink',this.linkURL);
		so.addVariable('sponsorImage','/players/'+this.skin+'/sponsor.png');
		so.addVariable('displayheight',this.height);
		so.addVariable('displaywidth',this.width);
		so.addVariable('file','/galleries/'+this.sponsor+'/'+this.gallery+'/'+targetID+'.flv');
		so.addVariable('image','/galleries/'+this.sponsor+'/'+this.gallery+'/'+targetID+'.jpg');
		so.addVariable('id','player_'+targetID);
		so.addVariable('backcolor','0x3e3e3e');
		so.addVariable('frontcolor','0xa6a6a6');
		so.addVariable('lightcolor','0xe0e0e0');//'0x015e95');
		so.addVariable('screencolor','0x000000');
		so.addVariable('javascriptid','js_'+targetID);
		so.addVariable('showdigits','false');
		so.addVariable('usefullscreen','false');
		so.addVariable('enablejs','true');
		so.write('player_'+targetID);
		
		return [so,targetID];
	}
}

