var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var NS6 = (document.getElementById && !document.all) ? true : false;
var color = '';
var selected = '';

// Popup ACC TV steam
function stream(id, type) {
	if (type == 0) {
	
	  var w = 315;
	  var h = 582;
	  var url ='http://www.acctv.com.au/stream_wrap.asp'
	  }
	if (type == 1) {
	
	  var w = 315;
	  var h = 582;
	  var url ='http://www.acctv.com.au/stream_wrap.asp'
	  }
	  
	  var l = (screen.availWidth-10 - w) / 2;
  	  var t = (screen.availHeight-20 - h) / 2;
  	  window.open(url+'?intid=' + id,'Stream' , 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=' + w + ',height=' + h + ',left=' + l + ',top=' + t);

}

// Launch E-News Registration
function openEnewsRego() {
  MM_openBrWindow('pu_enews.asp', 'Enews', 'status=no,width=350,height=400');
}
// Display Bible Verses
function openBibleVerse(strPassage) {
  strPassage.replace(":", "+");
  strPassage.replace(" ", "+");
  newWindow = window.open("http://www.biblegateway.com/cgi-bin/bible?language=english&version=NIV&passage=" + strPassage, "winBibleVerse", "width=550,height=400,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,resizable=yes");
}

// Drop down menus (with timeout delay)
var arrTimer = [];
var intDelay = 300;

function PJ_showMenu(id){
  PJ_hideInactiveMenus(id);
  if (arrTimer[id]) arrTimer[id] = window.clearTimeout(arrTimer[id])
  MM_showHideLayers(id, '', 'show');
}

function PJ_hideMenu(id){
  arrTimer[id] = window.setTimeout("PJ_timeoutMenu('" + id + "')", intDelay);
}

function PJ_hideInactiveMenus(id){
  for (menu in arrTimer) {if (id != menu) MM_showHideLayers(menu, '', 'hide');}
}

function PJ_timeoutMenu(id){
  MM_showHideLayers(id, '', 'hide');
}

// Changes the background image of a cell.
function changeBGImage(id, imageName)
{
  if (IE5 || NS6) {
    document.getElementById(id).style.background = 'url(' + imageName +')';
  }
  else if (IE4) {
    document.all[id].style.backgroundImage = 'url(' + imageName +' )';
  }
}

// Changes the background color of a cell.
function tdOver(id, col, clicked) {
  if (IE5 || NS6) {
    window.color = window.document.getElementById(id).style.backgroundColor;
    window.document.getElementById(id).style.backgroundColor = col;
  }
  else if (IE4) {
    window.color = window.document.all[id].style.background;
    window.document.all[id].style.background = col;
  }
  if (clicked) window.selected = id;
}

function tdOut(id, col) {
  if (window.selected != id) {
    if (IE5 || NS6) window.document.getElementById(id).style.backgroundColor = window.color;
    else if (IE4) window.document.all[id].style.background = window.color;
  } else {
    if (IE5 || NS6) window.document.getElementById(id).style.backgroundColor = col;
    else if (IE4) window.document.all[id].style.background = col;
  }
}

function del_confirm(itm, qs, tbl) {//v1
  if (confirm("Are you sure you want to delete " + itm + " from " + tbl)) window.location.href = window.location.pathname+"?"+qs;
}

function textareaLimiter(field, maxlimit) {
  if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
}

function confirmPassword(pwd1, pwd2) {
  if (!document.MM_returnValue) {
    return false;
  } else {
    document.MM_returnValue = (pwd1 == pwd2);
    if (!document.MM_returnValue) alert("Your password must match your confirmation password.");
  }
}