/* Altuit Button Script -- Version .9 */
/* send error reports to chris@altuit.com */
/* all buttons should be named in the following manner */
/* [normal btn]_x.jpg */
/* [over btn]_over_x.jpg */
/* [down btn]_down_x.jpg */

var buttons = [];
var images = [];

var supportsJS = 'yes';

function altButton(imageName,imageType,webName,rootName,lurl) 
{
   images[imageName+'_up'] = new Image;
   images[imageName+'_over'] = new Image;
   images[imageName+'_down'] = new Image;
  
      images[imageName+'_up'].src = '../'+rootName+'/'+imageName+'_x.'+imageType;
      images[imageName+'_over'].src = '../'+rootName+'/'+imageName+'_over_x.'+imageType;
      images[imageName+'_down'].src = '../'+rootName+'/'+imageName+'_down_x.'+imageType;

   
   this.webName = webName;
   this.curState = 'up';
   this.buttonName = imageName;
   this.url = lurl;
   this.id = buttons.length;
  buttons[this.id] = this;

  /* load the images */
   altButton_init(this);
   	
  /* change state if down */
   if( isButtonDown(this.webName) )
	altButton_ChangeState(this.id);
}

function orient()
{
       // supportsJS='no';
    if(!document.all)
     {
	if(document.layers)
	   document.all=document.layers;
	  else 	
           if(document.getElementById) 
		document.all = document.getElementById;	
	   else
		supportsJS = 'no';
	}
    if(!document.images)
        supportsJS = 'no';
  
}


function altButton_init(parent)
{
  orient();
  document.write('<td>');
 // alert(supportsJS);
  if (supportsJS == 'yes')
 	 document.write('<img id="' + parent.buttonName + '" onmouseover="altButton_onmouseover('+parent.id+')"   onmouseout="altButton_onmouseout('+parent.id+')" onmousedown="altButton_onmousedown('+parent.id+')" onclick="altButton_onclick('+parent.id+')" src="' + images[parent.buttonName+'_up'].src +'" />');
    else
        document.write('<font size="1"><a href="'+parent.url+'">'+parent.buttonName+'</a>&nbsp;|</font>');
  document.write('</td>');
}

function altButton_onmouseover(id)
{
  var mbutton = buttons[id];
  if (mbutton.curState != 'down')
        document.all(mbutton.buttonName).src = images[mbutton.buttonName+'_over'].src;

}

function altButton_onmouseout(id)
{
  var mbutton = buttons[id];

  if (mbutton.curState != 'down')
        document.all(mbutton.buttonName).src = images[mbutton.buttonName+'_up'].src;
}

function altButton_onmousedown(id)
{
  var mbutton = buttons[id];

  if (mbutton.curState != 'down')
        document.all(mbutton.buttonName).src = images[mbutton.buttonName+'_down'].src;
}

function altButton_onclick(id)
{
  var mbutton = buttons[id];

  if(mbutton.curState != 'down')
    window.location = mbutton.url;
}

function altButton_ChangeState(id)
{
  var mbutton = buttons[id];

  if(supportsJS== 'yes')
    document.all(mbutton.buttonName).src = images[mbutton.buttonName+'_down'].src;
  mbutton.curState = 'down';
}

function isButtonDown(bName)
{
   //check to see if the button is the same as the meta tag in this page
      if(typeof(document.getElementById('webname')) == 'object')
         if(typeof(document.getElementById('webname').name)!= 'undefined')
            { 
             if(document.getElementById('webname').name.toLowerCase() == bName.toLowerCase())
                return true;
             else
   	         return false;
             } 
	  else
		return false;
       else
	   return false;
}

  document.write('<table border="0" cellspacing="0" cellpadding="0"><tr>');
 /*parameter list for altbutton  buttonName,buttonType,button home web,home web,url to go to  */
 new altButton('home','jpg','buttongadget','buttonsets','../buttongadget/default.htm');   
  new altButton('manual','jpg','manual','buttonsets','../manual/gettingstarted.htm');
  new altButton('download','jpg','download','buttonsets','../download/default.htm');
  new altButton('registration','jpg','registration','buttonsets','../registration/default.htm');
 new altButton('buttonsets','jpg','buttonsets','buttonsets','../buttonsets/default.htm');

  document.write('</tr></table>');

