/*
 * for when a Youtube player is used and access the JS calls
 * Depends on swfobject.js being load before called
 * see http://code.google.com/apis/youtube/player_parameters.html for more details on the options
 */
;(function($) {

	/* Private functions */
	var __getPlayer	= function(){ return document.getElementById( $.youtubeplayer.id ); }

	$.extend({
			youtubeplayer : 
			{
					/* Load the player */
					loadPlayer	: function( elemID , vid )
					{
						var params 	= { 
								allowScriptAccess: "always"
							, 	bgcolor: $.youtubeplayer.bgcolor
							,	allowFullScreen:"true" 
						};
						var atts 	= { id: $.youtubeplayer.id };
						( vid )?$.youtubeplayer.video = vid:false;
						( elemID )?$.youtubeplayer.elemID = elemID :false;
						if( $.youtubeplayer.video.length == 0)
						{
							alert("there is no video to load!\nPlease pass in a video ID when loading the player");
						}
						else
						{
	     					swfobject.embedSWF(
									"http://www.youtube.com/v/"+$.youtubeplayer.video+"&amp;border=0&amp;enablejsapi=1&amp;playerapiid=ytplayer&amp;fs="+$.youtubeplayer.fullScreen
									+"&amp;hd="+$.youtubeplayer.highDef
									+"&amp;rel="+$.youtubeplayer.rel									
									+"&amp;showsearch="+$.youtubeplayer.showsearch									
									+"&amp;showinfo="+$.youtubeplayer.showinfo									
								,	$.youtubeplayer.elemID
								,	$.youtubeplayer.width 
								, 	$.youtubeplayer.height
								, 	$.youtubeplayer.flashVersion
								, 	null, null, params, atts);							
						}
							
					}
					/* Play functions */
				,	play	: function() 
					{
						__getPlayer().playVideo();
					}
				,	loadNewVideo	: function( vid )
					{
						 __getPlayer().loadVideoById(vid, parseInt(0));
					}
				
					/* default values */
				,	elemID	: "ytPlayer" /* the id of the HTML element to contain the player */
				,	id		: "thisyoutubeplayer" /* the ID of the element that is embeded */
				,	width	: 350 /* the width of the player */
				,	height 	: 290 /* the height of the player */
				,	flashVersion	: "8" /* the flash version the player requires */
				,	bgcolor	: "#cccccc" /* the bgcolor of the embed */
				,	video	: "" /* the string ID of the video to load */
				,	fullScreen	: 1 /* show the full screen button */
				,	highDef	: 1 /* show the high def button, if possible*/
				,	rel	: 0
				,	showsearch	: 0
				,	showinfo	: 0
					/* INIT function */
				,	init	: function( options ) {
					for( key in options)
					{
						if( $.youtubeplayer.hasOwnProperty(  key  ) )
						{
							$.youtubeplayer[ key ] = options[ key ];
						}
					}
				}
			}
			
			
		
	} );

})(jQuery);
/*
jQuery.extend(
	{
     name: "defaultName",
     size: 5,
     global: true
  }, options);

*/
