var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"

function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 20  // default, pixels from screen left to window left
  var d_winTop = 20   // default, pixels from screen top to window top
  var ran_unrounded=Math.random()*999999;
  var ran_number=Math.round(ran_unrounded);
  winName = "popWin" + ran_number; //unique name for each pop-up window

  if (openPopWin.arguments.length >= 4)  // any additional features?
    winFeatures = "," + winFeatures
  else
    winFeatures = ""
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
  else
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
  popWin = window.open(winURL, winName, "width=" + winWidth
           + ",height=" + winHeight + winFeatures)
  }


function closePopWin(){    // close pop-up window if it is open
  if (navigator.appName != "Microsoft Internet Explorer"
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close()
  }
function getLocation(winWidth, winHeight, winLeft, winTop){
  return ""
  }

function getLocation(winWidth, winHeight, winLeft, winTop){
  var winLocation = ""
  if (winLeft < 0)
    winLeft = screen.width - winWidth + winLeft
  if (winTop < 0)
    winTop = screen.height - winHeight + winTop
  if (winTop == "cen")
    winTop = (screen.height - winHeight)/2 - 20
  if (winLeft == "cen")
    winLeft = (screen.width - winWidth)/2
  if (winLeft>0 & winTop>0)
    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft
                + ",screenY=" + winTop + ",top=" + winTop
  else
    winLocation = ""
  return winLocation
  }


function createWindow(what) {
    var URL = what.URL.value;

    var windowName = what.windowName.value;

    var features =
        'width='        + what.width.value +
        ',height='      + what.height.value +
        ',directories=' + (what.directories.checked - 0) +
        ',location='    + (what.location.checked - 0) +
        ',menubar='     + (what.menubar.checked - 0) +
        ',scrollbars='  + (what.scrollbars.checked - 0) +
        ',status='      + (what.status.checked - 0) +
        ',toolbar='     + (what.toolbar.checked - 0) +
        ',resizable='   + (what.resizable.checked - 0);

    window.open (URL, windowName, features);
}

function bookmark() {

		// If it's Internet Explorer, use automatic link
		if (document.all){
		  document.write('<a class="black" href="javascript:history.go(0);" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.crossrhythms.co.uk\');">');
		  document.write('<img alt="Make Cross Rhythms your home page" border="0" src="/images/header_links/MAKE_CR_YOUR_HOME_PAGE.gif" width="149" height="10"><' + '/a>');
		}

		// If it's Netscape 6, tell user to drag link onto Home button
		else if (document.getElementById){
		  document.write('<' + 'br /><span style="font-size: 8px"><a class="black" style="text-decoration: none;" href="http:///www.crossrhythms.co.uk">DRAG TO HOME TO SET HOMEPAGE<' + '/a></span>');
		}

		// If it's any other browser, for which I don't know the specifications of, give up.
		else {
		  document.write('');
		}


		function urlencode(str) {
     		return unescape(str.replace(/\+/g, " "));
		}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

	function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
     while (theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
      theForm[z].checked = theElement.checked;
      z++;
     }
    }