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.0
  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 && document.getElementById) x=document.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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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 open500x535(URL) {
aWindow=window.open(URL,"pop","toolbar=no,width=500,height=535,left=20,top=20,status=no,scrollbars=no,resize=no,menubar=no");
}
function openMenu(URL) {
aWindow=window.open(URL,"pop","toolbar=no,width=570,height=500,left=20,top=20,status=no,scrollbars=yes,resize=no,menubar=no");
}
function open4Support(URL) {
aWindow=window.open(URL,"pop","toolbar=no,width=555,height=435,left=20,top=20,status=no,scrollbars=no,resize=yes,menubar=no");
}
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 open5(URL) {
aWindow=window.open(URL,"pop","toolbar=no,width=725,height=450,left=15,top=15,status=no,scrollbars=no,resize=no,menubar=no");
}
function openState(URL) {
aWindow=window.open(URL,"pop","toolbar=no,width=400,height=320,left=50,top=50,status=no,scrollbars=yes,resize=no,menubar=no");
}
// State

function openState(FileName) 
{
	FromTop = 100;  
	FromLeft = 100;
	winFeatures = "toolbar=0,location=0,directories=0,status=0";
	winFeatures += ",menubar=0,scrollbars=0,resizable=yes";
	winFeatures += ",screenX="+FromLeft+",screenY="+FromTop;
	winFeatures += ",left="+FromLeft+",top="+FromTop;
	winFeatures += ",height=300,width=500";
	ZoomWin=window.open("","ZoomWin",winFeatures);
	ZoomWin.document.writeln('<html>');
	ZoomWin.document.writeln('<head>');
	ZoomWin.document.writeln('<title>Distributors - a4i America</title>');
	ZoomWin.document.writeln('</head>');
	if (navigator.appName == "Microsoft Internet Explorer")
		  ZoomWin.document.writeln('<body topmargin="10" leftmargin="0"	marginwidth="0" marginheight="0">');
	else
		    ZoomWin.document.writeln('<body topmargin="10" leftmargin="0" marginwidth="0" marginheight="10">');
	ZoomWin.document.writeln('<span style=font-family:arial,sans><h3 align=center>a4i America<br>2604 Elmwood Avenue #326<br>Rochester, NY 14618<br>Phone: (585) 475-9577  Fax: (585) 475-1942</h3>');
	ZoomWin.document.writeln('<h3 align=center><a href=mailto:info@a4iamerica.com?subject=Distributor['+FileName+'] "">Email this Distributor</h3>');
	ZoomWin.document.writeln("<br><center><form><input type=button onClick='window.close();' value='Close' id=close name=close></form>");
	ZoomWin.document.writeln('</center></span></body>');
	ZoomWin.document.writeln('</html>');
	ZoomWin.document.close();
	ZoomWin.focus();
}
// Zoom

function Zoom(FileName,Text1) 
{
	FromTop = 100;  
	FromLeft = 100;
	winFeatures = "toolbar=0,location=0,directories=0,status=0";
	winFeatures += ",menubar=0,scrollbars=0,resizable=yes";
	winFeatures += ",screenX="+FromLeft+",screenY="+FromTop;
	winFeatures += ",left="+FromLeft+",top="+FromTop;
	winFeatures += ",height=375,width=500";
	ZoomWin=window.open("","ZoomWin",winFeatures);
	ZoomWin.document.writeln('<html>');
	ZoomWin.document.writeln('<head>');
	ZoomWin.document.writeln('<title>Zoom - a4i America</title>');
	ZoomWin.document.writeln('</head>');
	if (navigator.appName == "Microsoft Internet Explorer")
		  ZoomWin.document.writeln('<body topmargin="10" leftmargin="0"	marginwidth="0" marginheight="0" onLoad="window.resizeTo(document.images[0].width+50,document.images[0].height+110)">');
	else
		    ZoomWin.document.writeln('<body topmargin="10" leftmargin="0" marginwidth="0" marginheight="10" onLoad="window.resizeTo(document.images[0].width+50,document.images[0].height+85)">');
	ZoomWin.document.writeln('<center><img  src="'+FileName+' " border="0" alt="Picture Zoom - a4i America"></center>');
	ZoomWin.document.writeln("<br><center><form><input type=button onClick='window.close();' value='Close' id=close name=close></form>");
	ZoomWin.document.writeln('</center></body>');
	ZoomWin.document.writeln('</html>');
	ZoomWin.document.close();
	ZoomWin.focus();
}

function open500x375(URL) {
aWindow=window.open(URL,"pop","toolbar=no,width=500,height=375,left=50,top=25,status=no,scrollbars=no,resize=no,menubar=no");
aWindow.document.open();
aWindow.document.write (" <head><title>Screen Shot Zoom - a4i America</title></head> \
<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 background=tempi/loading1.gif> \
<a href='javascript:window.close()'><img border=0 alt=Click to Close src=");
aWindow.document.write (URL);
aWindow.document.write (" ></a></body>");
aWindow.document.close();
}

// Check Form

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 YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}

