/* Arie Molendijk, a plugin for the JW Player playing YouTube video's. It may be possible to economize the script a little bit further. Anyhow, it functions well as it is. You can freely use this script. I would be grateful if you put a link on your page to:
http://www.let.rug.nl/molendyk/include_video_jw_examples/example.html. 

The plugin allows us to: 
(i) create a customized playlist for chromeless YouTube-videos (using the JW player), 
(ii) place info about each video at the top of it and 
(iii) chop the video's - which makes it possible to create new YouTube-video's out of existing ones, by taking parts out of them. 

You have to use styles like the following on your page:
.player, .info {position:absolute; width:25%; left:45%; width:30%; margin-left:-11%; background:black; padding: 5px; border-right:1px solid black;border-top:1px solid black;}
.info{top: 10%; color: white; height:4%; overflow:auto; font-family:arial; font-size: 11px; }
.player{top:14%; height:25%; }

The top value for .player must be: 
top value for .info plus height for .info. 

The height of .info must be at least 4% or 37px in order for Firefox to show scroll bars in the info section.

Don't remove the specifications for the borders and the padding.

If you want to position the player at the top of the page, then give '.info' 0% for top and give '.player' 4% for top (assuming the height for '.info' is 4%). If you also want the bottom of the player to be positioned at the bottom of the screen, the height for '.player' must be 96%, not 100%.
Of course, all of this does not apply if you simply don't use the info area, by giving 'display: none' to the div having 'id=info' (see source of page, body section ).


Examples of use:
- Playing a complete video, no autostart:
  onclick="play_simple_nonauto('goeOUTRy2es'); info('Your <b>text about the video<\/b> <i>here<\/i>.')"
- Playing a complete video, autostart:
  onclick="play_simple_auto('goeOUTRy2es'); info('Your <b>text about the video<\/b> <i>here<\/i>.')"
- Playing part of a video, no autostart:
  onclick="play_chopped_nonauto('goeOUTRy2es',30,130); info('Your <b>text about the video<\/b> <i>here<\/i>.')"
- Playing part of a video, autostart:
  onclick="play_chopped_auto('goeOUTRy2es',30,130); info('Your <b>text about the video<\/b> <i>here<\/i>.')"

In order for this to work, these links must be preceded by (also in the body!; the order of the divs and the scripts must remain intact!!):


<div id='mediaspace' class='player'></div>

<div id='hider' class='player' ></div>

<div id="info" class='info' ></div>

<script type='text/javascript' src='http://www.yoursite/your_jw_folder/swfobject.js'></script>

<script type='text/javascript' src="play_youtube.js"></script> (if the name of THIS script is 'play_youtube.js')



***************************************************************************/
//THE SCRIPT 
function smooth_transition()
{
document.getElementById('hider').style.display='block';setTimeout('document.getElementById(\'hider\').style.display=\'none\'',1500);
}

function info(which)
{
document.getElementById('info').innerHTML=which; 
}




//SIMPLE (NON-CHOPPED) VIDEO'S

function prepare_play_simple()
{
     so_simple.addVariable('file',video);so_simple.addVariable('image',image);so_simple.write('mediaspace')
}

function play_simple_auto(which,img)
{
     so_simple.addVariable('autostart','false');
     document.getElementById('info').innerHTML='';
     smooth_transition();
     video=''+which;
     image=''+img;
     prepare_play_simple();
}


function play_simple_nonauto(which)
{
so_simple.addVariable('autostart','false');document.getElementById('info').innerHTML=''; smooth_transition(); video='http://youtube.com/watch%3Fv%3D'+which;prepare_play_simple(); 
}

var so_simple = new SWFObject('http://www.let.rug.nl/molendyk/include_video_jw/player-viral.swf','ply','285','175','9','#ffffff');
so_simple.addParam('allowfullscreen','true');
so_simple.addParam('allowscriptaccess','never');
so_simple.addParam('wmode','opaque');
so_simple.addVariable('autostart','false');
so_simple.addVariable("volume","100");
//so_simple.addVariable('autostart','true');
//so_simple.addVariable('image',img);
//so_simple.addVariable('icons','false');
//so_simple.addVariable('duration','130');



//CHOPPED VIDEO'S

function prepare_play_chopped()
{
so_chopped.addVariable('file',video);so_chopped.write('mediaspace')
}





function play_chopped_auto(which,start_at,end_at)
{
so_chopped.addVariable('autostart','false');so_chopped.addVariable('start',start_at);so_chopped.addVariable('duration',end_at);document.getElementById('info').innerHTML=''; smooth_transition(); video='http://youtube.com/watch%3Fv%3D'+which;prepare_play_chopped(); 
}


function play_chopped_nonauto(which,start_at,end_at)
{
so_chopped.addVariable('autostart','false');so_chopped.addVariable('start',start_at);so_chopped.addVariable('duration',end_at);document.getElementById('info').innerHTML=''; smooth_transition(); video='http://youtube.com/watch%3Fv%3D'+which;prepare_play_chopped(); 
}

  
var so_chopped = new SWFObject('http://www.let.rug.nl/molendyk/include_video_jw/player-viral.swf','ply','100%','100%','9','#ffffff');
so_chopped.addParam('allowfullscreen','true');
so_chopped.addParam('allowscriptaccess','never');
so_chopped.addParam('wmode','opaque');
so_chopped.addVariable('autostart','false');
so_chopped.addVariable("volume","100");
//so_chopped.addVariable('autostart','true');
//so_chopped.addVariable('image','http://wallpapers-diq.org/wallpapers/21/Sheet_Music.jpg');

//so_chopped.addVariable('icons','false');
//so_chopped.addVariable('duration','130');




