         ////////////////////////////////////////////////////////////////////////////////
         // Video window function, handles urls, sets up embeds, makes window visible/invisible
         ////////////////////////////////////////////////////////////////////////////////

         function playVid(vidId, noBlackout) {
            // Shows (or hides) the vidPane layer.   Accepts 2 parameteres.
            // vidId is null (close window) or an anchor object (contains HREF value)
            // vidId is mandatory example: <a href="someservice.com/somevideo.swf" onClick='return playVid(this);'></a>
            // noBlackout is optional. If you pass true, the background will not be "greyed out".

            if (vidId==null) { 
               // Null is passed by the "close" link, so we'll hide the layer.
               _vidPane.style.display='none';         // Hide the division.
               _vidPane.innerHTML='';                 // purge it's html (kill video)
               _blackout.style.display='none';        // Hide the blackout layer.
            } else {
               // Snag the url from the passed object
               vidId=vidId.href;

               // Next three lines make the blackout layer visible
               // and makes sure it covers the entire page.
               if (!noBlackout) {
                  _blackout.style.width='100%';
                  _blackout.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
                  _blackout.style.display='block';
               } else {
                  _blackout.style.display='none';        // Hide the blackout layer.
               }
               // Break out the URL passed to this function (so vidInfo[0]=http, [1]=domain, etc
               var vidInfo = vidId.split('/');

               // We're building a temporary string called vidstring. 
               // vidstring will hold the HTML as we build it based on the service
               // being used.  The next few lines contains items which are common
               // to all the services, or at least ignored if not directly used.
               
	       var vidstring =' ';	
               //var vidstring ='&nbsp;<A HREF="'+vidId+'">Source</A>';
               vidstring+='&nbsp;<A HREF="'+vidId+'"></A>';
	       vidstring+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="#" onClick="return(playVid())">Close</A><BR>';
               vidstring+='<center><embed ';  
               vidstring+=' enableJavascript="false" allowScriptAccess="never"';
               vidstring+=' allownetworking="internal" type="application/x-shockwave-flash"';
               vidstring+=' wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" ';

               // Now we'll do a little acrobatics for the individual services.

               if (vidInfo[2].indexOf('youtube.com')>=0) {
                  ////////////////////////////////////////////////////////////////////////////////
                  // YouTube (Use browser URL, autoplays)
                  ////////////////////////////////////////////////////////////////////////////////
                  vidInfo=vidId.match(/v\/.+$/);
                  vidInfo=String(vidInfo).replace(/v\//g,'');
                  vidstring+=' src="http://www.youtube.com/v/'+vidInfo+'" ';
                  vidstring+=' height="350" width="425" flashVars="autoplay=1"></embed></center>';
               } else if (vidInfo[2].indexOf('video.google.com')>=0) {
                  ////////////////////////////////////////////////////////////////////////////////
                  // Google (Use browser URL, autoplays)
                  ////////////////////////////////////////////////////////////////////////////////
                  vidInfo=vidId.match(/docid=.+$/);
                  vidInfo=String(vidInfo).replace(/docid=/g,'');
                  vidstring+='  src="http://video.google.com/googleplayer.swf?docId='+vidInfo+'&autoplay=1" ';
                  vidstring+=' height="350" width=425"></embed></center>';
               } else if (vidInfo[2].indexOf('metacafe.com')>0) {
                  ////////////////////////////////////////////////////////////////////////////////
                  // MetaCafe (Use browser URL, autoplays)
                  ////////////////////////////////////////////////////////////////////////////////
                  vidInfo=vidId.match(/watch.+$/);
                  vidInfo=String(vidInfo).replace(/watch./,'');
                  vidInfo=String(vidInfo).replace(/.$/,'');
                  vidstring+=' flashVars="playerVars=autoPlay=yes" ';
                  vidstring+=' src="http://www.metacafe.com/fplayer/'+vidInfo+'.swf" ';
                  vidstring+=' width="400" height="345">';  
                  vidstring+='</embed></center>';
               } else if (vidInfo[2].indexOf('ifilm.com')>=0) {
                  ////////////////////////////////////////////////////////////////////////////////
                  // iFilm (Use browser URL, autoplays)
                  ////////////////////////////////////////////////////////////////////////////////
                  vidInfo=vidId.match(/video.+$/);
                  vidInfo=String(vidInfo).replace(/video./,'');
                  vidstring+=' flashVars="flvbaseclip='+vidInfo+'&ip=true" ';
                  vidstring+=' src="http://ifilm.com/efp" quality="high" name="efp" align="middle" ';
                  vidstring+=' width="425" height="350">';  
                  vidstring+='</embed></center>';
               } else if (vidInfo[2].indexOf('dailymotion.com')>=0) {
                  ////////////////////////////////////////////////////////////////////////////////
                  // Daily Motion (Use EMBED URL, autoplays)
                  ////////////////////////////////////////////////////////////////////////////////
                  vidstring+=' src="'+vidId+'" flashVars="autoStart=1" ';
                  vidstring+=' width="425" height="334">';
                  vidstring+='</embed></center>';
               } else if (vidInfo[2].indexOf('break.com')>=0) {
                  ////////////////////////////////////////////////////////////////////////////////
                  // Break (use EMBED URL, does not autostart)
                  ////////////////////////////////////////////////////////////////////////////////
                  vidstring+=' src="'+vidId+'&autostart=1" autostart="1" ';
                  vidstring+=' width="425" height="350">';
                  vidstring+='</embed></center>';
               } else if (vidInfo[2].indexOf('shoutfile.com')>=0) {
                  ////////////////////////////////////////////////////////////////////////////////
                  // Shoutfile (use EMBED URL, does not autostart)
                  ////////////////////////////////////////////////////////////////////////////////
                  vidstring+=' src="'+vidId+'&autostart=true" flashvars="autostart=1" ';
                  vidstring+=' width="400" height="300">';
                  vidstring+='</embed></center>';
               } else {
                  ////////////////////////////////////////////////////////////////////////////////
                  // Failed.
                  ////////////////////////////////////////////////////////////////////////////////
                  vidstring += '></embed><BR><BR><BR>Unknown video service.</center>';
               } 
               // Insert our HTML and display the video window.
               _vidPane.innerHTML=vidstring;
               // Set the Y position of the video window so it's in the visible clip
               _vidPane.style.top=document.documentElement.scrollTop+50+'px';
               // Video window was hidden so we'll make it visible
               _vidPane.style.display='block'; 
            }
            return(false);
         }

         ////////////////////////////////////////////////////////////////////////////////
         // Drag and Grab handlers
         ////////////////////////////////////////////////////////////////////////////////

         function moveHandler(e){
            // Called automatically whenever the mouse is moved after a drag event starts
            if (e == null) { e = window.event }  // Get event data, if it wasn't passed, get it IE style.
            if ( _dragOK ){                      // is our global var set to true? is it ok to move the object?
               _savedTarget.style.left=e.clientX-_dragXoffset+'px';  //OK to move, calculate the offset and move it
               _savedTarget.style.top=e.clientY-_dragYoffset+'px';   // calculate the y offset and move it.
               return false;                                         // return false so browser doesn't try to do anything else.
            }                                   // End _dragOK check
         }                                      // End moveHandler
      
         function cleanup(e) {
            // Called whenever user lets up off a mouse button after a drag event starts
            document.onmousemove=null;                     // Turn off the mousemove event (won't call moveHandler() now).
            document.onmouseup=null;                       // Turn off the mouseup event (won't call cleanup() now).                     
            _savedTarget.style.cursor=_orgCursor;          // Restore original mouse shape
            _dragOK=false;                                 // Turn off the global constant we look for before moving stuff.
         }
      
         function dragHandler(e){
            // Called automatically when user holds down the mouse button
            var cursorType='-moz-grabbing';                               // Set mouse type to grabbing hand
            if (e == null) { e = window.event; cursorType='move';}        // This is IE so get event info IE style
            var target = e.target != null ? e.target : e.srcElement;      // Save object of the event
            if (target.className=="vidFrame") {                           // Did mouse go down over our dragable object?
               _orgCursor=target.style.cursor;                            // Remember the current mouse shape
               _savedTarget=target;                                       // Remember the object we're working with
               target.style.cursor=cursorType;                            // change mouse to "grab" icon                             
               _dragOK=true;                                              // When true, movehandler will move the window
               _dragXoffset=e.clientX-parseInt(_savedTarget.style.left);  // Remember current X offset
               _dragYoffset=e.clientY-parseInt(_savedTarget.style.top);   // Remember current Y offset
               document.onmousemove=moveHandler;                          // Call moveHandler() when mouse moves
               document.onmouseup=cleanup;                                // Call cleanup() when user lets go of mouse btn
               return false;                                              // IMPORTANT return false so browser doesn't do anything else.
            }                                                             // End Click on classname = object check
         }                                                                // End function dragHandler



	 function video_load () {
	document.onmousedown=dragHandler;

         _savedTarget=null;        // The target layer (effectively vidPane)
         _orgCursor=null;          // The original Cursor (mouse) Style so we can restore it
         _dragOK=false;            // True if we're allowed to move the element under mouse
         _dragXoffset=0;           // How much we've moved the element on the horozontal
         _dragYoffset=0;           // How much we've moved the element on the verticle
         _vidPane   = document.getElementById('vidPane');  // Our movable layer
         _blackout  = document.getElementById('blackout'); // greys out page 4 video 
         _vidPane.style.top='100px';    // Starting location horozontal
         _vidPane.style.left='200px';   // Starting location verticle

}

if (isJsEnabled()){
addLoadEvent (video_load);
}

