function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function CalculateTotal(frm) {
    var order_total = 0

    // Run through all the form fields
    for (var i=0; i < frm.elements.length; ++i) {

        // Get the current field
        form_field = frm.elements[i]

        // Get the field's name
        form_name = form_field.name

        // Is it a "product" field?
        if (form_name.substring(0,4) == "Quant") {

            // If so, extract the price from the name
            item_price = parseFloat(form_name.substring(form_name.lastIndexOf("_") + 1))

            // Get the quantity
            item_quantity = parseInt(form_field.value)

            // Update the order total
            if (item_quantity >= 0) {
                order_total += item_quantity * item_price
            }
        }
    }

    // Display the total rounded to two decimal places
    frm.TOTAL.value = round_decimals(order_total, 2)
}

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}
function CheckSelection() {
    var selection = document.frmLinkList.FileName.options[document.frmLinkList.FileName.selectedIndex].value
    if (selection != "None") {
        location.href = selection;
        return false;
    }
    else
        return false;
}

function QuickClick(list) {
    var selection = list.options[list.selectedIndex].value
    if (selection != "None") 
        location.href = selection
}
function confirmSubmit()
{
var agree=confirm("Are you sure you wish to delete this page?");
if (agree)
	return true ;
else
	return false ;
}
function ConfirmSubmitAdmin()
{
var agree=confirm("Are you sure you wish to delete this administrator?");
if (agree)
	return true ;
else
	return false ;
}

var agt=navigator.userAgent.toLowerCase();
var isMajor = parseInt(navigator.appVersion);

var isIE   = (agt.indexOf("msie") != -1);
var isIE4  = (isIE && (isMajor == 4) && (agt.indexOf("msie 5.0")==-1) ); 
var isIE4up  = (isIE  && (isMajor >= 4));
var isAOL   = (agt.indexOf("aol") != -1);
var isAOL4  = (isAOL && isIE4);
var isOk = (isIE4up || isAOL4);
// end browser detection

var chkDot = true;
var usEmail = true;
function validEmail(eAddr) 
{ 
   var lenSuffix = (usEmail) ? 4: 3;
   var goodAddr = false;
   var ndxAt = ndxDot = 0;

   ndxAt  = eAddr.indexOf("@");
   ndxDot = eAddr.indexOf(".");
   ndxDot2 = eAddr.lastIndexOf(".");

   if ( (ndxDot < 0) || (ndxAt < 0) )
      alert("Your email address lacks '.' or '@'.\n\nThe format is 'youremail@domain.suf'");  
   else if (chkDot  && (ndxDot < ndxAt) )
        chkDot =!( confirm("You entered a 'dot' before the '@'\n Are you sure that is right?"));
   else if ( (ndxDot2 - 3) <= ndxAt)
        alert("You may be missing your domain name.\n\nThe format is 'youremail@domain.suf'");
   
   else if ( eAddr.length < (ndxDot2 + lenSuffix) )
      usEmail =!( confirm("You have fewer than 3 characters as a domain suffix.\nAre you sure that is right?"));
   else
      goodAddr = true;


   return (goodAddr);                       
} 