function fIsHex(s,len){
		var regex="^[0-9A-Fa-f]{"+len+"}$";
		return (s.match(regex) != null);
}

function fDropVODev_OnChange()
{
	trVOUser0.style.display = "none";
	trVOUser1.style.display = "none";
	trVOUser2.style.display = "none";
	trVOUser3.style.display = "none";
	var bDVOther  = document.getElementById("dropVODev").value == "DVOther";
	if (!bDVOther) return;
	if (document.getElementById("dropVOQty").value != "1") {
	  alert("Quantity must be one for user-supplied device");
	  document.getElementById("dropVODev").value = "";
		return;
	}
	document.getElementById("trVOUser0").style.display = "block";
	document.getElementById("trVOUser1").style.display = "block";
	document.getElementById("trVOUser2").style.display = "block";
	document.getElementById("trVOUser3").style.display = "block";
}

function fDropVOQty_OnChange()
{
	var bDVOther  = document.getElementById("dropVODev").value == "DVOther";
	if (!bDVOther) return;
  alert("Quantity must be one for user-supplied device");
  document.getElementById("dropVOQty").value = "1";
}

function fValVOUser(src,args)
{
	args.IsValid = (document.getElementById("dropVODev").value != "DVOther" 
		|| document.getElementById("dropVOUser").value != ""); 
}

function fIsHex(s,len)
{
	s = s.replace(/[\-. :]/g, "");
	var slen = "";
	if (len>0) slen = "{"+len+"}"; 
	var regex = "^[0-9A-Fa-f]"+slen+"$";
	return (s.match(regex) != null);
}

function fReqTxtSNum(src,args)
{
	args.IsValid = (document.getElementById("dropVODev").value != "DVOther" );
}

function fReqTxtMAC(src,args)
{
	args.IsValid = (document.getElementById("dropVODev").value != "DVOther" 
		|| document.getElementById("txtMAC").value != "");
}

function fValTxtMAC(src,args)
{
	var txtMAC=document.getElementById("txtMAC").value;
	args.IsValid = (txtMAC == "" || fIsHex(txtMAC,12));
}

function KeyPress(what,e,max,action) {
	if (document.layers) {
		if (e.target.value.length >= max)
			eval(action);
	}
	else if (document.all) {
		if (what.value.length > (max-1))
			eval(action);
	}
}

function IsPopupBlocker() {
	var strNewURL = "Dummy.htm"
	var Strfeature = "" ;
	var WindowOpen = window.open(strNewURL,"MainWindow",Strfeature);
	try{
		var obj = WindowOpen.name;
		WindowOpen.close();
		//page must have hidden field "hiddenPopupsBlocked"
		findElementById("hiddenPopupsBlocked").value = "no";
	} 
	catch(e){ 
		//alert("System has been blocked by POP-UP BLOCKER.\nPlease disable the POP-UP BLOCKER and try again\nor\nPlease contact your system administrator. ");
		findElementById("hiddenPopupsBlocked").value = "yes";
	}
}


