/*
  to control plugin from http://jquery.lukelutman.com/plugins/flash/

*/
$(document).ready(function() {
	
	function fLoadFlash(sStream) {
		$('#video_player').empty();
		/*$('#video_player').flash({
	    src: sURL,
	    width: 528,
	    height: 305,
	    wmode: 'transparent',
	    play:'true'
	  });		*/
	  $('#video_player').flashembed('player.swf',{
	  	MM_ComponentVersion:1,
	  	skinName:'Clear_Skin_1',
	  	streamName:sStream,
	  	autoPlay:true,
	  	autoRewind:true
	  	//FlashVars: '&MM_ComponentVersion=1&skinName=Clear_Skin_1&streamName='+sStream+'&autoPlay=true&autoRewind=true'
	  });
	}
	
	// create the links to the other videos 	
	function fCreateVidLink(sCaption, sText, sImageURL, sVideoURL) {
		var oLink=document.createElement('a');
		oLink.setAttribute('href',sVideoURL);
		$(oLink).addClass('video_link');		
		$(oLink).css('background-image','url('+sImageURL+')');
		
		$(oLink).append($('<b>'+sCaption+'</b>'));
		$(oLink).append($('<em>[PLAYING]</em>'));
		$(oLink).append($('<br /><span>'+sText+'</span>'));
		
		var oCow=document.createElement('img');
		oCow.setAttribute('src','../images/cow.png');
		$(oCow).addClass('cow');
		$(oLink).append($(oCow));
		
		$(oLink).click(function(){
			
			$('.video_link').removeClass('current');
			
			fLoadFlash(this.getAttribute('href'));
			$(this).addClass('current');
			this.blur();
			return false;
		});
		
		$(oLink).appendTo($(oControlsWrapper));
		return oLink;
	}
	
	var oControlsWrapper=document.createElement('div');
  oControlsWrapper.setAttribute('id','controls_wrapper');
	
	var oFirstLink=fCreateVidLink('Introduction','Welcome to Celtic Pride, premium Welsh beef','../images/vid_control-intro.png','../videos/intro');
  fCreateVidLink('Production','See our quality assured production process in action.  Find out why Celtic Pride is some of the finest Wales has to offer','../images/vid_control-production.png','../videos/production');
  fCreateVidLink('Products','Ideas and inspiration to whet your appetite.  Warning - this may make you seriously hungry!','../images/vid_control-product.png','../videos/product');	
	 
	$(oControlsWrapper).appendTo($('#video'));
	
	//fLoadFlash('../videos/intro');
	$(oFirstLink).click();
  
});