//
// Global Variables
//
var popupwin=null;
var emaildomain="mydogtess.com";

//
// Function to create a popup window
//
function popup(url,options) {
   if (!options) options="width=610,height=500,scrollbars=yes,resizable=yes";
   popupwin = window.open(url,"popupwin",options);
   popupwin.focus();
   return false;
}

//
// Function to toggle display of a panel
//
function togglepanel(elm) {
	var obj = document.getElementById(elm);
	if (!obj) return;
	obj.style.display = (obj.style.display=="none")?"":"none";
	return false;
}
function toggletooltip(elm) {
   // Get reference to hidden layer
	var obj = document.getElementById(elm);
	if (!obj) return;
	obj.style.visibility = (obj.style.visibility=="hidden")?"visible":"hidden";
   return false;
}

//
// Function to toggle all panels on page starting with <stub>
//
var lasttoggle=0;
function toggleallpanels(stub) {
   lasttoggle=(lasttoggle==1)?0:1;
   var elms = document.getElementsByTagName("DIV");
   for (var i=0;i<elms.length;i++) {
         var elm=elms[i];
         if (elm.id && elm.id.indexOf(stub)==0)
            elm.style.display = (lasttoggle)?"":"none";
   }
   return false;
}

//
// De-jumble email addresses
//
function decryptemail() {
   var pattern = /^mail:([^\?]+)(\?.+)?$/i;
   var elms = document.getElementsByTagName("A");
   for (var i=0;i<elms.length;i++) {
      var elm=elms[i];
		var str = new String(elm.href);
		if (str.match(pattern)) {
		   elm.href = str.replace(pattern,"mailto:$1@"+emaildomain+"$2");
		   if (elm.hasChildNodes) {
		      var node=elm.childNodes[0];
		      if(node.nodeValue) node.nodeValue = node.nodeValue.replace(pattern,"$1@"+emaildomain);
		   }
		}
	}
}

// Send alert if a page has not been loaded in a half an hour
function alertSessionTimeout() {
   alert("Hi there! Your last communication with the server\n" + 
      "was around 30 minutes ago. Please take a moment to stop\n" + 
      "and save your work now before your session expires.")
}
