//setup onload function
if (typeof window.addEventListener != 'undefined') {
	window.addEventListener('load', fncOnload, false);
	window.addEventListener('resize', fncOnresize, false);
}
else if (typeof document.addEventListener != 'undefined') {
	document.addEventListener('load', fncOnload, false);
	document.addEventListener('resize', fncOnresize, false);
}
else if (typeof window.attachEvent != 'undefined') {
	window.attachEvent('onload', fncOnload);
	window.attachEvent('onresize', fncOnresize);
}
else {
	if(typeof window.onload == 'function') {
		var onload_existing = onload;
		var onresize_existing = onresize;
		window.onload = function() {
			onload_existing();
			fncOnload();
		};
		window.onresize = function() {
			onresize_existing();
			fncOnresize();
		};
	}
	else {
		window.onload = fncOnload;
		window.onresize = fncOnresize;
	}
}

function fncOnresize() {
  fncSetLayout();
}

function fncOnload() {
  fncSetLayout();
}

function fncSetLayout() {
  if (document.getElementById("resizeDiv") && document.getElementById("footer") && document.getElementById("idBottom")) {
    var oSidebar = document.getElementById("resizeDiv");
    var oFooter = document.getElementById("footer");
    var oBottom = document.getElementById("idBottom");
    
    oFooter.style.visibility = "hidden";
    oSidebar.style.height = "auto";
    
    var intSidebarTop = fncGetAbsoluteY(oSidebar);
    var intFooterHeight = fncGetHeight(oFooter);
    var intBottom = fncGetAbsoluteY(oBottom);
    
    oSidebar.style.height = "auto";
    oSidebar.style.height = (intBottom-intSidebarTop-intFooterHeight) + "px";
    oFooter.style.visibility = "visible";
  }
}


function fncSetBGColor(oElement, strColor) {
  if (oElement.style) {
    oElement.style.backgroundColor = strColor;
  }
}

function fncGoToURL(strURL) {
  document.location.href = strURL;
}



function fncGetAbsoluteX(oElement) {
  // Utility function to get the absolute X-coordinate of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
    var intCoords = {x: 0};
    while (oElement) {
      intCoords.x += oElement.offsetLeft;
      oElement = oElement.offsetParent;
    }
    return intCoords.x;
  }
}
function fncGetAbsoluteY(oElement) {
  // Utility function to get the absolute Y-coordinate of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
    var intCoords = {y: 0};
    while (oElement) {
      intCoords.y += oElement.offsetTop;
      oElement = oElement.offsetParent;
    }
    return intCoords.y;
  }
}

function fncGetWidth(oElement) {
  // Utility function to get the width of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
  	if (oElement.style.pixelWidth) {
  		return oElement.style.pixelWidth;
  	}
    if (oElement.style.width) {
        return oElement.style.width;
    } 
    return oElement.offsetWidth;
  }
}
function fncGetHeight(oElement) {
  // Utility function to get the height of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
  	if (oElement.style.pixelHeight) {
  		return oElement.style.pixelHeight;
  	}
    if (oElement.style.height) {
        return oElement.style.height;
    }
    return oElement.offsetHeight;
  }
}

function fncAddClass(oElement, strClassName) {
  if (typeof(oElement) == "object") {
    if (oElement.className) {  
      var strCurrentClassName = oElement.className;
      if (strCurrentClassName.indexOf(strClassName) < 0) {
        if (strCurrentClassName.length > 1) {
          strClassName = " " + strClassName;
        }        
        oElement.className = strCurrentClassName + strClassName;
      }
    }
    else {
      oElement.className = strClassName;
    }
  }
}

function fncRemoveClass(oElement, strClassName) {
  if (typeof(oElement) == "object" && strClassName.length > 0) {
    if (oElement.className) {
      var strCurrentClassName = oElement.className;
      if (strCurrentClassName.indexOf(strClassName) >= 0) {
        strNewClassName = fncRemoveClassRecursive(" " + strCurrentClassName + " ", " " + strClassName + " ");
        if (strNewClassName.indexOf(" ") == 0) { strNewClassName = strNewClassName.substring(1); }
        if (strNewClassName.lastIndexOf(" ") == strNewClassName.length-1) { strNewClassName = strNewClassName.substring(0,strNewClassName.length-1); }
        oElement.className = strNewClassName;
      }
    }
  }
}

function fncRemoveClassRecursive(strSource, strSubstrToRemove) {
  var intIndex = strSource.indexOf(strSubstrToRemove);
  var strReturn = "";
  if (intIndex == -1) return strSource;
  strReturn += strSource.substring(0,intIndex) + " " + fncRemoveClassRecursive(strSource.substring(intIndex + strSubstrToRemove.length), strSubstrToRemove);
  return strReturn;
}


function addEvent(element, type, handler) {
	// assign each event handler a unique ID
	if (!handler.$$guid) handler.$$guid = addEvent.guid++;
	// create a hash table of event types for the element
	if (!element.events) element.events = {};
	// create a hash table of event handlers for each element/event pair
	var handlers = element.events[type];
	if (!handlers) {
		handlers = element.events[type] = {};
		// store the existing event handler (if there is one)
		if (element["on" + type]) {
			handlers[0] = element["on" + type];
		}
	}
	// store the event handler in the hash table
	handlers[handler.$$guid] = handler;
	// assign a global event handler to do all the work
	element["on" + type] = handleEvent;
};
// a counter used to create unique IDs
addEvent.guid = 1;

function removeEvent(element, type, handler) {
	// delete the event handler from the hash table
	if (element.events && element.events[type]) {
		delete element.events[type][handler.$$guid];
	}
};

function handleEvent(event) {
	var returnValue = true;
	// grab the event object (IE uses a global event object)
	event = event || fixEvent(window.event);
	// get a reference to the hash table of event handlers
	var handlers = this.events[event.type];
	// execute each event handler
	for (var i in handlers) {
		this.$$handleEvent = handlers[i];
		if (this.$$handleEvent(event) === false) {
			returnValue = false;
		}
	}
	return returnValue;
};

function fixEvent(event) {
	// add W3C standard event methods
	event.preventDefault = fixEvent.preventDefault;
	event.stopPropagation = fixEvent.stopPropagation;
	return event;
};
fixEvent.preventDefault = function() {
	this.returnValue = false;
};
fixEvent.stopPropagation = function() {
	this.cancelBubble = true;
};



/*Script added for show and hide of Div*/

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Justin Barlow | http://www.netlobo.com */

function toggleLayer(whichLayer) {
  var elem, vis;
  if(document.getElementById) // this is the way the standards work
    elem = document.getElementById(whichLayer);
  else if(document.all) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if(document.layers) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

/*Javascript for GO to Page*/
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

/* show hide div */
function change() {

if (document.getElementById("showhide").style.display == "none") {

document.getElementById("showhide").style.display = "inline";

document.getElementById("thetext").innerHTML = "Pet Tracker";

} else {

document.getElementById("showhide").style.display = "none";

document.getElementById("thetext").innerHTML = "Pet Tracker";

}

}

function change_wristband() {

if (document.getElementById("showhide1").style.display == "none") {

document.getElementById("showhide1").style.display = "inline";

document.getElementById("thetext1").innerHTML = "UHF Wristband";

} else {

document.getElementById("showhide1").style.display = "none";

document.getElementById("thetext1").innerHTML = "UHF Wristband";

}

}
//-->
/*Javascript for GO to Page*/