var NN,IE,N6,hideName,showName,coll,styleObj,originX,originY,origWidth,origHeight;
var gTO = null;
var defImg = '';
var currentImg = defImg;
var currentLyr = '';
var kWaitTime = 500;

function stopTimer() {
	if (gTO) {
		clearTimeout(gTO);
		gTO = null;
	}
	return true;
}

function startTimer(imageID) {
	gTO = setTimeout('rollOutMain(\'' + imageID + '\',\'' + imageID + '\'); clearLayers();',kWaitTime);
}

function rollOverMain(imageID, imagename) {

	if (currentImg && (currentImg != imageID)) {
		rollOut(currentImg,currentImg);
	}
	rollOver(imageID, imagename);
	currentImg = imageID;
}

function rollOutMain(imageID, imagename) {
	rollOut(imageID , imagename );
	if (currentImg == imageID) {
		currentImg = defImg;
		if (defImg) {
			rollOver(defImg,defImg);
		}
	}
}

function clearLayers() {
	if (currentLyr) {
		hideLayer(currentLyr);
	}
	currentLyr = '';
}

function rollOverSub(aSection, aNum) {
	stopTimer();
	if (NN) {
		eval('document.i_' + aSection + '.document.images["' + aSection + '_submenu' + aNum + '"].src = eval("g" + aSection + "_submenu" + aNum + "_on" + ".src");');
		} else {
		rollOver(aSection + '_submenu' + aNum, aSection + '_submenu' + aNum);
	}

}


function rollOutSub(aSection,aNum) {
	startTimer(aSection);
	if (NN) {
		eval('document.i_' + aSection + '.document.images["' + aSection + '_submenu' + aNum + '"].src = eval("g" + aSection + "_submenu" + aNum + ".src");');
	} else {
		rollOut(aSection + '_submenu' + aNum, aSection + '_submenu' + aNum);
	}
}

function rollOver(imageID, imagename) {
	if(eval("g" + imagename + "_on")){
		document.images[imageID].src = eval("g" + imagename + "_on" + ".src");
       }
}

function rollOut(imageID, imagename) {
	if(eval("g" + imagename )){
		document.images[imageID].src = eval("g" + imagename + ".src");
       }
}

function rollLayerMain(layerID) {
	if (currentLyr) {
		hideLayer(currentLyr);
	}
	if (layerExists(layerID)) {
		showLayer(layerID);
		currentLyr = layerID;
	}
}



function init() {
	NN = (document.layers ? true : false );
	IE = (document.all ? true : false );
	N6 = ((!IE && document.getElementById) ? true : false );

	hideName = (NN ? 'hide' : 'hidden');
	showName = (NN ? 'show' : 'visible');
	coll = (NN ? '' : 'all.');
	styleObj = (NN ? '' : '.style');

	originX = 0;
	originY = 0;

	if (NN) {
		origWidth = innerWidth;
		origHeight = innerHeight;
	}
}

function reDo() {
	if (NN) {
		if (innerWidth != origWidth || innerHeight != origHeight) {
			location.reload();
		}
	}
}
onresize = reDo;

function getLayer(layer) {
	var theLayer;
	if (typeof layer == 'string' ) {
		if (NN || IE) {
			theLayer = eval("document." + coll + layer);
			if (theLayer) {
				theLayer = eval("theLayer" + styleObj);
			}
		} else if (N6) {
			theLayer = document.getElementById(layer);
			if (theLayer) {
				theLayer = theLayer.style;
			}
		}
	} else {
		theLayer = layer;
	}
	return theLayer;
}

function layerExists(layerName) {
	return (getLayer(layerName) != null);
}

function shiftTo(layer,x,y) {
	var theLayer = getLayer(layer);
	if (NN) {
		theLayer.moveTo(x + originX, y + originY);
	} else if (IE) {
		theLayer.pixelLeft = x + originX;
		theLayer.pixelTop = x + originY;
	} else if (N6) {
		theLayer.pixelLeft = x + originX + "px";
		theLayer.pixelTop = x + originY + "px";
	}
}

function shiftBy(layer,deltaX,deltaY) {
	var theLayer = getLayer(layer);
	if (NN) {
		theLayer.moveBy(deltaX,deltaY);
	} else if (IE) {
		theLayer.pixelLeft += deltaX;
		theLayer.pixelTop += deltaY;
	} else if (N6) {
		theLayer.pixelLeft = parseInt(theLayer.pixelLeft) + deltaX + "px";
		theLayer.pixelTop = parseInt(theLayer.pixelTop) + deltaX + "px";;
	}	
}

function showLayer(layer) {
	var theLayer = getLayer(layer);
	if (theLayer) {
		theLayer.visibility = showName;
	}
}

function hideLayer(layer) {
	var theLayer = getLayer(layer);
	if (theLayer) {
		theLayer.visibility = hideName;
	}
}

function makeLayer(aName, left, top, width, height, vis, copy) {
	left += originX;
	top += originY;
	if (NN) {
		document.writeln('<LAYER NAME="' + aName + '" LEFT="' + left + '" TOP="' + top +
			'" WIDTH="' + width + '" HEIGHT="' + height + 'color: #FFFFFF; " VISIBILITY="' + vis + '">' +
			copy + '\</LAYER>');
	} else {
		document.writeln('<DIV ID="' + aName + '" STYLE="position: absolute; overflow:none; left:' +
			left + 'px; top:' + top + 'px; width:' + width + 'px; background-color: #FFFFFF; color: #FFFFFF; height:' + height + 'px; ' +
			'visibility:' + vis + '; z-index:100;">' + copy + '\</DIV>');
	}
}

// for http links
function goToUrl(X) {
	location = X;
}

function printSpecial()
{
	this.print();
}

function ViewMap(street1, city, state, zip5, street1_to, city_to, state_to, zip5_to)
{	
str = street1 + "&1c="+city + "&1s=" + state + "&1z=" + zip5 + "&Submit=Get+Directions&1y=US&go=1&do=nw&ct=NA&2a="+street1_to+"&2c="+city_to+"2s="+state_to+"&2z=" + zip5_to + "&2y=US";
window.open("http://www.mapquest.com/directions/main.adp?1a=" + street1 + "&1c="+city + "&1s=" + state + "&1z=" + zip5 + "&Submit=Get+Directions&1y=US&go=1&do=nw&ct=NA&2a="+street1_to+"&2c="+city_to+"2s="+state_to+"&2z=" + zip5_to + "&2y=US"
,"ViewImage","toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=550");
}
