               /* ................................................. */
               /*   file: playVideo.js                              */
               /*   author: Ted O'Hara                              */
               /*   purpose: support for video page                 */                       
               /*   Created: 11/24/2008                             */
               /*   Copyright (C) 2008 bx.com, Inc.                 */
               /* ................................................. */ 
               
var miVideo = new Object();


miVideo.showVideo = function()
  {
    var queryString = this.href.split('?')[1]
    var playerDims = {height:'',width:''}
    var delta = {height:0,width:0}
    if(queryString)
      {
        var urlVars = queryString.split('&')
        var valPair, varName, varValue;
        for (var i = 0; i < urlVars.length; i++)
          {
            valPair = urlVars[i].split('=');
            varName = valPair[0]; varValue = parseInt(valPair[1])
            if(varName.match(/height|width/)){playerDims[varName] = varValue}
          }
          
        if (! isNaN(playerDims.height)) {playerDims.height += 130} else {playerDims.height = 400}
        if (! isNaN(playerDims.width)) {playerDims.width += 100} else {playerDims.width = 300}       
       
        if (!miVideo.popup || miVideo.popup.closed) //popup doesn't exist
          {
            miVideo.pdims = {width:playerDims.width,height:playerDims.height}
            miVideo.popup = popWindow(this.href, playerDims.width, playerDims.height, 'videoWindow');
            miVideo.popup.name = 'videoWindow'
           
          } 
        else //popup alread exists, resize.
          {
            delta.width = playerDims.width - miVideo.pdims.width;
            delta.height = playerDims.height - miVideo.pdims.height;
                        
            miVideo.popup.resizeBy(delta.width,delta.height)
            miVideo.popup.location.replace(this.href)
            
            miVideo.pdims.width = playerDims.width
            miVideo.pdims.height = playerDims.height
            
            miVideo.popup.focus()
          }
        return false
      }
    else {return true} //no query string, bail & allow default action
    
  }
  
miVideo.closePopup = function()
  {
  
  }

miVideo.init = function()
  {
    
    var videoArray = document.getElementById('video_array');
    var videoLnx = videoArray.getElementsByTagName('A');
    var currLk;
    
    for(var i = 0; i < videoLnx.length; i++)
      {
        currLk = videoLnx[i]
        
        if (currLk.className.match(/videolink/)) {currLk.onclick = this.miVideo.showVideo}
      }
  }  

if (window.addEventListener)
  {
    window.addEventListener('load',miVideo.init,false)
  }
else if (window.attachEvent)
  {
    window.attachEvent('onload',miVideo.init)
  }
  
 
  
function enumerateProperties()
  {
    var pString = this + '\n\nProperties:\n---------------\n';
    for (property in this)
      {
        if (typeof this[property] == 'function') 
          {
            {pString += property + ': (function)\n';}
          }
        else
        
          {pString += property + ': ' + this[property] + '\t\t\tType: ' + typeof this[property] + '\n';}
      }
    return pString
  }
  Object.prototype.toFullString = enumerateProperties
  
  

             




