/*
//////////////////////////////////////////////////////////////////////////////////////////////////////
GLOBAL JAVASCRIPTS FOR AAII.com v2.0
Created by Tony Piscotti on 6/3/2004
Code may not be distributed without consent of the author
///////////////////////////////////////////////////////////////////////////////////////////////////////
*/



/// GLOBAL ROLLOVER SCRIPT

function swapRestore() { //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 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=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 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=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function figures(url) {

link = window.open(url,"figures","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width=800,height=500,left=100,top=50");

}


function pdf(url) {
window.open(url,"pdf","toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=yes,resizable=no,width=400,height=332,left=50,top=50");
}


function iframeDesc(url) {
window.open(url,"iframeDesc","toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=yes,resizable=no,width=400,height=332,left=50,top=50");
}


//// POP-UP WINDOW SCRIPT
/*
function Image(url) {

 window.open(url,"Image","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=600,height=520,left=100,top=100");

}

*/





//// DISABLE RIGHT-CLICK ON IMAGES ONLY
/*
function right(e) {
var msg = "Sorry, you don't have permission to right-click on images at AAII.com.";
if (navigator.appName == 'Netscape' && e.which == 3) {
alert(msg);
return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
alert(msg);
return false;
}
else return true;
}

function trap() 
  {
  if(document.images)
    {
    for(i=0;i<document.images.length;i++)
      {
      document.images[i].onmousedown = right;
      document.images[i].onmouseup = right;
      }
    }
  }
*/







//// DISABLE STATUS BAR SCRIPT

//Hide status bar msg II script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
/*
function hidestatus(){
window.status=''
return true
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover=hidestatus
document.onmouseout=hidestatus
*/







//  DISABLE DRAG / HIGHLIGHT TEXT SELECT ABILITY

//Disable select-text script (IE4+, NS6+)- By Andy Scott
//Exclusive permission granted to Dynamic Drive to feature script
//Visit http://www.dynamicdrive.com for this script 

/*
function disableselect(e){
return false
} 
  
function reEnable(){
return true
} 
  
//if IE4+
document.onselectstart=new Function ("return false") 
  
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}

*/



//  FORM AUTO-TAB

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}



//  BOOKMARK SCRIPT

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}