/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
map = function ()
{
	imgString = ""
	for (i=1;i<9;i++){
		imgString = imgString + "map-0" + i + ".gif, ";
	}
	MM_preloadImages(imgString);
}

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];}}
	createHoverImg()
}

createHoverImg = function() {  
  root = document.getElementById('mapPane');
  newImg = document.createElement('img');
  newImg.id = "hoverImg";
  root.insertBefore(newImg,root.firstChild);
  newImg.width = 249;
  newImg.height = 291;
  newImg.useMap = "#Map"
  newImg.src = "/resources/img/spacer.gif"
  setImageCallback()
}

setImageCallback = function ()
{
    this.globalStateKey = Math.random();
    
    var elementList = document.getElementById('Map').childNodes;
    for (var i=0; i < elementList.length; ++i)
    {
        elementList[i].parent = this;
        elementList[i].onmouseover = imageRolledOver;
        elementList[i].onmouseout = imageRolledOut;
        
        elementList[i].contextReference = this;
        elementList[i].privateStateKey = globalStateKey;
    }
}

printSomething = function (label)
{
    window.status=label + ' ' + (new Date()).getTime();
}

imageRolledOver = function ()
{
    if ( this.privateStateKey != this.contextReference.globalStateKey ) return;
	baseOpacity=0;
    baseRegion=document.getElementById('mapPane').getElementsByTagName('p')[0].childNodes[0];
    setImgSrc(this.id);
    //fadeIn(baseOpacity);
	baseRegion.nodeValue = this.alt.replace(". ","");
}

imageRolledOut = function ()
{
    if ( this.privateStateKey != this.contextReference.globalStateKey ) return;
    baseOpacity=0;
    baseRegion=document.getElementById('mapPane').getElementsByTagName('p')[0].childNodes[0];
    baseRegionValue=baseRegion.nodeValue;
    //fadeOut(baseOpacity);
    baseRegion.nodeValue = baseRegionValue;
}

setImgSrc = function(imgId){
  root = document.getElementById('hoverImg')
  if ( root == null ) return;
  if (imgId == "blank"){
    root.src = "/resources/img/spacer.gif";
  } else {
    root.src = "/resources/img/find-us/map-" + imgId + ".gif";
  }
}

getRegions = function() {
	
}


/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

fadeIn = function(baseopacity,imgId){
	imgobj=document.getElementById('hoverImg')
	browserdetect=imgobj.filters? "ie" : typeof imgobj.style.MozOpacity=="string"? "mozilla" : ""
	instantset(baseopacity)
	highlighting=setInterval("gradualfade(imgobj)",100)
}

fadeOut = function(baseopacity){
	cleartimer()
	instantset(baseopacity)
}

instantset = function(degree){
	if (browserdetect=="mozilla")
		imgobj.style.MozOpacity=degree/100
	else if (browserdetect=="ie") {;
		if(!imgobj.filters) alert("something not right");
		imgobj.style = "filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);"
		//alert(imgobj.style)
		imgobj.filters.alpha.opacity=degree
	}
}

cleartimer = function(){
	if (window.highlighting) clearInterval(highlighting)
}

gradualfade = function(cur2){
	if (browserdetect=="mozilla" && cur2.style.MozOpacity<1){
		cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.2, 0.99)
	}
	else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100){
		cur2.filters.alpha.opacity+=20
	}
	else if (window.highlighting)
		clearInterval(highlighting)
}