function showLayer(p)
{
	element = MM_findObj(p);
	if (element.style.display == "none")
	{
		element.style.display = "";
		element.style.visibility = "visible";
	}
	else
	{
		element.style.display ="none";
		element.style.visibility = "hidden";
	}
}

function swapSection(p_id) {
	var o_primary = MM_findObj(p_id);
	var o_inactive = MM_findObj(p_id + "_inactive");
	if (o_primary && o_inactive) {
		if (o_primary.style.display == "none") {
			o_primary.style.display = "block";
			o_inactive.style.display = "none";
		} else {
			o_primary.style.display = "none";
			o_inactive.style.display = "block";
		}
	}
}
function MM_displayLayers() {
	for (var i=0; i<(arguments.length-1); i=i+2) {
		var l=arguments[i];var b=arguments[i+1];var o=MM_findObj(l);
		if (o) o.style.display=(b)?"":"none";
	}
}
function resetForm(p_frm) {
	var o_frm = MM_findObj(p_frm);
	if (o_frm) o_frm.reset();
	return false;
}
function submitForm(p_frm) {
	var o_frm = MM_findObj(p_frm);
	if (o_frm) o_frm.submit();
	return false;
}
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;
}
// set all checkboxes in the form to the value of the controlling checkbox (p_obj)
function changeAll(p_obj, p_id) {
	var val = p_obj.checked;
	var frm = p_obj.form;
	for (var i=0; i < frm.length; i++) {
		if (frm[i].type == "checkbox" && (typeof(p_id) == "undefined" || (typeof(frm[i].id) != "undefined" && frm[i].id.indexOf(p_id) >= 0))) {
			frm[i].checked = val;
		}
	}
}
// expand or collapse menus
function heirarchyInit(p_expand, p_collapse) {
	document.expandHeirarchyImage = p_expand;
	document.collapseHeirarchyImage = p_collapse;
}
function heirarchy(p_key) {
	var i = MM_findObj("icon_" + p_key);
	var d = MM_findObj("div_" + p_key);
	if (d != undefined) {
		var v = (d.style.display == "none");
		d.style.display = (v) ? "" : "none";
		i.src = (v) ? document.collapseHeirarchyImage : document.expandHeirarchyImage;
	}
}

function popup(u) {
	window.open(u);
}
function popupFlash(oid,w,h) {
	if (navigator.userAgent.indexOf("MSIE")>=0) w=w+20;
	props = 'toolbar=no, location=no, status=yes, resizable=no, scrollbars=yes, width='+w+', height='+h;
	x = window.open('popup.cfm?oid='+oid, 'childWindow', props); 
	x.focus();
}


// =================================================
// Find object location in pixels as array [x,y]
// =================================================
isgecko = (navigator.userAgent.indexOf("Gecko")>=0);
isexplorer = (navigator.userAgent.indexOf("MSIE")>=0);
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;
	var self = true;
	while (obj.offsetParent) {
		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;
		if (isexplorer && !self) {
			// fix for IE - some CSS borders cause offset
			curleft += obj.clientLeft;
			curtop += obj.clientTop;
		}
		obj = obj.offsetParent;
		self = false;
	}
	return [curleft,curtop];
}

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_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];}
}

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;
}

// =================================================
// Nav image Swap with submenu
// =================================================

function navImageShow () {
	var img = this.getElementsByTagName("IMG")[0];
	if (img) {
		img.src = "images/" + img.name + "_over.gif";
	}
}
function navImageHide () {
	var img = this.getElementsByTagName("IMG")[0];
	if (img) {
		img.src = "images/" + img.name + ".gif";
	}

}

function subnavHover (src) {
	if (typeof(src) == "undefined") src = this;
	src.className = "over_submenu";
}
function subnavUnhover (src) {
	if (typeof(src) == "undefined") src = this;
	src.className = "";
}


<!-- Image swap function -->
function fue_swap(o, u) {
	if (o && o.childNodes.length) {
		var img=o.childNodes[0];
		// find img tag
		while (img && (typeof(img.tagName) != "string" || img.tagName != "IMG")) {
			img = img.nextSibling;
		}
		if (img) img.src = u;
	}
}


function gotoSelectedTopic() {
	var ob_cbo = MM_findObj('cboTopic')
	if (ob_cbo != null) {
		if (ob_cbo.value == "") alert("Please select a topic!");
		else
			document.location.href = "active_living_topic.cfm?oid=" + ob_cbo.value;
	}		
}

// extend String class for trim
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
function checkEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		return true;
    }else{   
		return false;
    }
}


// replace image child of A tag
function toggleChildImage(obj, on_img, off_img) {
	if (!obj) return;
	var o_img, imgUri, imgFile;
	var reg = new RegExp("[^/]+$");
	
	if (obj && typeof(on_img) != 'undefined' && typeof(off_img) != 'undefined') {
		o_img = obj.firstChild;
		if (o_img && o_img.tagName == 'IMG') {
			imgFile = o_img.src.match(reg);
			if (imgFile != null && imgFile != '') {
				imgUri = o_img.src.replace(imgFile,'');
				if (imgFile == off_img) {
					o_img.src = imgUri + on_img;
				}
				else {
					o_img.src = imgUri + off_img;
				}
			}
		}
	}
}










