/**
* Assign the view handler
*/

viewHandler = Home;

/**
* Creates a new object with methods used by the Home page
*
* @author				Matt Gifford
* @copyright			2008 Timeshifting Interactive Limited
*/
function Home()
	{
	// Step 1. Define Properties

	var _instance = this;



	// Step 2. Define Public Methods

	/**
	* Sets up the initial page state and event handlers
	*/
	this.init = function()
		{
		// Call generic page init method
		this.base.init.call(this);
		}


	/**
	* Displays the information block for the specified video
	*
	* @param		obj		The anchor clicked on
	* @param		id			The video block to display
	*/
	this.focusVideo = function(obj, id)
		{
		// Update the menu list
		var anchors = document.getElementById('homeVideos').getElementsByTagName('ul')[0].getElementsByTagName('a');
		for (var x = 0; x < anchors.length; x++)
			{
			anchors[x].className = '';
			}
		obj.className = 'active';

		// Update the video information blocks
		for (var x = anchors.length; 0 < x; x--)
			{
			document.getElementById('homeVideo' + x).className = 'hidden';
			}
		document.getElementById('homeVideo' + id).className = '';
		}


	/**
	* Plays the specified video
	*
	* @param		id					The video to play
	* @param		youtube		Id is a youtube video id
	*/
	this.playVideo = function(id, youTube)
		{
		// Inject the container html
		var viewer = document.createElement('div');
		viewer.id = 'viewer';
		viewer.innerHTML = '<div id="viewerBackground" onclick="document.body.removeChild(document.getElementById(\'viewer\'));"></div><div id="viewerFlash"><div id="flashPlayer"></div><a href="javascript:;" class="close" onclick="document.body.removeChild(document.getElementById(\'viewer\'));"></a></div>';
		document.body.appendChild( viewer );

		// Inject the flash player
		if (arguments.length == 1)
			{
			var so = new SWFObject("http://www.foreveryoung.net/flash/videoplayer.swf", "mediaVideo", "480", "407", "8", "#000000");
			so.addParam("wmode", "opaque");
			so.addParam("allowScriptAccess", "sameDomain");
			so.addParam("allowFullScreen", "true");
			so.addParam("loop", "false");
			so.addVariable("videoPaths","videos/34.flv,kabc_tv_dr_rahimi_tuliplift.flv,rahimitulip.flv,rahimiethnic.flv,rahimihand.flv");
			so.addVariable("startIndex", ""+(--id));
			so.write('flashPlayer');
			}
		else
			{
			var so = new SWFObject("http://www.youtube-nocookie.com/v/" + id + "?fs=1&amp;hl=en_US", "mediaVideo", "480", "407", "8", "#000000");
			so.addParam("wmode", "opaque");
			so.addParam("allowScriptAccess", "sameDomain");
			so.addParam("allowFullScreen", "true");
			so.addParam("loop", "false");
			so.write('flashPlayer');
			}

		}
	}

