// scripts to run austech medical
// (c) 2oo8 Bout Time software

	// for changing header images
function rollover(pos,af)
{
 if (pos == "am_b5")
  document.images["pic-01"].src = "slide_files/left-01a.jpg";

 if (pos == "am_b4")
  document.images["pic-04"].src = "slide_files/right-02a.jpg";


//  if (document.getElementById("topleft").style.display=="")
//     document.getElementById("topleft").style.display = "none";

//  if (document.getElementById("topright").style.display=="")
//     document.getElementById("topright").style.display = "none";

//  if (pos == "am_b2")
//    document.getElementById("topleft").style.display = "";
//  else if (pos == "am_b3")
//       document.getElementById("topright").style.display = "";
}

	// for changing menu images
function imagechange(imag,af)
{
 var iname = "";
 if (imag == "z")
  return 0;

  if (imag.search(/A/) != -1)
  {
   var dname = "pic-01";
   iname = imag.replace(/A/, "");
  }
   else if (imag.search(/B/) != -1)
   {
    var dname = "pic-02";
    iname = imag.replace(/B/, "");
   }
    else if (imag.search(/C/) != -1)
    {
     var dname = "pic-03";
     iname = imag.replace(/C/, "");
    } 
     else if (imag.search(/D/) != -1)
     {
      var dname = "pic-04";
      iname = imag.replace(/D/, "");
     }

  if (af)
     document.images[dname].src = "slide_files/"+iname+".jpg";
  else
  {
    if (dname == "pic-01")
     document.images[dname].src = "slide_files/left-01.jpg";
    else
     if (dname == "pic-02")
      document.images[dname].src = "slide_files/left-02.jpg";
     else
      if (dname == "pic-03")
       document.images[dname].src = "slide_files/right-01.jpg";
      else
       if (dname == "pic-04")
        document.images[dname].src = "slide_files/right-02.jpg";
  }
}

	// for changing main heading images.  inactive.
function rolloverimage(pos,af)
{
   document.images["pic-01"].src= "images/t-dot.gif"
   document.images["pic-02"].src= "images/t-dot.gif"

   if (pos == "am_b1")
      var imagename = "pic-01";
   else if (pos == "am_b2")
         var imagename = "pic-01";
      else if (pos == "am_b3")
            var imagename = "pic-02";
         else if (pos == "am_b4")
               var imagename = "pic-02";

//   document.images[imagename].src= "images/logo-sigma.jpg";
}

	// for changing bg of thumbs

function cbg(item,tn)
{
   if (!tn)
     var tn = "";

   document.getElementById(item).style.background = "url('images/thumbnail"+tn+"-o.png') no-repeat";
}

function rbg(item,tn)
{
   if (!tn)
     var tn = "";

  document.getElementById(item).style.background = "url('images/thumbnail"+tn+".png') no-repeat";
}

	// for adjusting product summary content
function summary(infob, details)
{
 document.getElementById(infob).innerHTML=details;
}



	// for order

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place

function numbersonly(myfield, e, dec)
{
   var key;
   var keychar;

   if (window.event)
      key = window.event.keyCode;
   else if (e)
      key = e.which;
   else
      return true;
   keychar = String.fromCharCode(key);

   // control keys
   if ((key==null) || (key==0) || (key==8) || 
       (key==9) || (key==27) )
      return true;

   // numbers
   else if ((("0123456789").indexOf(keychar) > -1))
      return true;

   // decimal point jump
   else if (dec && (keychar == "."))
   {
//      myfield.form.elements[dec].focus();
  //    return false;
   }
   else
      return false;
}


function charsonly(e)
{
   var unicode=e.charCode? e.charCode : e.keyCode
   if ((unicode==34) || (unicode==44))
      return false
}

function newnumbersonly(e)
{
   var unicode=e.charCode? e.charCode : e.keyCode
   if (((unicode>=49) && (unicode<=54)) || (unicode ==127)  || (e.keyCode ==37) || (e.keyCode ==39)  || (e.keyCode ==46))
      return true
   else
      return false
}



//<!--[if IE]>
// <script language="javascript" type="text/JavaScript">
// document.onkeypress = keyPress;
// var count = 1;
// function keyPress()
// {
//    if (window.event.keyCode == 13)
//    {
//       event.returnValue=false;
//       event.cancel = true;
//    }
// }
//<![endif]-->

 function noenterkey()
 {
    if (window.event.keyCode == 13)
    {
       event.returnValue=false;
       event.cancel = true;
    }
 }

var referencereq = 0;

// scripts by me to manage forms and checkboxes
function validate_form()
{
   var valid = true;
   var missing = "";
   var focusset = 0;

   if ( window.document.order.b_last.value == "" )
   {
      missing += "- Your Name\n";
      if (!focusset)
       window.document.order.b_last.focus();
      focusset = 1;
   }

   if ( window.document.order.b_email.value == "" )
   {
      missing += "- Your Email Address\n";
      if (!focusset)
       window.document.order.b_email.focus();
      focusset = 1;
   }

   if ( window.document.order.b_first.value == "" )
   {
      missing += "- Company Name\n";
      if (!focusset)
       window.document.order.b_first.focus();
      focusset = 1;
   }

   if ( window.document.order.b_phone.value == "" )
   {
      missing += "- Phone Number\n";
      if (!focusset)
       window.document.order.b_phone.focus();
      focusset = 1;
   }

//   if ( window.document.order.s_addr.value == "" )
//   {
//      missing += "- Your Shipping/Delivery Address\n";
//      if (!focusset)
//       window.document.order.s_addr.focus();
//      focusset = 1;
//   }

   if ( window.document.order.reference.value == ""  && referencereq)
   {
      missing += "- Requisition Number\n";
      if (!focusset)
       window.document.order.reference.focus();
      focusset = 1;
   }

   if (missing != "")
   {
      alert ( "The following required field(s) in the form have not been completed\n\n" + missing);
      valid = false;
   }
   if (valid)
     document.order.submit();
   return valid;
}

function notice()
{
   if (window.document.order.process.checked==true)
   {
      window.document.order.summary.value=" Clicking on Submit WILL PROCESS YOUR ORDER or QUOTE IMMEDIATELY.";
      window.document.order.subbut.value="  SUBMIT  ";
   }
   if (window.document.order.process.checked==false)
   {
      window.document.order.summary.value=" Clicking on Preview will allow you to preview your order / quote.";
      window.document.order.subbut.value=" PREVIEW "; 
   }
}


function checkcatall(mode)
{
 var formpos = 0;		// position of form on page
 var max = 0;
 var count = 0;
 var info = "";

   while (document.forms[formpos].elements[max])
   {
      max++;
   }
   max -= 7;

   if (window.document.custom.allcats.checked == true)
   {
      while (count != max)
      {
         info = "idcat" + count;
         if (document.forms[formpos].elements[count].checked==false)	// if not on, display, else it's already on
         {
            if (mode)
               displaycategory (info);

            document.forms[formpos].elements[count].checked=true;		// set all categories to ON
         }
         count++;
      }
   }
   else
   {
      count = 0;
      while (count < max)
      {
         info = "idcat" + count;
         if (document.forms[formpos].elements[count].checked==true)	// if on, now turn it off
         {
            if (mode)
               displaycategory (info);
            document.forms[formpos].elements[count].checked=false;		// set category to off
         }
         count++;
      }
   }
}

function checkcat()
{
   if (window.document.custom.allcats.checked==true)		// show all categories is true
      window.document.custom.allcats.checked=false;		// so turn it off
}


function checkcatstart()
{
 var formpos = 0;
 var max = 0;
 var count = 0;
 var info = "";

   while (document.forms[formpos].elements[max])
   {
      max++;
   }

   max -= 7;

   while (count < max)
   {
      info = "idcat" + count;
      if (document.forms[formpos].elements[count].checked==true || window.document.custom.allcats.checked==true)
         displaycategory (info);
      if (window.document.custom.allcats.checked==true)		// make sure they are all selected
         document.forms[formpos].elements[count].checked=true;
      count++;
   }
}


function displaycategory(the_sub)
{
   if (document.getElementById(the_sub).style.display=="")
   {
      document.getElementById(the_sub).style.display = "none";
      return
   }
   document.getElementById(the_sub).style.display = "";
}

function dispf(the_sub)
{
   if (document.getElementById(the_sub).style.display=="")
   {
      document.getElementById(the_sub).style.display = "none";
      return
   }
   document.getElementById(the_sub).style.display = "";
}

function showem(infob,pos)
{
 var spl = "@";
 var edata=new Array();
 edata[0] = "peter" + spl + "austechmedical.com";
 edata[1] = "david" + spl + "austechmedical.com";
 edata[2] = "andrew" + spl + "austechmedical.com.au";
 edata[3] = "redcliffe" + spl + "austechmedical.com";

 details="<A HREF=\"mailto:" + edata[pos] + "?subject=Contact-from-Web-Site\">" + edata[pos] + "</A>";
 document.getElementById(infob).innerHTML=details;
}

function setem(pos)
{
 var newvalue = "<A HREF=\"javascript:showem('empos0','0');\" class=clse>Click to Display Email Address</A>";
 var newvalue1 = "<A HREF=\"javascript:showem('empos1','1');\" class=clse>Click to Display Email Address</A>";
 var newvalue2 = "<A HREF=\"javascript:showem('empos2','2');\" class=clse>Click to Display Email Address</A>";

 document.getElementById('empos0').innerHTML=newvalue;
 document.getElementById('empos1').innerHTML=newvalue1;
 document.getElementById('empos2').innerHTML=newvalue2;
}