function MM_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=MM_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 MM_swapImgRestore() { //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 MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2]; height='auto'; width='auto';}
}

function popWin(url) {
window.open(url,'','width=610,height=600,alwaysRaised=yes,toolbar=no,directories=no,status=yes,scrollbars=yes,location=no,menubar=no,resizable=yes,top=yes')
}

function tourWin(url) {
window.open(url,'','width=570,height=530,alwaysRaised=yes,toolbar=no,directories=no,status=yes,scrollbars=no,location=no,menubar=no,resizable=no,top=yes')
}






// initRollovers - Find all images that have the class "roll", and set events for each (avoids needing to add event handling to image tags)
// - loops through all image tags on the page, and skips any that have no 'roll' class

function initRollovers()
{
  // Set rollstate variable (this is typically either 'on' or 'over')
  var roll_state = "over";
  // Loop through all im if they contain the class roll
  var imgs=document.getElementsByTagName('img');
  for(i=0;i<imgs.length;i++){
    img_obj = imgs[i];
    if(/roll/.test(img_obj.className)){

      // add the function roll to the parent Element (i.e a href) of the image
      img_obj.parentNode.onmouseover=function(){rollOver(this, roll_state);};
      img_obj.parentNode.onmouseout=function(){rollOver(this, '');};
      img_obj.parentNode.onfocus=function(){rollOver(this, roll_state);};
      img_obj.parentNode.onblur=function(){rollOver(this, '');};
      // Preload images (on and over variations)
      img_width = img_obj.width;
      img_height = img_obj.height;
      img_name = img_obj.id;
      img_ext = img_obj.src.substring(img_obj.src.lastIndexOf('.'), img_obj.src.length);

      // Preload 'over' images (if applicable)
      img_name_over = img_name.replace("_button", "_over");
      eval (img_name_over + " = new Image(" + img_width + "," + img_height + ")" );
      eval (img_name_over + ".src = \"" + img_obj.src.replace(img_ext, "_over" + img_ext) + "\"");

      // Preload 'on' images (if applicable)
      img_name_on = img_name.replace("_button", "_on");
      eval (img_name_on + " = new Image(" + img_width + "," + img_height + ")" );
      eval (img_name_on + ".src = \"" + img_obj.src.replace(img_ext, "_on" + img_ext) + "\"");
    }
  }
}



function rollOver(obj, rollstate){
  var i,isnode,src,ftype,newsrc,nownode;
  // loop through all childNodes (i.e. img within a)
  for (i=0;i<obj.childNodes.length;i++){
    nownode=obj.childNodes[i];
    // if the node is an element and an IMG set the variable and exit the loop
    if(nownode.nodeType==1 && /img/i.test(nownode.nodeName)){
      isnode=i;
      break;
    }
  }
  // check src and do the rollover
  img_src = obj.childNodes[isnode].src;
  ftype = img_src.substring(img_src.lastIndexOf('.'), img_src.length);
  if(/_on/.test(img_src)){
    currstate = 'on';
  }
  else if(/_over/.test(img_src)){
    currstate = 'over';
  }
  else{
    currstate = '';
  }
  newsrc = '';
  if (currstate != rollstate){
    newsrc = img_src.replace(ftype, '_'+rollstate+ftype);
  }
  else{
    return;
  }
  if (rollstate.length == 0){
    newsrc = img_src.replace('_'+currstate, '');
  }
  if (newsrc.length != 0){
    obj.childNodes[isnode].src=newsrc;
  }
}