﻿//
//	City of Toronto
//	Date: 22-03-2005.
//	Copyright (c) City of Toronto - www.toronto.ca
//

//  CSS rollover fix from HTMLDog (Patrick Griffiths and Dan Webb) - http://www.htmldog.com/articles/suckerfish/
sfHover = function() {
  if (document.getElementById("globalNav") != null) {
    var sfEls = document.getElementById("globalNav").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
        this.className+=" sfhover";
      }
      sfEls[i].onmouseout=function() {
        this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
      }
    }
  }
}
if (window.attachEvent){ window.attachEvent("onload", sfHover)};

//
//  Preload images for dropdowns
//
function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
window.onload="preloadImages('/images/menu1-1_on.gif','/images/menu1-2_on.gif','/images/menu1-3_on.gif','/images/menu1-4_on.gif','/images/menu1-5_on.gif','/images/menu1-6_on.gif','/images/menu1-7_on.gif','/images/menu2-1_on.gif','/images/menu2-2_on.gif','/images/menu2-3_on.gif','/images/menu2-4_on.gif','/images/menu2-5_on.gif','/images/menu2-6_on.gif','/images/menu2-7_on.gif','/images/menu2-8_on.gif','/images/menu3-1_on.gif','/images/menu3-2_on.gif','/images/menu3-3_on.gif','/images/menu3-4_on.gif','/images/menu4-1_on.gif','/images/menu4-2_on.gif','/images/menu4-3_on.gif','/images/menu4-4_on.gif','/images/menu4-5_on.gif','/images/menu4-6_on.gif','/images/menu4-7_on.gif','/images/menu4-8_on.gif','/images/menu4-10_on.gif','/images/section1_title_01.gif','/images/section2_title_01.gif','/images/section3_title_01.gif','/images/section4_title_01.gif')"

//
//
//
function goURL(tempArg){
  this.window.location.href = document.optionsForm.elements[tempArg].options[document.optionsForm.elements[tempArg].selectedIndex].value
}


//
// Javascript css entry
//
function includeCSS() {
  var global = '<style type="text/css" media="screen">@import url("/css/_global.css");</style>';
    var page = '<style type="text/css" media="screen">@import url("/css/_section1.css");</style>';
    var print = '<style type="text/css" media="print">@import url("/css/_print.css");</style>';
    var handheld = '<style type="text/css" media="handheld">@import url("/css/_handheld.css");</style>';
    css = global+page+print+handheld;
  return css;
}
