function MyGubaItem( fileId, userDownloadLink, numComments, tLink, aLink, subject, fileName, isContentOwner, isFavVideos, isUpload, isUserAuthor, isSourceUsenet, isVideo, isSourceGuba, isAuthenticated, authorThumbUrl, author, authorLink, numDownloads )
{
    this._fileId = fileId;
    this._userDownloadLink = userDownloadLink;
    this._premiumLink;
    this._numComments = numComments;
    this._tLink = tLink;
    this._aLink = aLink;
    this._subject = subject;
    this._fileName = fileName;
    this._isContentOwner = isContentOwner;
    this._isFavVideos = isFavVideos;
    this._isUpload = isUpload;
    this._isUserAuthor = isUserAuthor;
    this._isSourceGuba = isSourceGuba;
    this._isSourceUsenet = isSourceUsenet;
    this._isVideo = isVideo;
    this._isAuthenticated = isAuthenticated;
    this._authorThumbUrl = authorThumbUrl;
    this._author = author;
    this._authorLink = authorLink;
    this._numDownloads = numDownloads;

    this._output = "";
    
    this._isPremium = false;

    this.isTrue = isTrue;

    this.deleteFromBlock = deleteFromFavoriteVideos;
    this.deleteVideo = noBehavior;
    this.deleteVideoFromGuba = noBehavior;

    this.addVideoToSeries = addVideoToSeries;

    this.draw = draw;
}

function SearchItem( fileId, userDownloadLink, numComments, tLink, aLink, subject, fileName, isContentOwner, isFavVideos, isUpload, isUserAuthor, isSourceUsenet, isVideo, isSourceGuba, isAuthenticated, authorThumbUrl, author, authorLink, numDownloads )
{
    this._fileId = fileId;
    this._userDownloadLink = userDownloadLink;
    this._premiumLink;
    this._numComments = numComments;
    this._tLink = tLink;
    this._aLink = aLink;
    this._subject = subject;
    this._fileName = fileName;
    this._isContentOwner = isContentOwner;
    this._isFavVideos = isFavVideos;
    this._isUpload = isUpload;
    this._isUserAuthor = isUserAuthor;
    this._isSourceGuba = isSourceGuba;
    this._isSourceUsenet = isSourceUsenet;
    this._isVideo = isVideo;
    this._isAuthenticated = isAuthenticated;
    this._authorThumbUrl = authorThumbUrl;
    this._author = author;
    this._authorLink = authorLink;
    this._numDownloads = numDownloads;

    this._output = "";
    
    this._isPremium = false;

    this.isTrue = isTrue;

    this.deleteFromBlock = noBehavior;
    this.deleteVideo = noBehavior;
    this.deleteVideoFromGuba = noBehavior;

    this.addVideoToSeries = addVideoToSeries;

    this.draw = draw;
}

function SeriesItem( fileId, userDownloadLink, numComments, tLink, aLink, subject, fileName, isContentOwner, isFavVideos, isUpload, isUserAuthor, isSourceUsenet, isVideo, isSourceGuba, isAuthenticated, authorThumbUrl, author, authorLink, numDownloads, seriesId )
{
    this._fileId = fileId;
    this._userDownloadLink = userDownloadLink;
    this._premiumLink;
    this._numComments = numComments;
    this._tLink = tLink;
    this._aLink = aLink;
    this._subject = subject;
    this._fileName = fileName;
    this._isContentOwner = isContentOwner;
    this._isFavVideos = isFavVideos;
    this._isUpload = isUpload;
    this._isUserAuthor = isUserAuthor;
    this._isSourceGuba = isSourceGuba;
    this._isSourceUsenet = isSourceUsenet;
    this._isVideo = isVideo;
    this._isAuthenticated = isAuthenticated;
    this._authorThumbUrl = authorThumbUrl;
    this._author = author;
    this._authorLink = authorLink;
    this._numDownloads = numDownloads;
    this._seriesId = seriesId;

    this._output = "";
    
    this._isPremium = false;

    this.isTrue = isTrue;

    this.deleteFromBlock = deleteFromSeries;
    this.deleteVideo = noBehavior;
    this.deleteVideoFromGuba = noBehavior;

    this.addVideoToSeries = addVideoToSeries;

    this.draw = draw;
}

function MyUploadItem( fileId, userDownloadLink, numComments, tLink, aLink, subject, fileName, isContentOwner, isFavVideos, isUpload, isUserAuthor, isSourceUsenet, isVideo, isSourceGuba, isAuthenticated, authorThumbUrl, author, authorLink, numDownloads )
{
    this._fileId = fileId;
    this._userDownloadLink = userDownloadLink;
    this._premiumLink;
    this._numComments = numComments;
    this._tLink = tLink;
    this._aLink = aLink;
    this._subject = subject;
    this._fileName = fileName;
    this._isContentOwner = isContentOwner;
    this._isFavVideos = isFavVideos;
    this._isUpload = isUpload;
    this._isUserAuthor = isUserAuthor;
    this._isSourceGuba = isSourceGuba;
    this._isSourceUsenet = isSourceUsenet;
    this._isVideo = isVideo;
    this._isAuthenticated = isAuthenticated;
    this._authorThumbUrl = authorThumbUrl;
    this._author = author;
    this._authorLink = authorLink;
    this._numDownloads = numDownloads;

    this._output = "";
    
    this._isPremium = false;

    this.isTrue = isTrue;

    this.deleteFromBlock = noBehavior;
    this.deleteVideo = deleteVideo;
    this.deleteVideoFromGuba = deleteVideoFromGuba;

    this.addVideoToSeries = addVideoToSeries;

    this.draw = draw;
}

function UploadItem( fileId, userDownloadLink, numComments, tLink, aLink, subject, fileName, isContentOwner, isFavVideos, isUpload, isUserAuthor, isSourceUsenet, isVideo, isSourceGuba, isAuthenticated, authorThumbUrl, author, authorLink, numDownloads )
{
    this._fileId = fileId;
    this._userDownloadLink = userDownloadLink;
    this._premiumLink;
    this._numComments = numComments;
    this._tLink = tLink;
    this._aLink = aLink;
    this._subject = subject;
    this._fileName = fileName;
    this._isContentOwner = isContentOwner;
    this._isFavVideos = isFavVideos;
    this._isUpload = isUpload;
    this._isUserAuthor = isUserAuthor;
    this._isSourceGuba = isSourceGuba;
    this._isSourceUsenet = isSourceUsenet;
    this._isVideo = isVideo;
    this._isAuthenticated = isAuthenticated;
    this._authorThumbUrl = authorThumbUrl;
    this._author = author;
    this._authorLink = authorLink;
    this._numDownloads = numDownloads;

    this._output = "";
    
    this._isPremium = false;

    this.isTrue = isTrue;

    this.deleteFromBlock = noBehavior;
    this.deleteVideo = noBehavior;
    this.deleteVideoFromGuba = noBehavior;

    this.addVideoToSeries = addVideoToSeries;

    this.draw = draw;
}

/**
 * isTrue
 *
 * translate responses from perl into a boolean
 * 0 or '' => false
 * 1       => true
 */
isTrue = function( condition ) {
   return ( condition != '0'
         && condition != '' );
}

/**
 * deleteFromMyGuba
 *
 * delete an individual video from 
 * my guba; only from Favorite Video Section.
 */
deleteFromFavoriteVideos = function()
{
   if ( this.isTrue( this._isContentOwner ) )
   {
      this._output += '<div class="thumbs_remove">'
                   + '<a href="/delete_from_myfavorite?bid=' + this._fileId + '">'
                   + '<img src="/art/btn_remove.gif" alt="Remove Video" title="Remove Video" border="0">'
                   + '</a>'
                   + '</div>';
   }
}

/**
 * deleteFromSeries
 *
 * remove the current video from
 * the current series.
 */
deleteFromSeries = function()
{
   if ( this.isTrue( this._isContentOwner ) )
   {
      this._output += '<div class="thumbs_remove">'
                   + '<a href="/delete_from_series?bid=' + this._fileId + '&series_id=' + this._seriesId + '">'
                   + '<img src="/art/btn_remove.gif" alt="Remove from Series" title="Remove from Series" border="0">'
                   + '</a>'
                   + '</div>';
   }
}

/**
 * deleteVideo
 *
 * delete video from the site; contained in a div
 */
deleteVideo = function()
{
   this._output += '<div class="thumbs_remove">'
                + '<a href="#" onclick="window.open( \'http://upload.guba.com/user/deleteOpus.do?id='
                + this._fileId
                + '\',\'newWin\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height=285,width=650\');">'
                + '<img src="/art/btn_remove.gif" alt="Delete Video from GUBA" title="Delete Video" border="0">'
                + '</a>'
                + '<span class="edit_btn">'
                + '<a href="#" onclick="window.open( \'http://upload.guba.com/user/editOpus.do?id='
                + this._fileId
                + '\',\'newWin\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,height=650,width=650\');">'
                + '<img src="/art/btn_edit.gif" alt="Edit Video Details" title="Edit Video Details" border="0">'
                + '</a>'
                + '</span>'
                + '</div>';
}

/**
 * deleteVideoFromGuba
 *
 * delete video from the site; contained in a li
 */
deleteVideoFromGuba = function()
{
   this._output +='<li class="tooltip_mid">'
              + '<a href="#" onclick="window.open( \'http://upload.guba.com/user/deleteOpus.do?id='
                + this._fileId
                + '\',\'newWin\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height=285,width=650\');">'
                + '<img src="/art/icon_delete.gif" border="0" alt="Delete Video from GUBA" title="Delete Video from GUBA"> Delete Video</a>'
                + '</li>'
                + '<li class="tooltip_mid">'
                + '<a href="#" onclick="window.open( \'http://upload.guba.com/user/editOpus.do?id='
                + this._fileId
                + '\',\'newWin\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,height=650,width=650\');">'
                + '<img src="/art/icon_edit.gif\" border="0" alt="Edit Video Details" title="Edit Video Details"> Edit Details</a>'
                + '</li>';
}

/**
 * addVideoToSeries
 *
 * add the current video to a series; brings up the series
 * lightbox to select which series to place it in or create
 * a new series; this can be from one series to another.
 */
addVideoToSeries = function()
{

   this._output += ' <a href="#">'
                + '<img src="/art/btn_addtoseries.gif" ';
 
   if ( this._isAuthenticated )
   {
      this._output += 'alt="Add to a Series" title="Add to a Series" onClick="showSeries( \'isLightBox=true&source_myguba=1\', \'' + this._fileId + '\' );" ';
   }
   else {
      this._output += 'alt="Subscribe to Use This Feature" title="Subscribe to Use This Feature" onClick="showSignupOverlay( \'isLightBox=true\' );" ';
   }
 
   this._output += 'border="0"/></a>';
}

/**
 * userConfirm
 *
 * Ask the user <message>
 * If yes, go to the given url, else do nothing.
 * originally written for ticket #2619
 */
function userConfirm(message, url) {
    if(confirm(message))
        location.href = url;
}

/**
 * noBehavior
 *
 * allows behavior to be blocked and the script
 * continues.
 */
noBehavior = function()
{
}

/**
 * draw
 *
 * main function from which you draw the thumb; this function
 * calls the instance function which the object has set (or set
 * as an empty function) to polymorphically determine functionality.
 */
draw = function()
{
   if ( this._output == '' )
   {
      this._output += '<div id="block_thumb" class="video_sml" style="margin-right:11px;">';
           
      this.deleteFromBlock();

      this.deleteVideo();


      /**
       * Mark video as Usenet or Guba Upload
       */
      if ( this.isTrue( this._isSourceUsenet ) )
      {
         this._output += '<span class="block_thumb_label">'
                      + '<img src="/art/img_label_usenet.gif">'
                      + '</span>';
      }
      else {
         this._output += '<span class="block_thumb_label_upload">'
                      + '<img src="/art/img_label_upload.gif">'
                      + '</span>';
      }

      /**
       * Show number of comments
       */
      if ( this.isTrue( this._numComments ) )
      {
         this._output += '<span class="block_thumb_comment thumb_comment_sml">'
                      + '<a href="' + this._userDownloadLink + '#comments" alt="'
                      + this._numComments + ' Comments" title="'
                      + this._numComments + ' Comments">'
                      + this._numComments
                      + '</a>'
                      + '</span>';
      }

      this._output += '<a href="' + this._userDownloadLink + '" >'
                   + '<img src="' + this._tLink + '"';
  
      if ( this.isTrue( this._isVideo ) )
      {
         this._output += ' onMouseOver="this.src=\'' + this._aLink
                      + '\';" onMouseOut="this.src=\'' + this._tLink + '\';" ';
      }
  
      this._output += 'alt="" border="0"/>'
                   + '</a>'
                   + '<ul class="drop drop_free"><li style="width:134px;" ><div class="thumbs_title_small">'
                   + '<a href="' + this._userDownloadLink + '">';
               
     if ( this.isTrue( this._isSourceUsenet ) )
     {
         this._output += this._fileName;
     }
     else {
        this._output += this._subject;
     }
 
     this._output += '</a>'
                  + '<ul><li class="tooltip_top"><img src="/art/_.gif" width="8" height="5" /></li>'
                  + '<li class="tooltip_mid"><b>'
                  + '<a href="' + this._userDownloadLink + '" alt="'
                  + this._subject + '" title="' + this._subject + '" >';
 
     if ( this.isTrue( this._isSourceUsenet ) )
     {
        this._output += this._fileName;
     }
     else {
        this._output += this._subject;
     }
 
     this._output += '</a>'
                  + '</b></li>'
                  + '<li class="tooltip_mid"><b>Posted by:</b>';
              
     if ( this.isTrue( this._isSourceUsenet ) )
     {
        this._output += '<a href="' + this._authorLink + '">';
     }
     else {
        this._output += '<img src="' + this._authorThumbUrl + '"> <a href="/user/' + this._author + '"> ';
     }
 
     this._output += this._author + '</a>'
                  + '</li>'
                  + '<li class="tooltip_mid">'
                  + '<b>Views:</b> ' + this._numDownloads + '</li>'
                  + '<li class="tooltip_mid_btn"> '
                  + '<a href="';
 
     if ( this._isAuthenticated )
     {
        this._output += 'javascript:;';
     }
     else {
        this._output += '#';
     }
 
     this._output += '"><img name="addToFavorite" src="/art/btn_favorites.gif" ';
 
     if ( this._isAuthenticated )
     {
        this._output += 'alt="Add to My GUBA" title="Add to My GUBA" onClick="addGalleryFavorite( \'' + this._fileId + '\', this );" ';
     }
     else {
        this._output += 'alt="Subscribe to Use This Feature" title="Subscribe to Use This Feature" onClick="showSignupOverlay( \'isLightBox=true\' );" ';
     }
 
     this._output += 'border="0"/></a>'
     
     this.addVideoToSeries();

     this._output += '</li>';

     this.deleteVideoFromGuba();
              
     this._output += '<li class="tooltip_bot"><img src="/art/_.gif" width="8" height="5" /></li>'
                  + '<li class="tooltip_triangle"><img src="/art/_.gif" width="28" height="18" /></li>'
                  + '</ul>'
                  + '</li></ul>'
                  + '</div>';
     }

   return this._output;
}
