/*  ********** THESE TWO FUNCTIONS ARE USED BY ALL OF THE OTHER FUNCTIONS ********** */

// Create object variables representing a given layer and its style object
function getObj(name)
{
   if (document.getElementById)
   {
      this.obj = document.getElementById(name);
      this.style = document.getElementById(name).style;
   }
   else if (document.all)
   {
      this.obj = document.all[name];
      this.style = document.all[name].style;
   }
   else if (document.layers)
   {
      this.obj = getObjNN4(document,name);
      this.style = this.obj;
   }
}

/* Netscape 4.x browsers handle layers as if they were separate documents.
    Referencing a nested layer in "dot" notation becomes cumbersome. For example,
    a layer nested 3 levels deep (a layer inside a layer inside a layer), is referred to as
    document.layers.layerLevel1.document.layers.layerLevel2.document.layers.layerLevel3  */
function getObjNN4(obj,name)
{
   var x = obj.layers;
   var foundLayer;
   for (var i=0;i<x.length;i++)
   {
      if (x[i].id == name)
              foundLayer = x[i];
      else if (x[i].layers.length)
              var tmp = getObjNN4(x[i],name);
      if (tmp) foundLayer = tmp;
   }
   return foundLayer;
}
/*  ******************************************************************************** */


// Given a layer name, change its contents
function writeToLayer(layerName,layerText) {
if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=layerText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(layerText);
   x.style.document.close();
}
}

/*  ************ THESE ARE BASIC FUNCTIONS USED TO SHOW AND HIDE LAYERS ************ */
// Given a layer name, make it visible
function showLayer(layerName)
{
   var x = new getObj(layerName);
   x.style.visibility = 'visible';
   x.style.display = 'block';
}

// Given a layer name, make it invisible
function hideLayer(layerName)
{
   var x = new getObj(layerName);
   x.style.visibility = 'hidden';
   x.style.display = 'none';
}

// Given a layer name, change its size
function changeLayerSize(layerName,layerWidth,layerHeight)
{
   var x = new getObj(layerName);
   if (layerWidth != '') {
     x.style.width = layerWidth + 'px';
   }
   if (layerHeight != '') {
     x.style.height = layerHeight + 'px';
   }
}

// Given a layer name, change its left and top coordinates
function positionLayer(layerName,Xcoord,Ycoord)
{
   var x = new getObj(layerName);
   if (Xcoord!='') {
     x.style.left = Xcoord + 'px';
   }
   if (Ycoord != '') {
     x.style.top = Ycoord + 'px';
   }
}

// Given a layer name represented as a tabbed index card in a stack,
//   make it visible by changing its "Z" index
function showTab(layerName)
{
   var x = new getObj(layerName);
   x.style.zIndex = '10';
}

// Given a layer name represented as a tabbed index card in a stack,
//   make it invisible by changing its "Z" index
function hideTab(layerName)
{
   var x = new getObj(layerName);
   x.style.zIndex = '9';
}
/*  ******************************************************************************** */

/*  *********** THESE FUNCTIONS ARE USED TO CREATE "WIPE" TRANSITIONS *********** */
enableShow = 'enabled';
enableHide = 'enabled';

function getClipValueTop(layerName) {
var y = new getObj(layerName);
var currTop;

if(document.layers) {
   currTop =  y.style.clip.top;
} else if(document.getElementById || document.all) {
   var clipVals = y.style.clip.split("rect(")[1].split(" ")[0].split("px");
   currTop = clipVals[0];
}
//alert (currTop);
return currTop;
}

function setClipValues(layerName,clipTop,clipRight,clipBottom,clipLeft) {
var y = new getObj(layerName);
if(document.layers) {
   y.style.clip.top = clipTop;
   y.style.clip.right = clipRight;
   y.style.clip.bottom = clipBottom;
   y.style.clip.left = clipLeft;
} else if(document.getElementById || document.all) {
   y.style.clip = "rect(" + clipTop + "px, "
   + clipRight + "px, "
   + clipBottom + "px, "
   + clipLeft + "px)";
}
}

/*  *****  For 500px by 200px layers  *****  */
function showBio(layerName) {
if (enableShow == 'enabled') {
var strCurrTop = getClipValueTop(layerName);
var intCurrTop = parseInt(strCurrTop);
intCurrTop -= 2;
strCurrTop = intCurrTop.toString();
if (intCurrTop>=0) {
enableHide = 'disabled'; //prevent hideBio() function from working at the same time
setClipValues(layerName,strCurrTop,"500","200","0");
setTimeout('showBio("' + layerName + '")',40);
}
else {
enableHide = 'enabled';
}
}
}

/*  *****  For 500px by 200px layers  *****  */
function hideBio(layerName) {
if (enableHide == 'enabled') {
var strCurrTop = getClipValueTop(layerName);
var intCurrTop = parseInt(strCurrTop);
intCurrTop += 2;
strCurrTop = intCurrTop.toString();
if (intCurrTop<=200) {
enableShow = 'disabled'; //prevent showBio() function from working at the same time
setClipValues(layerName,strCurrTop,"500","200","0");
setTimeout('hideBio("' + layerName + '")',40);
}
else {
enableShow = 'enabled';
}
}
}


/*  *****  For 456px by 320px layers  *****  */
function showBio2(layerName) {
if (enableShow == 'enabled') {
var strCurrTop = getClipValueTop(layerName);
var intCurrTop = parseInt(strCurrTop);
intCurrTop -= 2;
strCurrTop = intCurrTop.toString();
if (intCurrTop>=0) {
enableHide = 'disabled'; //prevent hideBio() function from working at the same time
setClipValues(layerName,strCurrTop,"456","320","0");
setTimeout('showBio2("' + layerName + '")',10);
}
else {
enableHide = 'enabled';
}
}
}

/*  *****  For 456px by 320px layers  *****  */
function hideBio2(layerName) {
if (enableHide == 'enabled') {
var strCurrTop = getClipValueTop(layerName);
var intCurrTop = parseInt(strCurrTop);
intCurrTop += 2;
strCurrTop = intCurrTop.toString();
if (intCurrTop<=320) {
enableShow = 'disabled'; //prevent showBio() function from working at the same time
setClipValues(layerName,strCurrTop,"456","320","0");
setTimeout('hideBio2("' + layerName + '")',10);
}
else {
enableShow = 'enabled';
}
}
}
/*  ******************************************************************************** */


/*  ********** THESE FUNCTIONS ARE USED TO CHANGE THE FILE THAT A MEDIA PLAYER PLAYS ********** */
/*  **********   NEEDED BECAUSE MANY POPULAR BROWSERS NO LONGER SUPPORT CONTROLLING  ********** */
/*  **********          MEDIA PLAYERS DIRECTLY THROUGH JAVASCRIPT OR VBSCRIPT        ********** */

// Causes a media player embedded in a layer to stop playing
//  by erasing the contents of the layer
function stopPlayer(layerName){
var newText= '';

if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=newText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(newText);
   x.style.document.close();
}
}

// Create a text string which will create a Windows Media Player for playing audio-only clips
function writeWPlayer(layerName,clipName,mute){
// use only the embed tag; some Iexplorers don't recognize <object> tag when using innerHTML
var newText=
//  '<object id="Player" classid="clsid:22D6f312-B0F6-11D0-94AB-0080C74C7E95"'+
//     ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"'+
//     ' standby="Loading Microsoft Windows Media Player components..."'+
//     ' type="application/x-oleobject"'+
//     ' width="320" height="70">'+
//  '<param name="FileName" value="' + clipName + '" />'+
//  '<param name="AutoStart" value="true" />'+
//  '<param name="ShowControls" value="1" />'+
//  '<param name="ShowDisplay" value="0" />'+
//  '<param name="ShowStatusBar" value="1" />'+
//  '<param name="AutoSize" value="1" />'+
  '<embed type="application/x-mplayer2"'+
     ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/"'+
     ' src="' + clipName + '"'+
     ' filename="' + clipName + '"'+
     ' AutoStart="1"'+
     ' name="Player"'+
     ' width="320" height="70"'+
     ' ShowControls="1"'+
     ' ShowDisplay="0"'+
     ' ShowStatusBar="1">'+
  '</embed>';
//  '</object>';

if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=newText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(newText);
   x.style.document.close();
}

}

// Create a text string which will create a RealPlayer for playing audio-only clips
function writeRPlayer(layerName,clipName){
var newText=
  // The RealPlayer controls
  '<object id="videocontrolActiveX"'+
     ' classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"'+
     ' width="320" height="70">'+
  '<param name="src"       value="' + clipName + '" />'+
  '<param name="controls"  value="ControlPanel,StatusBar" />'+
  '<param name="console"   value="Video" />'+
  '<param name="autostart" value="true" />'+
  '<embed src="' + clipName + '"'+
    ' type="audio/x-pn-realaudio-plugin" width="320" height="70"'+
    ' controls="ControlPanel,StatusBar" console="Video" name="videocontrolJavaplugin" autostart="true">'+
  '</embed>'+
  '</object>';


if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=newText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(newText);
   x.style.document.close();
}
}


// Create a text string which will create a RealPlayer for showing videos
function writeRVideo(layerName,clipName){
var newText=
  // The video window 
  '<object id="videoscreenActiveX"'+
     ' classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"'+
     ' width="320" height="240">'+
  '<param name="src"       value="' + clipName + '" />'+
  '<param name="controls"  value="ImageWindow" />'+
  '<param name="console"   value="Video" />'+
  '<param name="autostart" value="true" />'+
  '<embed src="' + clipName + '"'+
    ' type="audio/x-pn-realaudio-plugin" width="320" height="240"'+
    ' controls="ImageWindow" console="Video" name="videoscreenJavaplugin" autostart="true">'+
  '</embed>'+
  '</object>'+

  '<br />'+

  // The RealPlayer controls
  '<object id="videocontrolActiveX"'+
     ' classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"'+
     ' width="320" height="70">'+
  '<param name="src"       value="' + clipName + '" />'+
  '<param name="controls"  value="ControlPanel,StatusBar" />'+
  '<param name="console"   value="Video" />'+
  '<param name="autostart" value="true" />'+
  '<embed src="' + clipName + '"'+
    ' type="audio/x-pn-realaudio-plugin" width="320" height="70"'+
    ' controls="ControlPanel,StatusBar" console="Video" name="videocontrolJavaplugin" autostart="true">'+
  '</embed>'+
  '</object>';


if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=newText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(newText);
   x.style.document.close();
}
}


// Create a text string which will create a Flash Player for playing mp3 audio clips
function playFlashAudio(layerName,clipName) {
var newText='<object id="FlashPlayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"'
    + ' width="350" height="40">'
    + '<param name="allowScriptAccess" value="sameDomain" />'
    + '<param name="movie" value="' + clipName + '" />'
    + '<param name="loop" value="false" />'
    + '<param name="quality" value="high" />'
    + '<param name="bgcolor" value="#000000" />'
    + '<embed src="' + clipName + '"'
    + ' loop="false"'
    + ' quality="high"'
    + ' bgcolor="#000000" '
    + ' allowScriptAccess="sameDomain"'
    + ' swLiveConnect="true"'
    + ' name="FlashPlayer"'
    + ' width="350" height="40"'
    + ' type="application/x-shockwave-flash"'
    + ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
    + '<\/embed>'
    + '<\/object>';

if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=newText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(newText);
   x.style.document.close();
}
}


// Create a text string which will create a Flash Player for playing videos
function writeFlash(layerName,clipName){
var newText='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + 'width="330" height="310"'
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<param name="movie" value="' + clipName + '" />'
    + '<param name="loop" value="false" />'
    + '<param name="quality" value="high" />'
    + '<param name="bgcolor" value="#000000" />'
    + '<embed src="' + clipName + '" quality="high" bgcolor="#000000" '
    + 'width="330" height="310" name="detectiontest" align="middle"'
    + 'play="true"'
    + 'loop="false"'
    + 'quality="high"'
    + 'allowScriptAccess="sameDomain"'
    + 'type="application/x-shockwave-flash"'
    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
    + '<\/embed>'
    + '<\/object>';


if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=newText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(newText);
   x.style.document.close();
}
}



// Create a text string which will create an Apple Quick Time Player
function writeQTPlayer(layerName,clipName){
var newText=
  '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'+
     ' codebase="http://www.apple.com/qtactivex/qtplugin.cab"'+
     ' width="320" height="256">'+
  '<param name="src" value="' + clipName + '">'+
  '<param name="AutoPlay" value="true">'+
  '<param name="Controller" value="true">'+
  '<param name="bgcolor" value="#343434">'+
  '<param name="scale" value="ToFit">'+
  '<embed src="' + clipName + '"'+
    ' width="320" height="256" scale="ToFit" bgcolor="#343434"'+
    ' type="video/quicktime"'+
    ' pluginspage="http://www.apple.com/quicktime/download/"'+
    ' autoplay="true"'+
    ' controller="true">'+
  '</embed>'+
  '</object>';

if (document.getElementById || document.all)
{
   var x = new getObj(layerName);
   x.obj.innerHTML=newText;
}

else if (document.layers)
{
   var x = new getObj(layerName);
   x.style.document.open();
   x.style.document.write(newText);
   x.style.document.close();
}
}





/*  ******************************************************************************************* */