
/* Copyright (c) 2007-2010 Filmit IT Solutions. All rights reserved. */

/**
 * Collection of JavaScript functions
 * for Filmit CMS generated DHTML pages.
 */


function showClip( clipAddress, width, height, clipDiv) {

  var wmpVer = null;
  var wmpMajor = 0;

  if (( typeof( window.ActiveXObject) != 'undefined') &&
      ( typeof( WMP7) != 'undefined') &&
      ( typeof( WMP7.URL) != 'undefined') &&
      ( WMP7.URL == '')) {

    wmpVer = WMP7.versionInfo.split('.');
    wmpMajor = parseInt( wmpVer[0]);

  }

  if ( wmpMajor >= 12) {

    showClipWMP( clipAddress, width, height, clipDiv);

  } else {

    showClipQT( clipAddress, width, height, clipDiv);

  }

  return void(0);
}


function showClipWMP( clipAddress, width, height, clipDiv) {

  var clipNode = document.getElementById( clipDiv);
  var ctrlHeight = height + 64;
  var clipObject = null;
  var srcParam = null;
  var autoParam = null;
  var ctrlParam = null;
  var qtEmbed = null;

  clipNode.style['padding'] = '20pt 0';

  if ( typeof( window.ActiveXObject) != 'undefined') {

    clipObject = document.createElement( 'object');
    srcParam = document.createElement ( 'param');
    autoParam = document.createElement ( 'param');
    ctrlParam = document.createElement ( 'param');

    srcParam.name = 'url';
    srcParam.value = clipAddress;
    clipObject.appendChild( srcParam);

    autoParam.name = 'autoStart';
    autoParam.value = 'true';
    clipObject.appendChild( autoParam);

    ctrlParam.name = 'uiMode';
    ctrlParam.value = 'full';
    clipObject.appendChild( ctrlParam);

    clipObject.width = width.toString();
    clipObject.height = ctrlHeight.toString();

    while ( clipNode.firstChild) {
      clipNode.removeChild( clipNode.firstChild);
    }
    clipNode.appendChild( clipObject);

    clipObject.classid = 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6';

  } else {

    // The current version of showClip only branches to showClipWMP if ActiveXObject is available.

  }

  return void(0);
}


function showClipQT( clipAddress, width, height, clipDiv) {

  var clipNode = document.getElementById( clipDiv);
  var ctrlHeight = height + 16;
  var clipObject = null;
  var srcParam = null;
  var autoParam = null;
  var ctrlParam = null;
  var qtEmbed = null;

  clipNode.style['padding'] = '20pt 0';

  if ( typeof( window.ActiveXObject) != 'undefined') {

    clipObject = document.createElement( 'object');
    srcParam = document.createElement ( 'param');
    autoParam = document.createElement ( 'param');
    ctrlParam = document.createElement ( 'param');

    srcParam.name = 'src';
    srcParam.value = clipAddress;
    clipObject.appendChild( srcParam);

    autoParam.name = 'autoplay';
    autoParam.value = 'true';
    clipObject.appendChild( autoParam);

    ctrlParam.name = 'controller';
    ctrlParam.value = 'true';
    clipObject.appendChild( ctrlParam);

    clipObject.width = width.toString();
    clipObject.height = ctrlHeight.toString();

    while ( clipNode.firstChild) {
      clipNode.removeChild( clipNode.firstChild);
    }
    clipNode.appendChild( clipObject);

    clipObject.codeBase = 'http://www.apple.com/qtactivex/qtplugin.cab';
    clipObject.classid = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';

  } else {

    clipNode.innerHTML = '<EMBED SRC="' + clipAddress + '" WIDTH="' + width.toString() + '" HEIGHT="' + ctrlHeight.toString() + '" TYPE="video/quicktime" PLUGINSPAGE="http://www.apple.com/quicktime/download/" AUTOPLAY="true" CONTROLLER="true" \/>';

  }

  return void(0);
}

function showLatest() {

  var myclass = new RegExp('\\blatest\\b');
  var classes = null;
  var elem = document.getElementsByTagName('p');

  for ( var i = 0; i < elem.length; i++) {
    classes = elem[i].className;
    if ( myclass.test(classes)) {
      if ( elem[ i].style['display'] == 'block') {
        elem[ i].style['display'] = 'none';
      } else {
        elem[ i].style['display'] = 'block';
      }
    }
  }

  return void(0);
} 

