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);
}


// =================================================
// 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 showRemote() {
  self.name = "main"; // names current window as "main"
  
  var windowprops = "toolbar=0,location=0,directories=0,status=0, " +
  "menubar=0,scrollbars=yes,resizable=yes,width=610,height=300";
  
  OpenWindow = window.open("pAdditionalProducts.aspx", "remote", windowprops); // opens remote control
}

function bigScreen(thePAGE) {
	self.name = "main"; // names current window as "main"
	window.open(thePAGE, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=yes,width=500,height=275,scrollbars=yes');
}

function submenu_onshow() {
  this.className='navcopy2over';
}

function submenu_onhide() {
  this.className='navcopy2'
}

function ValidateForm(form) {

	isValid = true;
	for(i = 0; i < form.elements.length; i++) {
		if(form.elements[i].name.substring(0, 3) == "req") {
			if(form.elements[i].value.length == 0) {
				form.elements[i].style.background = "#A3BBD4";
				isValid = false;
			}
			else {
				form.elements[i].style.background = "#FFFFFF`";
			}
		}
	}
	return isValid;
}


var lastDiv = "OVDiv";
function div_visibility(div_name) {
	if (div_name == lastDiv) {
	  return;
	}
	var lastDivObj = MM_findObj(lastDiv);
	if (lastDivObj) {
	  lastDivObj.style.display = "none";
	}
	var currDivObj = MM_findObj(div_name);
	if (currDivObj) {
	  currDivObj.style.display = "block";
	}
	lastDiv = div_name;
}
