var win;
var win2;
var win3;
var win4;
var win5;
var win6;
var win7;

function MM_openBrWindow(theURL) {
  var w=640;
  var h=480;
  if (window.screen) {
    w = parseInt(window.screen.availWidth - 5);
    h = parseInt(window.screen.availHeight - 50);
  }
  
  win=window.open(theURL,'CBCDunn_Win','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width='+w+',height='+h+',top=0,left=0');
  win.focus();
}

function PlayVideo(theURL) {
  win2=window.open('/videos/GetBandwidth.asp?pg=' + theURL,'CBC_VideoWin','toolbar=0,location=0,directories=0,status=0,statusbar=0,menubar=0,scrollbars=0,resizable=0,width=350,height=350,top=0,left=0');
  win2.focus();
}

function EventDetail(theURL) {
  win3=window.open(theURL,'CBCDunn_Event_Win','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=520,height=350,top=0,left=0');
  win3.focus();
}

function HelpWindow(theURL) {
  win4=window.open(theURL,'CBCDunn_Help_Win','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=365,top=0,left=0');
  win4.focus();
}

function HelpWindow2(theURL) {
  win5=window.open(theURL,'CBCDunn_Help_Win2','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=520,height=425,top=0,left=0');
  win5.focus();
}

function MissionaryDetail(theURL) {
  win6=window.open(theURL,'CBCDunn_missionary_Win','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=520,height=480,top=0,left=0');
  win6.focus();
}

function SongDetail(theSong) {
  var theURL='/SongDetail.asp?song=' + theSong;
  win7=window.open(theURL,'CBCDunn_Song_Win','toolbar=no,location=no,locationbar=no,personalbar=no,directories=no,status=no,statusbar=no,menubar=no,scrollbars=no,resizable=no,width=250,height=280,top=0,left=0');
  win7.focus();
}

function WM_preloadImages() {

/*
WM_preloadImages()
Loads images into the browser's cache for later use.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: nadav@wired.com

Usage: WM_preloadImages('image 1 URL', 'image 2 URL', 'image 3 URL', ...);
*/

  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}

function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  /*
    WM_imageSwap()
    Changes the source of an image.

    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Shvatz
    Author Email: shvatz@wired.com

    Usage: WM_imageSwap(originalImage, 'newSourceUrl');

    Requires: WM_preloadImages() (optional, but recommended)
    Thanks to Ken Sundermeyer (ksundermeyer@macromedia.com) for his help
    with variables in ie3 for the mac. 
    */

  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
