function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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_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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function validateLogonForm(form){
	if((form.email.value == "")||(form.password.value == "")){
		alert("Please Enter An Email And Password.");
	}else{
		if (!isEmailAddr(form.email.value)){
    		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    		form.email.focus();
    	}else{
			form.submit();
		}
	}
}
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function popUp(URL) 
{ 
  day = new Date(); 
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=250,left=100,top=100');");
}

function clearDefault(el)
{
	if (el.defaultValue==el.value) el.value = "";
}

function SWIFT_styleSwap(object, state){
  if (state == 'on'){
    object.className ='inputBodyFocus';
  }
  else
  {
    object.className ='inputBody';
  }
}

function COMPANY_styleSwap(object, state){
  if (state == 'on'){
    object.className ='COMPANYinputBodyFocus';
  }
  else
  {
    object.className ='inputBody';
  }
}

function CUSTOMER_styleSwap(object, state){
  if (state == 'on'){
    object.className ='CUSTOMERinputBodyFocus';
  }
  else
  {
    object.className ='inputBody';
  }
}

function RED_styleSwap(object, state){
  if (state == 'on'){
    object.className ='inputBodyFocus';
  }
  else
  {
    object.className ='inputBodyRed';
  }
}

function initArray() {
  this.length = initArray.arguments.length;
  for (var i = 0; i < this.length; i++) {
    this[i] = initArray.arguments[i];
    }
  }

function inchcm() { // Inches -> CM 
/* Please don't ask about this work-around. It works... We're sure arrays
    will be better supported soon. */
var isn01 = new initArray("4b","5b","8b","8b");
isn01[0] = "~01~10.3937~20.03281~30.01094~40.01~50.0004971~60.00001~70.000006214~8";
isn01[1] = "~02.540~11~20.08333~30.02778~40.0254~50.001263~60.0000254~70.00001578~8";
  // First, get the variables checked by the user
      leno = 0;
      leni = 1;
  // Now grab the number input by user and parse to be sure numeric
  useri = document.edit.size_in_w.value;
  if (useri == 0) {
    useri = 0;
    document.edit.size_in_w.value = useri;
  }
  mulstr = isn01[leni];
  picker = "~" + leno;
  ps = mulstr.indexOf(picker);
  leno++;
  picker = "~" + leno;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  document.edit.size_cm_w.value = picker;
  // First, get the variables checked by the user
      leno = 0;
      leni = 1;
 // Now grab the number input by user and parse to be sure numeric
  useri = document.edit.size_in_h.value;
  if (useri == 0) {
    useri = 0;
    document.edit.size_in_h.value = useri;
  }
  mulstr = isn01[leni];
  picker = "~" + leno;
  ps = mulstr.indexOf(picker);
  leno++;
  picker = "~" + leno;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  document.edit.size_cm_h.value = picker;
   // First, get the variables checked by the user
      leno = 0;
      leni = 1;
 // Now grab the number input by user and parse to be sure numeric
  useri = document.edit.size_in_d.value;
  if (useri == 0) {
    useri = 0;
    document.edit.size_in_d.value = useri;
  }
  mulstr = isn01[leni];
  picker = "~" + leno;
  ps = mulstr.indexOf(picker);
  leno++;
  picker = "~" + leno;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  document.edit.size_cm_d.value = picker;
  }

function cminch() { //CM -> Inches
/* Please don't ask about this work-around. It works... We're sure arrays
    will be better supported soon. */
var isn01 = new initArray("4b","5b","8b","8b");
isn01[0] = "~01~10.3937~20.03281~30.01094~40.01~50.0004971~60.00001~70.000006214~8";
isn01[1] = "~02.540~11~20.08333~30.02778~40.0254~50.001263~60.0000254~70.00001578~8";
  // First, get the variables checked by the user
      leno = 1;
      leni = 0;
  // Now grab the number input by user and parse to be sure numeric
  useri = document.edit.size_cm_w.value;
  if (useri == 0) {
    useri = 0;
    document.edit.size_cm_w.value = useri;
  }
  mulstr = isn01[leni];
  picker = "~" + leno;
  ps = mulstr.indexOf(picker);
  leno++;
  picker = "~" + leno;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  document.edit.size_in_w.value = picker;
  // First, get the variables checked by the user
      leno = 1;
      leni = 0;
  // Now grab the number input by user and parse to be sure numeric
  useri = document.edit.size_cm_h.value;
  if (useri == 0) {
    useri = 0;
    document.edit.size_cm_h.value = useri;
  }
  mulstr = isn01[leni];
  picker = "~" + leno;
  ps = mulstr.indexOf(picker);
  leno++;
  picker = "~" + leno;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  document.edit.size_in_h.value = picker;
  // First, get the variables checked by the user
      leno = 1;
      leni = 0;
  // Now grab the number input by user and parse to be sure numeric
  useri = document.edit.size_cm_d.value;
  if (useri == 0) {
    useri = 0;
    document.edit.size_cm_d.value = useri;
  }
  mulstr = isn01[leni];
  picker = "~" + leno;
  ps = mulstr.indexOf(picker);
  leno++;
  picker = "~" + leno;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  document.edit.size_in_d.value = picker;
  }

function setCheckboxes(the_form, do_check)
{
    var elts      = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined')
                  ? document.forms[the_form].elements['selected_db[]']
                  : (typeof(document.forms[the_form].elements['selected_tbl[]']) != 'undefined')
          ? document.forms[the_form].elements['selected_tbl[]']
          : document.forms[the_form].elements['selected_fld[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function

function GeneratePassword( ) {

    if (parseInt(navigator.appVersion) <= 3) {
        alert("Sorry this only works in 4.0+ browsers");
        return true;
    }

    var length=6;
    var sPassword = "";

    var noPunction = true;
    var randomLength = false;

    if (randomLength) {
        length = Math.random();

        length = parseInt(length * 100);
        length = (length % 7) + 6
    }

    for (i=0; i < length; i++) {

        numI = getRandomNum();
        if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }

        sPassword = sPassword + String.fromCharCode(numI);
    }
	
    document.aForm.passField.value = sPassword

    return true;
}

function GenerateSwiftPassword( ) {

    if (parseInt(navigator.appVersion) <= 3) {
        alert("Sorry this only works in 4.0+ browsers");
        return true;
    }

    var length=6;
    var sPassword = "";

    var noPunction = true;
    var randomLength = false;

    if (randomLength) {
        length = Math.random();

        length = parseInt(length * 100);
        length = (length % 7) + 6
    }

    for (i=0; i < (length/2); i++) {

        numI = getRandomNum();
        if (noPunction) { while (checkSwiftPunc(numI)) { numI = getRandomNum(); } }

        sPassword = sPassword + String.fromCharCode(numI);
    }
	
    for (i=0; i < (length/2); i++) {

		var rndNum = Math.random()
		rndNum = parseInt(rndNum * 10);
 
 		sPassword = sPassword + rndNum;
    }

    document.aForm.passField.value = sPassword

    return true;
}

function getRandomNum() {

    // between 0 - 1
    var rndNum = Math.random()

    // rndNum from 0 - 1000
    rndNum = parseInt(rndNum * 1000);

    // rndNum from 33 - 127
    rndNum = (rndNum % 94) + 33;

    return rndNum;
}

function checkSwiftPunc(num) {

	if ((num >=33) && (num <=47)) { return true; }
	if ((num >=48) && (num <=57)) { return true; } // 0..9
    if ((num >=58) && (num <=64)) { return true; }
    if ((num >=65) && (num <=90)) { return true; } // A..Z (Caps)
    if ((num >=91) && (num <=96)) { return true; }
    //if ((num >=65) && (num <=90)) { return true; } // a..z (Lower)
    if ((num >=123) && (num <=126)) { return true; }

    return false;
}

function checkPunc(num) {

	if ((num >=33) && (num <=47)) { return true; }
	//if ((num >=48) && (num <=57)) { return true; } // 0..9
    if ((num >=58) && (num <=64)) { return true; }
    //if ((num >=65) && (num <=90)) { return true; } // A..Z (Caps)
    if ((num >=91) && (num <=96)) { return true; }
    //if ((num >=65) && (num <=90)) { return true; } // a..z (Lower)
    if ((num >=123) && (num <=126)) { return true; }

    return false;
}

function NewWindow(wizpage, wizname, w, h) {

	settings = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,height=' + h + ',width=' + w + ',top= 100,left=100'
	win = window.open(wizpage, wizname, settings)
}
