// Miscellaneous support functions

// Swap two images (rollover effect)
function rollover(img,idx) {
  if (document.images) {
    document.images[idx].src = eval(img + ".src");
  }
}

// Verifies if entry is Numeric
function IsNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
}

 // Verifies validity of e-mail address, passed as the field, not the value
function isEmail(fld) {
    var str = fld.value;
    var pat = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(pat)) {
        return false;
    }
    return true;
}

// Hides a div element content via the div id passed as parameter
function HideContent(d) {
    if(d.length < 1) return;
    document.getElementById(d).style.display = "none";
}

// Shows a div element content via the div id passed as parameter
function ShowContent(d) {
    if(d.length < 1) return;
    document.getElementById(d).style.display = "block";
}

// Replaces content of one div (d2) with another (d1) (both passed as parameters)
function SwapDiv(d1, d2) {
    if((d1.length < 1) || (d2.length < 1)) return;
    document.getElementById(d2).innerHTML = document.getElementById(d1).innerHTML;
}
