/*
	HowToInterface.js
	
	Sets Up all of the functionailty to talk with our Flash Video player. 
	
	The variable in the domready function is case sensitive, DO NOT CHANGE
	or all of the Flash/Interface interaction will disappear. 
*/

var HowToInterface = new Class({
	options: {
		VideoContainer: Class.empty,
		TitleContainer: Class.empty,
		HowToContainer: Class.empty
	},
	
	initialize: function(options) {
		// Start-Up Code	
		this.setOptions(options);
		this.HowTo = $(this.options.HowToContainer);
		this.Video = $(this.options.VideoContainer);
		this.Title = $(this.options.TitleContainer);
		
		// All Links in the HowTo container will be modified.
		if( this.HowTo )
			this.Links = this.HowTo.getElements('a');
		
		if ( this.Links )
			for(var i = 0; i < this.Links.length; i++)
				this.Links[i].addEvent('click', this.HowToPress.bindWithEvent( this, this.Links[i] ));
		
	},
	
	HowToPress: function(event, refObj) {		
		var IData     = refObj.id.split("[_]");
		var ClassName = IData[0];
		var VideoName = IData[1].split(".")[0];
		var theID     = IData[2];
		
		// Change Title
		if( this.Video )
		{
			this.Title.innerHTML = ClassName;
			this.Video.PlayVideo(VideoName);
			event.stop();
		}
		else
		{
			var newAddress = document.location.href.split("/Detail/");
			
			document.location.href = newAddress[0] + "/Detail/" + theID + "/";
		}
	}
	
	
});

HowToInterface.implement(new Options);

window.addEvent('domready', function(){
	var HowTo = new HowToInterface({
		VideoContainer: "ClassPlayer",
		TitleContainer: "vid_title",
		HowToContainer: "how_to_content"
   });
});