	
// 001 - onFocus clear search field

function clearfield(){
if (document.searchform.Terms.value == " Search")
	document.searchform.Terms.value = "";
}

// 002 - pops locally-sized/spec'd window

function dynaPop(url,name,properties) {
  popupWin = window.open(url,name,properties);
}

function dynaPoppyDoodle(url,name) {
  popupWin = window.open(url,name,'menubar,toolbar,location,status,scrollbars,resizable');
}

// 003 - pops sized/spec'd glossary window

function gPop(url,name,properties) {
  popupWin = window.open(url,'glossary','scrollbars,height=300,width=400');
}

// 004 - pops sized/spec'd tools window

function tPop(url,name,properties) {
  popupWin = window.open(url,'tools','scrollbars,height=400,width=500');
}

// 005 - colin thingy

function dynaSaur(url) {
  parent.location=url;
}

// 006 - Close n Load //.href = '/_apps/inforeq.php';
function goTo(url){
	window.opener.location.href(url)
	window.close();
	}

// 007 - Swap images
function Permut (flag,img) {
   if (document.images) {
        if (document.images[img].permloaded) {
            if (flag==1) document.images[img].src = document.images[img].perm.src
            else document.images[img].src = document.images[img].perm.oldsrc
        }
   }
}
function preloadPermut (img,adresse) {
   if (document.images) {
        img.onload = null;
        img.perm = new Image ();
        img.perm.oldsrc = img.src;
        img.perm.src = adresse;
        img.permloaded = true;
   }
}

// 008 - Validate IP
function checkField(entry) {
	// We're going to assume this is from an IP field.
	if (!isValidIPAddress(entry)) {
		alert ('Please form IP addresses as follows: example: xxx.xx.xx.x')
	}
}

function isValidIPAddress(ipaddr) {
   var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
   if (re.test(ipaddr)) {
      var parts = ipaddr.split(".");
      if (parseInt(parseFloat(parts[0])) == 0) { return false; }
      for (var i=0; i<parts.length; i++) {
         if (parseInt(parseFloat(parts[i])) > 255) { return false; }
      }
      return true;
   } else {
      return false;
   }
}

