//    printf("        var =trim(form..value);\n");
//    printf("        =str_null(, );\n");

function pass()
{
 if (form.directory.value==''){}
 else if (form.directory.value.indexOf('sample')==0) form.password.value='lloyd';
 else form.password.value='';
}

function side_entry(){
 document.write("&nbsp;<a href='http://www.eziaccounts.com/index.html' target='new' title='Home page'>Home</a><br>\n");
 document.write("&nbsp;<a href='http://www.auzform/ezi/bbs.html' target='new' title='Post your bulletin'>Bulletin Board</a><br>\n");
 document.write("&nbsp;<a href=\"JavaScript:popup('http://www.eziaccounts.com/chat.html',540,130,'no','no','no');\" title='Chat with others'>Chat</a><br>\n");
 document.write("&nbsp;<a href='http://www.eziaccounts.com/guestbook.html' target='new' title='Sign our guest book'>Guest Book</a><br>\n");
}

function addcents(num)//function to return dollars and cents
{
 if(isNaN(num))num=0.00; 
 num = num.toString().replace(/\$|\,/g,'');
 var n , x ;
 for (n=0 ; n<=num.length; n++)
 {
  if (num.charAt(n-1)=='.')//found
  {
   for(x=n; x<n+2; x++) if (num.charAt(x)=='') num+='0';
   break;
  }
  else if (n==num.length && num.charAt(n-1)!='.') num+='.'; //add decimal point
 }
 return(num);
}

function click() {
//  if ((event.button==3 || event.button==2) && popCal.style.visibility=='visible') popCal.style.visibility='hidden';
  //if (event.button==2) alert("Copyright © 2005 LocalNet Australia");
} document.onmousedown=click;

 var orderno='*';
 var choice=99;
 var pageLoaded=true;

function onpressed(act){
 choice=act;
}

function housecode(code){
  window.opener.document.form.prodtype.value=code;
  window.close();
}

function modelcode(code){
  window.opener.document.form.prodtype.value='';
  window.opener.document.form.product.value=code;
  window.close();
}

function page_load(){
  if(pageLoaded==true){
   pageLoaded=false;
   return(true);
  }
  else {
   alert('Page is still loading......Please wait.');
   return(false);
  }
}
function helpwindow(doc){
  new_window = window.open(doc, 'magic_window', 'left=50, top=100, width=280, height=320, resizable=0, scrollbars=yes');
}
function openMagicWindow1(doc1){
  new1 = window.open( doc1, 'new1','width=750, height=300, copyhistory=no, resizable=yes, scrollbars=yes');//'fullscreen=1, resizable=no, copyhistory=no, scrollbars=no');
}
function openMagicWindow2(doc1){
  new2 = window.open( doc1, 'new2', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow3(doc1){
  new3 = window.open( doc1, 'new3', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow4(doc1){
  new4 = window.open( doc1, 'new4', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow5(doc1){
  new5 = window.open( doc1, 'new5', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow6(doc1){
  new6 = window.open( doc1, 'new6', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow7(doc1){
  new7 = window.open( doc1, 'new7', 'width=750, height=310, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow8(doc1){
  new8 = window.open( doc1, 'new8', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow9(doc1){
  new9 = window.open( doc1, 'new9', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow10(doc1){
  new10 = window.open( doc1, 'new10', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow11(doc1){
  new11 = window.open( doc1, 'new11', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow12(doc1){
  new12 = window.open( doc1, 'new12', 'width=750, height=300, copyhistory=no, resizable=no, scrollbars=no');
}
function openMagicWindow13(doc1){
  new13 = window.open( doc1, 'new13', 'width=750, height=300, copyhistory=no, resizable=yes, scrollbars=yes');
}
function openMagicWindow14(doc1){
  new14 = window.open( doc1, 'new14', 'width=750, height=300, copyhistory=no, resizable=yes, scrollbars=yes');
}
function openMagicWindow15(doc1){
  new14 = window.open( doc1, 'new15', 'width=750, height=300, copyhistory=no, resizable=yes, scrollbars=yes');
}
function ccWindow(doc){
  window1 = window.open( doc, 'window1', 'left=100, top=100, width=240, height=208, copyhistory=no, resizable=no, scrollbars=no');
}
function change(h, doc){
  change1 = window.open( doc, 'change1', 'left=15, top=100, screenX=15, screenY=200, width=760, height='+h+', scrollbars=yes, resizable=yes');
} 
function change_D(h, doc){
  change2 = window.open( doc, 'change2', 'left=15, top=100, screenX=15, screenY=200, width=760, height='+h+', scrollbars=yes, resizable=yes');
} 
function change_C(h, doc){
  change3 = window.open( doc, 'change3', 'left=15, top=100, screenX=15, screenY=200, width=760, height='+h+', scrollbars=yes, resizable=yes');
} 
function openMagicWindowL(doc){
  magic = window.open( doc, "magic", 'left=50, top=100, width=450, height=300, copyhistory=no, resizable=no, menu=yes, scrollbars=yes');
}

function closeall()
{
 if (window.new1) window.new1.close();
 if (window.new2) window.new2.close();
 if (window.new3) window.new3.close();
 if (window.new4) window.new4.close();
 if (window.new5) window.new5.close();
 if (window.new6) window.new6.close();
 if (window.new7) window.new7.close();
 if (window.new8) window.new8.close();
 if (window.new9) window.new9.close();
 if (window.new10) window.new10.close();
 if (window.new11) window.new11.close();
 if (window.new12) window.new12.close();
 if (window.new13) window.new13.close();
 if (window.new14) window.new14.close();
 if (window.new15) window.new15.close();
 if (window.window1) window.window1.close();
 if (window.window2) window.window2.close();
 if (window.price) window.price.close();
 if (window.openHelpWindow) window.openHelpWindow.close();
 if (window.change1) window.change1.close();
 if (window.change2) window.change2.close();
 if (window.change3) window.change3.close();
 if (window.magic) window.magic.close();
 if (window.magic_window) window.magic_window.close();
}

function trim(string) {
  var check="";
  for(n=1; n<=string.length; n++){
   if(string.substring(n-1, n)=='+'
      || string.substring(n-1, n)=='#'
      || string.substring(n-1, n)=='!'
      || string.substring(n-1, n)=='"'
      || string.substring(n-1, n)=='~'
      || string.substring(n-1, n)=='`'
      || string.substring(n-1, n)=='$'
      || string.substring(n-1, n)=='^'
      || string.substring(n-1, n)=='&'
      || string.substring(n-1, n)=='*'
      || string.substring(n-1, n)=='('
      || string.substring(n-1, n)==')'
      || string.substring(n-1, n)=='/'
      || string.substring(n-1, n)=='}'
      || string.substring(n-1, n)=='{'
      || string.substring(n-1, n)=='.'
      || string.substring(n-1, n)=='\\'
      || string.substring(n-1, n)=='>'
      || string.substring(n-1, n)=='<'
      || string.substring(n-1, n)=='"'
      || string.substring(n-1, n)=='['
      || string.substring(n-1, n)==']'
      || string.substring(n-1, n)=='?'
      || string.substring(n-1, n)=='%'
      || string.substring(n-1, n)==':'
      || string.substring(n-1, n)=='|'
      || string.substring(n-1, n)==';'
      || string.substring(n-1, n)=='=')
   {
    alert('The Invalid character " '+string.charAt(n-1)+' "  has been replaced with "_".');
    check+="_";
   }
   else if(string.substring(n-1, n)=='\'') check+="`";
   else check+=string.substring(n-1, n);
  }
  string=check;

  spos=0;
  while(string.charAt(spos)==' ' && spos<string.length) spos++;
  if(spos==string.length) string='';
  else {
   string=string.substring(spos, string.length);
   epos=(string.length)-1;
   while(string.charAt(epos)==' ') epos--;
   string=string.substring(0, epos+1);
  }
  return(string);
}

function checkword(entry){
   var check='';
    for (var n=0 ; n<entry.length ; n++)
    {
     if (entry.substring(n, n+1)=='+') check+='^';
     else check+=entry.substring(n, n+1);
    }
 return(check);
}

function str_null(string, len) {
 var re=/ /g;
 if (string=='') string='_';
 string=string.replace(re, '_');
 for(i=string.length; i<len; i++) string+='_';
 string=string.substring(0, len);
 return(string);
}

 var message="The browser window that opened this popup window has been closed.\n\nThis directory window will not function properly so I will close it.\n\nTo re-enable it, you must go back go to your Start Menu.";

function goThere(YN, location) {
 if(YN==0) self.close();
 if (!window.opener)  alert(message);
 else { Load(); window.opener.parent.TOP.location.href = location; }
}

function isDigit(num) {
    if (num.length>1){return false;}
    var string="1234567890";
    if (string.indexOf(num)!=-1) return true;
    return false;
}

function isNumeric(val){return(parseFloat(val,10)==(val*1));}

function checkdate(date){
 var tdate=new Date();
 var tyear=tdate.getFullYear();
 var dcount=0;
 var t, x=0, days, year='', month='', day='';

 for(t=0;t<date.length;t++) if(!isDigit(date.charAt(t))) dcount++;

 if(dcount==2 && date.length>=6)
 {
  for(t=0;t<date.length;t++)
  {
   if(!isDigit(date.charAt(t)))x++;
   else if(t<2) day+=date.charAt(t);
   else if(t<6-x) month+=date.charAt(t);
   else if(isDigit(date.charAt(t))) year+=date.charAt(t);
  }

  if(year.length==2 && year>20) year='19'+year;
  else if(year.length==2) year='20'+year;
  if(day.length<2) day='0'+day;
  if(month.length<2) month='0'+month;

  if (year.length<4) year=tyear;
  if (month<1 || month>12) month='01';
  if (day<1 || day>31) day='01';
  if (month==2){ if (isLeapYear(year)) days=29; else days=28; }
  else if (month==4 || month==6 || month==9 || month==11) days=30;
  else days=31;
  if (day>days) day=days;
  date=year+month+day;
 }
 else { alert("Incorrect date format ("+date+") - Date now used : 01.01."+tyear); return(tyear+'0101'); }
 return(date);
}

function isLeapYear (Year) {
 if ((Year % 4)==0 && (Year % 100)!=0 || (Year % 400)==0) return (true);else return (false);
}

//special function to take change the "+" sign in equations
// to stop the string being changed at the "+" sign
 function wordcheck(entry){
    var checkplus = "";
    for (var n=1 ; n<=entry.length ; n++) 
    {
     if (entry.substring(n-1, n) == "+") checkplus+="^";
     else checkplus+=entry.substring(n-1, n); 
    }
   return checkplus;
 }

function toUpper(word)
{
 var check;
 check=word.toUpperCase();
 return(check);
}

function autoComplete (field, select, property, forcematch)
{
 var found = false;
 for (var i = 0; i < select.options.length; i++)
 {
  if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) { found=true; break; }
 }
 if (found) select.selectedIndex = i;
 else select.selectedIndex = -1;
 if (field.createTextRange)
 {
  if (forcematch && !found){ field.value=field.value.substring(0,field.value.length-1); return; }
  var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
  if (cursorKeys.indexOf(event.keyCode+";") == -1)
  {
   var r1 = field.createTextRange();
   var oldValue = r1.text;
   var newValue = found ? select.options[i][property] : oldValue;
   if (newValue != field.value)
   {
    field.value = newValue.substr(0,6);
    field.value = field.value.replace(',',' ');
    var rNew = field.createTextRange();
    rNew.moveStart('character', oldValue.length) ;
    rNew.select();
   }
  }
 }
}

function Load()
{
 if (window.opener) {var top=window.opener.parent.TOP.document.body.scrollTop+150;}
 else { var top=parent.TOP.document.body.scrollTop+150;}
 var width=(document.body.scrollWidth/2)-100;
 var message= '<DIV ID="load" STYLE="position:absolute; TOP:'+top+'px; LEFT:'+width+'px;">'
      +'<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="0" bgcolor="orange">'
      +'<tr><td width="200" height="100" align="center" valign="center">'
      +'<marquee>. . L O A D I N G . .</marquee>'
      +'</td></tr></TABLE>'
      +'</DIV>';

 if (window.opener) window.opener.parent.TOP.document.body.insertAdjacentHTML('BeforeEnd', message);
 else parent.TOP.document.body.insertAdjacentHTML('BeforeEnd', message);
}

///////////////////////////////object hide and show
function anyObj(divName)
{
 this.IE5=this.NN4=this.NN6=false
 if(document.all)this.IE5=true
 else if(document.layers)this.NN4=true
 else if(document.getElementById)this.NN6=true
	
 if(this.NN4)this.obj=eval("document."+divName)
 if(this.IE5)this.obj=eval("document.all."+divName)
 if(this.NN6)this.obj=eval("document.getElementById(\""+divName+"\")")

 this.show = showDiv
 this.hide = hideDiv
}

function showDiv()
{
  if(this.NN4) this.obj.visibility="visible";
  else this.obj.style.visibility="visible";
}

function hideDiv()
{
 if(this.NN4) this.obj.visibility="hidden";
 else this.obj.style.visibility="hidden";
}

function check_show()
{
 if (form.Resource.value && form.Resource.value == "Business Card" || form.Resource.value == "Leaflet")
 {
   myObj.show();
 }
 else myObj.hide();
}

function initialize() 
{
 myObj = new anyObj("tableDiv"); myObj.hide();
}

function hide_me(ref)
{
 ref = new anyObj(ref); ref.hide();
}

function show_me(ref)
{
 ref = new anyObj(ref); ref.show();
}

 function ShowLayer(id)
 { 
  if (document.all)
  { 
   document.all[id].style.visibility = 'visible';
   document.all[id].style.position   = 'relative';
  } 
  if(document.layers)
  { 
   document.layers[id].visibility = 'show' ;
   document.layers[id].position   = 'relative';
  } 
  if(document.getElementById)
  {
   document.getElementById(id).style.visibility = 'visible';
   document.getElementById(id).style.position   = 'relative';
  } 
 } 

 function HideLayer(id)
 { 
  if (document.all)
  { 
   document.all[id].style.visibility = 'hidden';
   document.all[id].style.position   = 'absolute';
  } 
  if(document.layers)
  { 
   document.layers[id].visibility = 'hide';
   document.layers[id].position   = 'absolute';
  } 
  if(document.getElementById)
  {
   document.getElementById(id).style.visibility ='hidden';
   document.getElementById(id).style.position   ='absolute';
  } 
 }

