function m2 (p1,p2,p3,p4,p5) {var l2r;var t = new Array();var td = new Array();
  td[0]="co";td[1]="org";td[2]="gov";td[10]="com";td[11] = "org";td[12]="net";
  td[13]="info";for (i=0;i<10;i++) {td[i]=td[i]+'.uk';}
  var c=0;for (i=72;i<85;i++) {c++;t[c]=String.fromCharCode(i);}
  var m2= t[6]+'a'+t[2]+t[5]+'t'+t[8]+':';var a= String.fromCharCode(2*4*8);
  if (p5==null) {l2r=m2+w2(p3)+'.'+w2(p4)+a+w2(p1)+'.'+td[p2];return l2r;}
  if (p5.length<2) {l2r=m2+w2(p3)+p5+w2(p4)+a+w2(p1)+'.'+td[p2];return l2r;}
  l2r=m2+w2(p3)+'.'+w2(p4)+'.'+w2(p5)+a+w2(p1)+'.'+td[p2];return l2r;}

function w2 (w,p) {var w2r = '';var r2w = '';var m='';
  for (i=0;i<w.length;i++) {nc = w.charCodeAt(i);rc = nc;
    if ((nc > 96 && nc < 123) || (nc > 47 && nc < 58))
      {nc = nc + 1 - i % 3;rc = rc - 1 + i % 3;
      switch (nc) {case 96: nc=122;break;case 123: nc=97;break;
                   case 47: nc=57;break;case 58: nc=48;break;}
      switch (rc) {case 96: rc=122;break;case 123: rc=97;break;
                   case 47: rc=57;break;case 58: rc=48;break;}
      }
    m = m + 'i='+i+' nc='+nc+' rc='+rc+' ';
    // if (i==5) {alert(m);}
    w2r = w2r + String.fromCharCode(nc);r2w = r2w + String.fromCharCode(rc);
  }
  if (p==null) {return w2r;}return w2r + ' ' + r2w + ' ' + m;
}



function byein2() {window.status='Waiting 2 seconds to close in case you launched something, Bye!';
var cmd = 'window.close()';this.timerHandle = setTimeout(cmd , 2000);
}
var gotLIB = 1;


function CloseWinIn(insec) {
  if (insec < 0.1 || insec > 99) {insec = 3;}
  inms = insec * 1000;
  window.status='Waiting ' + insec + ' seconds to close in case you launched ' +
    'something, Bye! ';
  var cmd = 'window.close()';this.timerHandle = setTimeout(cmd , inms);
}

function Fragments() {
  if (!isNaN(intime)) {intime = 2000;}
}


function GetCook(cname) {
  cname = " " + cname + "=";
  cookwbs = " " + document.cookie + "; ";
  pos = cookwbs.indexOf(cname);
  if (pos == -1) return null;
  pos = pos + cname.length;
  cend = cookwbs.indexOf("; ",pos);
  ret = cookwbs.substring(pos,cend);
  return ret;
  alert('pos/cname/cookwbs = ' + pos + ' / ' + cname + ' / ' + cookwbs)
  alert('ret/pos/bpc/cn/cend: /' + ret +'/'+
        pos +'/'+ cookwbs +'/'+ cname +'/'+ cend);

}

function SetCook(name, value, exp) {
//  the units for exp are minutes... default = 10 years... "F7 on THIS line...
  if (exp == '') {exp = 30*365.25*24*60;}
  expire  = new Date();
  expire.toGMTString();
  texp = expire.getTime() + exp * 60000;
  expire.setTime(texp);
  var toset = name + "=" + escape (value) +
  "; expires=" + expire.toGMTString() + "; path=/;";
  document.cookie = toset;
  return true;
  alert('toset' + toset + expire);

}

function SetSCook(name, value) {
// set a SESSION cookie...
  var toset = name + "=" + escape (value) + "; path=/;";
  document.cookie = toset;
  return true;
  alert('toset' + toset + expire);

}






function DelCook (name,exp) {
  if (exp == undefined) exp = -1;
  var cval = GetCook(name);
  r=SetCook(name,cval,exp);
}


var BisNN = (navigator.appName.indexOf("Netscape")!=-1);
function nowShowPop(sHtext,action,wleft,wtop,sizex,sizey,cx,cy) {

if (globPop.value == 0) {
  window.status = 'Popup available for: ' + sHtext;
  return true;
  }

if (sHtext == "") return true;

if (isNaN(wleft) || wleft=='') {wleft=1;}
if (isNaN(wtop)  || wtop =='') {wtop=1;}

if (isNaN(sizex) || sizex=='') {sizex=330;}
if (isNaN(sizey) || sizey=='') {sizey=250;}
var ps = 'NotSet';
cxms=0;cyms=0;
if (!BisNN) {
  cx = cx * 1;
  cy = cy * 1;
  cxms = cx - sizex;cyms = cy - sizey;
  if (cxms >= 30 && cyms >= 20) {ps=ps+'1';wleft=10;wtop=10;}
  if (cxms >= 30 && cyms <  20) {ps=ps+'2';wleft=10;wtop=cy + 30;}
  if (cxms <  30 && cyms >= 20) {ps=ps+'3';wleft=cx+30;wtop=10;}
  if (cxms <  30 && cyms <  20) {ps=ps+'4';
    wleft=cx+25;wtop=cy + 30;
    if (sizex > 500) {ps=ps+'5';wleft=cx+30;wtop=35;}
    if (sizey > 500) {ps=ps+'6';wleft=cx+30;wtop=35;}
  }

  if (cxms >= 70) {ps=ps+'7';wleft = cx-sizex-25;}
  if (cyms >= 70) {ps=ps+'8';wtop  = cy-sizey-25;}
}
if (wleft > 800) {ps=ps+'9';wleft = 123;}
if (wtop  > 500) {ps=ps+'0';wtop  = 123;}
if (wtop + sizey > 700) {ps=ps+'a';wtop  = 12;}
ws = 'Popup at: ps:'+ps+' cxms:'+cxms+' cyms:'+cyms+' wl:'+wleft+' wt:'+wtop;
ws = ws+' cx:'+cx+' cy:'+cy+' sx:'+sizex+' sy:'+sizey+' for: ' + sHtext;
window.status = 'Popup for: ' + ws;
if (0) {alert(navigator.appName + '... ' + ws);}

var url = "";
var posssl = action.indexOf ("SSL") + document.URL.indexOf ("secure1.affinity.");

if (sHtext.length < 10) {var url = Domain + sHtext + ".htm";}
if (posssl >= -1)       {var url = sDomain + sHtext + ".htm";}

if (!this.windowHandle || !this.windowHandle.name || this.windowHandle.name=="")
this.windowHandle = window.open(url, +
"subWindow","toolbar=no,location=no,directories=no,status=no,menubar=no," +
"scrollbars=no,left=" + wleft + ",top=" + wtop + ",resizable=no,width=" + sizex + ",height=" + sizey );
else
if (1) {this.windowHandle.focus();}

if (sHtext.length < 10) {return true;}

this.windowHandle.document.open();



var to_page =
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ' +
'"http://www.w3.org/TR/html4/loose.dtd">' + "<HTML>" +
"<HEAD><TITLE>" + CompName  + " PopUp help - move mouse away from image/box to close this window</TITLE>" +
"</HEAD><BODY onBlur='javascript:window.close()' BGCOLOR='#F0FFFF'><FONT SIZE=3 COLOR=black><STRONG><BR>" +
sHtext;

var actmsg='<BR>'
if (posssl >= 0) actmsg = actmsg + '<BR>Note the small padlock icon at the bottom of your browser<BR>will show closed if this information will be sent securely<br>';

var posact = action.indexOf ("Enter");
if (posact >= 0) actmsg = actmsg + '<BR>Click on box, key in data, then press tab key for next or';

var posact = action.indexOf ("Print");
if (posact >= 0) actmsg = actmsg + '<BR>To Print this Pop-Up press and hold the Ctrl key then press P';

var posact = action.indexOf ("Out");
if (posact >= 0) actmsg = actmsg + '<BR>To remove PopUp move mouse away from image/box/link';

var posact = action.indexOf ("Sub");
if (posact >= 0) actmsg = actmsg + '<BR>When all fields complete, click on Submit to process';

var posact = action.indexOf ("Test");
if (posact >= 0) actmsg = actmsg + "<BR>Testing positions: cx="+cx+",cy="+cy+",wleft="+wleft+",wtop="+wtop+" sizex="+sizex+",sizey="+sizey+",ps="+ps;

to_page = to_page + actmsg + "</STRONG></FONT></BODY></HTML>";
this.windowHandle.document.write(to_page);
this.windowHandle.document.close();
}

var globPop   = new String();
globPop.value = 0;
function closePop() {
var cmd = "top.nowClosePop()";
this.timerHandle = setTimeout(cmd , 234);
}
function nowClosePop() {
globPop.value = 0;
if (this.windowHandle && this.windowHandle.name) {
this.windowHandle.close();
this.windowHandle=null;
   }
}


function showPop(a,b,c,d,e,f) {
var cx=0;
var cy=0;
var BisNN = (navigator.appName.indexOf("Netscape")!=-1);
var BisOp = (navigator.userAgent.indexOf("Opera")!=-1);



if (!BisNN && !BisOp) {cx=event.screenX;cy=event.screenY;}
if (BisOp)  {
  if (window.event)
    {cx=event.clientX;cy=event.clientY;}
  else
    {cx=event.clientX;cy=event.clientY;}
  }

var cmd = "top.nowShowPop('" + a + "','" + b + "','" + c + "','" + d + "','" + e + "','" + f +  "','" + cx + "','" + cy + "')";
globPop.value = 1;
this.timerHandle = setTimeout(cmd , 1234);
}

function ShowBiggerPicture(nop) {
  window.status='Will show big picture after Mouse Up';}


function stoprc(bigE) {
  if (!bisOK) {return true;}
  if (bisIE) {
  if (event.button == 2) {alert('Sorry - please use normal (Left click) navigation');
                          return false;}return true;}

  if (bisNS) {
  if (bigE.which   == 3) {alert('Sorry - please use normal (Left click) navigation');
                          return false;}return true;}
  return true;
}


function formdata(fname,io) {
  if (io == 'S' || io == 's' || io=='save') {s = 1;}
  else {s = 0;}
  r=inoutcook(s,fname.first_name,'first_name');
  r=inoutcook(s,fname.last_name,'last_name');
  r=inoutcook(s,fname.address,'address');
  r=inoutcook(s,fname.city,'city');
  r=inoutcook(s,fname.state,'state');
  r=inoutcook(s,fname.zip,'zip');
  r=inoutcook(s,fname.country,'country');
  r=inoutcook(s,fname.phone,'phone');
  r=inoutcook(s,fname.email,'email');
  r=inoutcook(s,fname.cnameoc,'cnameoc');
  r=inoutcook(s,fname.mmemail,'mmemail');
}

function inoutcook(save,fname,iname) {
  cname = 'My_' + iname;
//    if (1) alert('i / f = ' + iname + ' / ' + fname);
    if (save) {SetCook(cname,fname.value,'');}
       else {
         if (fname.value != null && fname.value != "") {return true;}
         incook = GetCook(cname);
         if (incook != null && incook != "undefined")
           {fname.value = incook;}
       }
//    if (!save) alert('f.i / f = ' + GetCook(cname) + ' / ' + fname.value + ' / ' + cname + '
    return true;
}

function popp(fld,pmsg,pdef) {
  val=prompt(pmsg,pdef);
  document.forms[0].elements[fld].value=val;
}


