// Begin Scroll & Logos Code ---------------------------------------------------------------
//
// Scroll Layer Usage example:
// UP: onMouseOver="P7AniMagic('content',0,0,5,30,0,0,false)" onMouseOut="P7AniMagic('content',0,0,1,1,2,0,false)"
// DN: onMouseOver="P7AniMagic('content',0,-800,5,30,0,0,false)" onMouseOut="P7AniMagic('content',0,0,1,1,2,0,false)"
function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
// The loop parameter I've added tells the function
// to use my special code to do the sliding logo bits
// when set to true. When false, this function should
// behave normally (we use it for scrolling, too).
// 
function P7AniMagic(el, x, y, a, b, c, s, loop) { //v2.1 PVII
 var elo=el,f="",m=false,d="";
 x=parseInt(x);y=parseInt(y);





 if (parseInt(s)>0) {





  setTimeout("P7AniMagic(\""+elo+"\",\""+x+"\",\""+y+"\",\""+a+"\",\""+b+"\",\""+c+"\",\""+0+"\","+loop+")", s);





	return;





 }





 if (el.indexOf("?")>0) {p=el.split("?");f="parent.frames['"+p[1]+"'].";el=p[0];}





 if (document.all) {g=eval(f+"document.all['"+el+"']");d=g.style;





 	if(!d.left) {d.left=(!g.currentStyle)?0:g.currentStyle.left;}





  if(!d.top) {d.top=(!g.currentStyle)?0:g.currentStyle.top;}





 }





 else if (document.getElementById) {g=eval(f+"document.getElementById('"+el+"')");d=g.style;





  if(!d.left) {d.left=(!document.defaultView)?0:document.defaultView.getComputedStyle(g,"").getPropertyValue("left");}





	if(!d.top) {d.top=(!document.defaultView)?0:document.defaultView.getComputedStyle(g,"").getPropertyValue("top");}





 }





 else {d=eval(MM_findObj(elo));





 }





 var xx=(parseInt(d.left))?parseInt(d.left):0;





 var yy=(parseInt(d.top))?parseInt(d.top):0;





 if(c==1) {x+=xx;y+=yy;m=true;c=0;}





 else if (c==2) {m=false;clearTimeout(d.p7Magic);}





 else {var i=parseInt(a);





  if (eval(d.moved)){clearTimeout(d.p7Magic);}





  if (xx<x){xx+=i;m=true;if(xx>x){xx=x;}}





  if (xx>x){xx-=i;m=true;if(xx<x){xx=x;}}





  if (yy<y){yy+=i;m=true;if(yy>y){yy=y;}}





  if (yy>y){yy-=i;m=true;if(yy<y){yy=y;}}





  // 





  // My modifications for the logo stuff





  // 





  if (loop==true && xx==326)





  {





  	if (el=="logos1")





	{





		setTimeout("P7AniMagic('logos2',-200,0,1,30,0,0,true)",10);





	}





	else if (el=="logos2")





	{





		setTimeout("P7AniMagic('logos3',-200,0,1,30,0,0,true)",10);





	}





	else if (el=="logos3")





	{





		setTimeout("P7AniMagic('logos4',-200,0,1,30,0,0,true)",10);





	}





	else





	{





		setTimeout("P7AniMagic('logos1',-200,0,1,30,0,0,true)",10);





	}





  }





 }





 if (m) {d.left=xx;d.top=yy;d.moved=true;





  d.p7Magic=setTimeout("P7AniMagic(\""+elo+"\",\""+x+"\",\""+y+"\",\""+a+"\",\""+b+"\",\""+c+"\",\""+0+"\","+loop+")", b);





  }





 else





 {





   d.moved=false;





   //More of my mods - reset the layer when done





   if (loop == true)





   {





		d.left = 526;





		d.top = 0;





   }





 }





}





function startLogos()





{





	i = 1;





	while (i <= 4)





	{





		var id = ("logos" + i);





		P7AniMagic(id,526,0,200,1,0,0,true);





		i++;





	}





	setTimeout("P7AniMagic('logos1',-200,0,1,30,0,0,true)",30);





}











function setContent()





{





	P7AniMagic('content',0,0,600,1,0,0,false);





}











function stopLogos()





{





	i = 1;





	while (i <= 4)





	{





		P7AniMagic("logos" + i,0,0,1,1,2,0);





		i++;





	}











}











function restartLogos()





{





	// alert("here");





	i = 1;





	while (i <= 4)





	{





		var theLogo = MM_findObj("logos" + i);





		if (theLogo)





		{





			// Get the left position





			var leftPos = theLogo.left;





			if(!leftPos)





			{





				leftPos=(!theLogo.currentStyle)?theLogo.style.left:theLogo.currentStyle.left;





			}





			var n = -1





			if (leftPos.indexOf)





			{





				n = leftPos.indexOf("px");





			}





			if (n > -1)





			{





				leftPos = leftPos.substring(0,n);





			}





			// Check the left position to





			// see if this layer is in motion





			if ((parseInt(leftPos)) < 526)





			{





				P7AniMagic("logos" + i,-200,0,1,30,0,0,true);





			}





		}





		i++;





	}





}











// End Scroll & Logos Code -----------------------------------------------------------------

















// Begin Menu Code -----------------------------------------------------------------
// ************************
// layer utility routines *
// ************************
function getStyleObject(objectId) 
{
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) 
	{
		// W3C DOM
		return document.getElementById(objectId).style;
    } 
	else if (document.all && document.all(objectId)) 
	{
		// MSIE 4 DOM
		return document.all(objectId).style;
    } 
	else if (document.layers && document.layers[objectId]) 
	{
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } 
	else 
	{
		return false;
    }
} // End getStyleObject
function changeObjectVisibility(objectId, newVisibility) 
{
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) 
	{
		styleObject.visibility = newVisibility;
		return true;
    } 
	else 
	{
		// we couldn't find the object, so we can't change its visibility
		return false;
    }
} // End changeObjectVisibility
function moveObject(objectId, newXCoordinate, newYCoordinate)
{
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject)
	{
		styleObject.left = newXCoordinate;
		styleObject.top = newYCoordinate;
		return true;
    } 
	else 
	{
		// we couldn't find the object, so we can't very well move it
		return false;
    }





} // End moveObject











function eventHandler(e,index)





{





	// This function is used by NN4.x browsers.





	// NN4 needs to be told to listen for and





	// respond to events on layers.





	var targ = (" " + e.target);





	// alert(targ);





	if (targ.indexOf("Layer") > 0)





	{





		var thisType = (" " + e.type)





		if (thisType.indexOf("over") > 0)





		{





			// A mouseover event





			showMenu(index, e, null, null);





			return true;





		}





		else if (thisType.indexOf("out") > 0)





		{





			// A mouseout event





			delay_hideAllMenus();





			return true;





		} 





	}





	else





	{





		routeEvent(e);





	}	





} // End eventHandler
// ********************************
// application-specific functions *
// ********************************
var currentMenu = -1;
function showMenu(menuNumber, eventObj, x, y) 
{
	stop_everything();
	if (currentMenu != menuNumber)
	{
		hideAllMenus();
	}
	currentMenu = menuNumber;
	// Check to be sure the browser can manipulate layers
	if (document.getElementById || document.all || document.layers)





	{





		var menuId = 'menu' + menuNumber;





		// If x or y is null, then we won't move





		// the div.





		if (x != null && y != null)





		{





			// move popup div to current cursor position 





			// (add scrollTop to account for scrolling for IE)





			// var newXCoordinate = (eventObj.pageX)x:x + ((document.body.scrollLeft)?document.body.scrollLeft:0);





			// var newYCoordinate = (eventObj.pageY)y:y + ((document.body.scrollTop)?document.body.scrollTop:0);





			// moveObject(menuId, newXCoordinate, newYCoordinate);





			// Note: the code above seemed to cause IE5





			// to do the wrong thing when the page was scrolled.





			moveObject(menuId, x, y);





		}





		// Switch the main menu image





		if (MM_findObj("img" + menuNumber))





		{





			var thisImage = MM_findObj("img" + menuNumber);





			// NN4.75 doesn't show the new image for some reason...





			// document[thisImage].src=eval("imgOn.src");





			thisImage.src=imgOn.src;





		}





		





		if(changeObjectVisibility(menuId, 'visible')) 





		{			





			eventObj.cancelBubble = true;





			return true;				





		}





		else





		{





			return false;





		}





	} // End browser check





} // End showMenu











// Initialize the timer ID





var menu_timer = 0;











function delay_hideAllMenus()





{
	// Delays 300ms before hiding the menu
	// Helps minimize flicker and makes things
	// a little more user-friendly
	menu_timer = setTimeout("hideAllMenus()",300);
}
function hideAllMenus()
{
	stop_everything();
	// Check to be sure the browser can manipulate layers
	if (document.getElementById || document.all || document.layers)
	{





		for(counter = 1; counter <= numMenus; counter++) 





		{





			changeObjectVisibility("menu" + counter,"hidden");





			// Switch the main menu image





			if (MM_findObj("img" + counter))





			{





				var thisImage = MM_findObj("img" + counter);





				if (counter != currentSection)





				{





					thisImage.src=imgOff.src;





				}





				else





				{





					thisImage.src=imgOn.src;





				}





			}





		}





	} // End browser check





} // End hideAllMenus











function stop_everything() {





	// This clears any delayed events





	if(menu_timer > 0) {





		clearTimeout(menu_timer);





		menu_timer = 0;





	}





} // End stop_everything











function highLight(element, action)





{





	// Highlights elements in submenus
	if (action == "on")
	{
		getStyleObject(element + "a").backgroundColor=subMenuHighlightColor;
		getStyleObject(element + "b").backgroundColor=subMenuHighlightColor;
	}
	else





	{





		getStyleObject(element + "a").backgroundColor=subMenuNormalColor;





		getStyleObject(element + "b").backgroundColor=subMenuNormalColor;





	}





}











var currentSection = "";





function sectionHighlight(section)





{





	if (section) {currentSection = section;}





	MM_findObj("img" + section).src=eval("http://www.integresource.ca/imgOn.src");





	return true;





}











// ***********************
// hacks and workarounds *
// ***********************
// initialize hacks whenever the page loads
window.onload = initializeHacks;
// setup an event handler to hide popups for generic clicks on the document
document.onClick = hideAllMenus();
function initializeHacks() 
{
    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}
function createFakeEventObj() 
{
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) 
	{
		window.event = false;
    }
} // createFakeEventObj
function explorerMacResizeFix () 
{
    location.reload(false);
}
// ************************
// Configuration
// ************************
// Known issues:
//
// 1. NN4.75 Windows
//    a. highlights do not work on pop up menu
//       due to the fact that you can't get a
//       reference to a style object on nested
//       layers in NN4. Also appears to be the
//       case in Opera 5.02.
//
// 2. NN6.01 Windows
//    a. the "outlines" on the pop up
//       menu table vanish. These are set in the styles.
//       No idea what the trouble is.
//
// 3. Browsers that don't do layers
//    a. simply put, it's a mess. Hidden layers are displayed.
//
// Tested on: Win2K -- MSIE 5.5, NN 4.75, NN 6.02, Opera 5.02
//
// DHTML pop-up menus adapted (read "butchered")
// from Apple's developer site:
// http://developer.apple.com/internet/_javascript/hideshow_layer.html
//
var numMenus = 24;		// change from 13 to 24  12-01-06 by deb venn
var subMenuHighlightColor = "#000000";
var subMenuNormalColor = "#0066cc";
imgOn=new Image();
imgOn.src ="images/mainmenu_on.gif";
imgOff=new Image();
imgOff.src ="images/mainmenu_off.gif";
arrowMoreOn=new Image();
arrowMoreOn.src ="http://www.integresource.ca/images/arrow_more_on.gif";
arrowMoreOff=new Image();
arrowMoreOff.src ="http://www.integresource.ca/images/arrow_more.gif";
arrowLessOn=new Image();
arrowLessOn.src ="http://www.integresource.ca/images/arrow_less_on.gif";
arrowLessOff=new Image();
arrowLessOff.src ="http://www.integresource.ca/images/arrow_less.gif";
// End menu code -------------------------------------------------------------------

