/*****************************************************
* ypSlideOutMenu
* 3/04/2001
*
* a nice little script to create exclusive, slide-out
* menus for ns4, ns6, mozilla, opera, ie4, ie5 on
* mac and win32. I've got no linux or unix to test on but
* it should(?) work...
*
* --youngpup--
*****************************************************/
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 650
ypSlideOutMenu.hideDelay = 325
ypSlideOutMenu.minCPUResolution = 10
// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
this.ie = document.all ? 1 : 0
this.ns4 = document.layers ? 1 : 0
this.dom = document.getElementById ? 1 : 0
if (this.ie || this.ns4 || this.dom) {
this.id = id
this.dir = dir
this.orientation = dir == "left" || dir == "right" ? "h" : "v"
this.dirType = dir == "right" || dir == "down" ? "-" : "+"
this.dim = this.orientation == "h" ? width : height
this.hideTimer = false
this.aniTimer = false
this.open = false
this.over = false
this.startTime = 0
// global reference to this object
this.gRef = "ypSlideOutMenu_"+id
eval(this.gRef+"=this")
// add this menu object to an internal list of all menus
ypSlideOutMenu.Registry[id] = this
var d = document
d.write('')
this.load()
}
}
ypSlideOutMenu.prototype.load = function() {
var d = document
var lyrId1 = this.id + "Container"
var lyrId2 = this.id + "Content"
var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
var temp
if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
else {
this.container = obj1
this.menu = obj2
this.style = this.ns4 ? this.menu : this.menu.style
this.homePos = eval("0" + this.dirType + this.dim)
this.outPos = 0
this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen
// set event handlers.
if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
// this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
// this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")
//set initial state
this.endSlide()
}
}
ypSlideOutMenu.showMenu = function(id)
{
var reg = ypSlideOutMenu.Registry
var obj = ypSlideOutMenu.Registry[id]
if (obj.container) {
obj.over = true
// if this menu is scheduled to close, cancel it.
if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
// if this menu is closed, open it.
if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
}
}
ypSlideOutMenu.hideMenu = function(id)
{
// schedules the menu to close after ms, which
// gives the user time to cancel the action if they accidentally moused out
var obj = ypSlideOutMenu.Registry[id]
if (obj.container) {
if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
}
}
ypSlideOutMenu.hide = function(id)
{
var obj = ypSlideOutMenu.Registry[id]
obj.over = false
if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
// flag that this scheduled event has occured.
obj.hideTimer = 0
// if this menu is open, close it.
if (obj.open && !obj.aniTimer) obj.startSlide(false)
}
ypSlideOutMenu.prototype.startSlide = function(open) {
this[open ? "onactivate" : "ondeactivate"]()
this.open = open
if (open) this.setVisibility(true)
this.startTime = (new Date()).getTime()
this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}
ypSlideOutMenu.prototype.slide = function() {
var elapsed = (new Date()).getTime() - this.startTime
if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
else {
var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
if (this.open && this.dirType == "-") d = -d
else if (this.open && this.dirType == "+") d = -d
else if (!this.open && this.dirType == "-") d = -this.dim + d
else d = this.dim + d
this.moveTo(d)
}
}
ypSlideOutMenu.prototype.endSlide = function() {
this.aniTimer = window.clearTimeout(this.aniTimer)
this.moveTo(this.open ? this.outPos : this.homePos)
if (!this.open) this.setVisibility(false)
if ((this.open && !this.over) || (!this.open && this.over)) {
this.startSlide(this.over)
}
}
ypSlideOutMenu.prototype.setVisibility = function(bShow) {
var s = this.ns4 ? this.container : this.container.style
s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) {
this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : (p) + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
return parseInt(this.style[c])
}
// events
ypSlideOutMenu.prototype.onactivate = function() { }
ypSlideOutMenu.prototype.ondeactivate = function() { }
var yPosition = 188;
//new ypSlideOutMenu("number menu", "slide position", left, top, width, height)
new ypSlideOutMenu("menu0", "down", 21, yPosition, 209, 154)
new ypSlideOutMenu("menu1", "down", 229, yPosition, 195, 305)
new ypSlideOutMenu("menu2", "down", 423, yPosition, 226, 27)
new ypSlideOutMenu("menu3", "down", 618, yPosition, 142, 105)
new ypSlideOutMenu("menu4", "right", 229, yPosition, 160, 52)
new ypSlideOutMenu("menu5", "right", 423, yPosition, 210, 355)
new ypSlideOutMenu("menu6", "right", 423, yPosition, 210, 305)
new ypSlideOutMenu("menu7", "right", 423, yPosition, 100, 230)
new ypSlideOutMenu("menu8", "right", 522, yPosition + 129, 150, 101)
/**********************************
End of drop down menus
**********************************/
function ChangeFontSize(id, size) {
document.getElementById(id).style.fontSize = size + "px";
}
function showLayer(id) {
var lyr = getElemRefs(id);
if (lyr && lyr.css) lyr.css.visibility = "visible";
}
function hideLayer(id) {
var lyr = getElemRefs(id);
if (lyr && lyr.css) lyr.css.visibility = "hidden";
}
function getElemRefs(id) {
var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
if (el) el.css = (el.style)? el.style: el;
return el;
}
//original code written by Dan Steinman
ns = (document.layers)? true:false
ie = (document.all)? true:false
function preload(imgObj,imgSrc) {
if (document.images) {
eval(imgObj+' = new Image()')
eval(imgObj+'.src = "'+imgSrc+'"')
}
}
preload('img0off','http://www.county.peterborough.on.ca/pics/link.government.out.gif')
preload('img1off','http://www.county.peterborough.on.ca/pics/link.departments.out.gif')
preload('img2off','http://www.county.peterborough.on.ca/pics/link.documents.out.gif')
preload('img3off','http://www.county.peterborough.on.ca/pics/link.county.out.gif')
preload('img4off','http://www.county.peterborough.on.ca/pics/link.loom.out.gif')
preload('img5off','http://www.county.peterborough.on.ca/pics/link.bustour.out.gif')
preload('img6off','http://www.county.peterborough.on.ca/pics/link.press.out.gif')
preload('img7off','http://www.county.peterborough.on.ca/pics/link.contact.out.gif')
preload('img8off','http://www.county.peterborough.on.ca/pics/link.links.out.gif')
preload('img9off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img10off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img11off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img12off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img13off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img14off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img15off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img16off','http://www.county.peterborough.on.ca/pics/blank.out.gif')
preload('img0on','http://www.county.peterborough.on.ca/pics/link.government.over.gif')
preload('img1on','http://www.county.peterborough.on.ca/pics/link.departments.over.gif')
preload('img2on','http://www.county.peterborough.on.ca/pics/link.documents.over.gif')
preload('img3on','http://www.county.peterborough.on.ca/pics/link.county.over.gif')
preload('img4on','http://www.county.peterborough.on.ca/pics/link.loom.over.gif')
preload('img5on','http://www.county.peterborough.on.ca/pics/link.bustour.over.gif')
preload('img6on','http://www.county.peterborough.on.ca/pics/link.press.over.gif')
preload('img7on','http://www.county.peterborough.on.ca/pics/link.contact.over.gif')
preload('img8on','http://www.county.peterborough.on.ca/pics/link.links.over.gif')
preload('img9on','http://www.county.peterborough.on.ca/pics/link.home.over.gif')
preload('img10on','http://www.county.peterborough.on.ca/pics/link.siteindex.over.gif')
preload('img11on','http://www.county.peterborough.on.ca/pics/link.events.over.gif')
preload('img12on','http://www.county.peterborough.on.ca/pics/link.headlines.over.gif')
preload('img13on','http://www.county.peterborough.on.ca/pics/link.maps.over.gif')
preload('img14on','http://www.county.peterborough.on.ca/pics/link.faqs.over.gif')
preload('img15on','http://www.county.peterborough.on.ca/pics/link.contactus.over.gif')
preload('img16on','http://www.county.peterborough.on.ca/pics/link.sitesearch.over.gif')
function swapPic(layer,imgName,imgObj) {
if (document.images) {
if ((ns) && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
else document.images[imgName].src = eval(imgObj+".src");
}
}
var popUp = null;
var chasm = screen.availWidth;
var mount = screen.availHeight;
var w = 0;
var h = 0;
function openWindow(url,w,h) {
popUp = window.open(url,'','width=' + w + ',height=' + h + ',left=' + ((chasm - w - 10) * .5) + ',top=' + ((mount - h - 30) * .5));
}
/*In the event the user changes the dimensions of their browser window
call the 'findWindowDim' function*/
function findWindowDim(){
/*
Constructing the function to work with Netscape 6 (innerHeight)
and Netscape 7+, Mozilla 1.0.1+ and IE6+ (clientHeight).
Determining browser type by functionality.
Start IE5+, NS7 and Mozilla based on build 1.0.1
*/
var leftHeight = document.getElementById('leftwrapper').offsetHeight;
var centerHeight = document.getElementById('centerwrapper').offsetHeight;
var rightHeight = document.getElementById('rightwrapper').offsetHeight;
var mastheadHeight = document.getElementById('mhwrapper').offsetHeight;
var objFooter = document.getElementById('footer');
var objLeft = document.getElementById('leftcolumn');
var objRight = document.getElementById('rightcolumn');
var objCenter = document.getElementById('centercolumn');
// set top of 3 columns
colTop = mastheadHeight+5+"px";
objLeft.style.top = colTop;
objCenter.style.top = colTop;
objRight.style.top = colTop;
if ((centerHeight > leftHeight) && (centerHeight > rightHeight)) {
footerTop = mastheadHeight + centerHeight-2;
footerTopPx = footerTop+5+"px";
objFooter.style.top = footerTopPx;
colHeight = centerHeight;
lHeight = colHeight+"px";
objLeft.style.height = lHeight;
objRight.style.height = lHeight;
}
else if ((leftHeight > centerHeight) && (leftHeight > rightHeight)) {
footerTop = mastheadHeight + leftHeight-2;
footerTopPx = footerTop+"px";
objFooter.style.top = footerTopPx;
colHeight = leftHeight;
lHeight = colHeight+"px";
objRight.style.height = lHeight;
objCenter.style.height = lHeight;
}
else {
footerTop = mastheadHeight + rightHeight-2;
footerTopPx = footerTop+"px";
objFooter.style.top = footerTopPx;
colHeight = rightHeight;
lHeight = colHeight+"px";
objLeft.style.height = lHeight;
objCenter.style.height = lHeight;
}
}
function ChangeFontSize(left, centre, right, size) {
var lineheight = eval(size)+4+"px";
document.getElementById(left).style.fontSize = size + "px";
document.getElementById(left).style.lineHeight = lineheight;
document.getElementById(centre).style.fontSize = size + "px";
document.getElementById(centre).style.lineHeight = lineheight;
document.getElementById(right).style.fontSize = size + "px";
document.getElementById(right).style.lineHeight = lineheight;
self.focus();
findWindowDim();
}
// EyeCreate's Javascript code, copyright 2002
// swap cell/row colour javascript functions
// Feel free to borrow and modify this javascript,
// but be sure leave this credit in the source!
// -Ken Tuck-
// http://www.eyecreate.net/
function swapBGcell(el, BGC1) {
if(document.getElementById||(document.all && !(document.getElementById))){
temp=el.style.backgroundColor;
el.style.backgroundColor=BGC1;
}
}
function swapBGcellBack(el) {
if(document.getElementById||(document.all && !(document.getElementById))){
el.style.backgroundColor=temp;
}
}
function swapBGrow(el, BGR1, BGR2) {
if(document.getElementById||(document.all && !(document.getElementById))){
el.style.backgroundColor = (el.style.background == BGR1) ? BGR2 : BGR1;
}
}
function showThis(tgt) {
document.getElementByID(tgt).style.visibility = "visible";
}
function hideThis(tgt) {
document.getElementByID(tgt).style.visibility = "hidden";
}
function getLocation(tgt) {
location.href=tgt;
}
function OpenLogin() // 1. NEED THIS FUNCTION
{
var tar = "http://maps.county.peterborough.on.ca/webgis/login/login1.cfm" ;
var par = "height=300,width=400,left=100,top=100,location=no,resizable=yes" ;
window.open(tar,"login",par) ;
}