
// global variables

var cachedImages = new Array();
var chambDropdownMenu = null;
var mouseOverBuffer = null;
var mouseOverBufferTwo = null;

window.onresize = resizeHandler;
window.onload = init;


// imageCaching code, to be eventually outmoded by cacheImages();
if (document.images) {
	property_on = new Image();
	property_off = new Image();
	property_over = new Image();
	property_off.src = dirUp + "images/space_lease_button.gif"
	property_on.src = dirUp + "images/space_lease_button_mo.gif"
	property_over.src = dirUp + "images/space_lease_button_mo.gif"

	sites_on = new Image();
	sites_off = new Image();
	sites_over = new Image();
	sites_off.src = dirUp + "images/develop_sites_button.gif"
	sites_on.src = dirUp + "images/develop_sites_button_mo.gif"
	sites_over.src = dirUp + "images/develop_sites_button_mo.gif"

	tenant_on = new Image();
	tenant_off = new Image();
	tenant_over = new Image();
	tenant_off.src = dirUp + "images/tenant_area_button.gif"
	tenant_on.src = dirUp + "images/tenant_area_button_mo.gif"
	tenant_over.src = dirUp + "images/tenant_area_button_mo.gif"
	
	services_on = new Image();
	services_off = new Image();
	services_over = new Image();
	services_off.src = dirUp + "images/develop_services_button.gif"
	services_on.src = dirUp + "images/develop_services_button_mo.gif"
	services_over.src = dirUp + "images/develop_services_button_mo.gif"
}


/* your everyday rollover function */
function roll(divName, imgName, which) {
	if ((is.ns4)&&(divName!=-1)) {
		var imgObject = eval("document." + divName +".document.images['"+imgName +"_image']");
		imgObject.src = eval(imgName + "_" + which + ".src");
	}	
	else {
		document.images[imgName +"_image"].src = eval(imgName + "_" + which + ".src");
	} 
}


// function to look actively into the document for img tags with offimage and overimage attributes, setting up a cached img object for those it finds. 
function cacheImages() {
	for (i=0; i<document.images.length; i++) {
		var workingImage = document.images[i];
		if (workingImage.getAttribute("overimage") && workingImage.getAttribute("offimage")) {
			eval("workingImage.onmouseover = function() {this.src = cachedImages['"+workingImage.getAttribute('overimage')+"'].src;}");
			eval("workingImage.onmouseout = function() {this.src = cachedImages['"+workingImage.getAttribute('offimage')+"'].src;}");
			var index = cachedImages.length;
			cachedImages[""+workingImage.getAttribute('overimage')] = new Image(); 
			cachedImages[""+workingImage.getAttribute('overimage')].src = workingImage.getAttribute('overimage')
			cachedImages[""+workingImage.getAttribute('offimage')] = new Image(); 
			cachedImages[""+workingImage.getAttribute('offimage')].src = workingImage.getAttribute('offimage')
		}
	}
}


// function that can be explicitly called from <input type="image"> objects.  (Since these do not appear in the images array, they cant be taken care of with cacheImages.   If the input element has onload="setupButtonRollover(this)", and also has both overimage and offimage attributes, a rollover will be setup on it. 
function setupButtonRollover(elt) {
	if (elt.getAttribute("overimage") && elt.getAttribute("offimage")) {			
		eval("elt.onmouseover = function() {elt.src ='"+elt.getAttribute('overimage')+"'}");
		eval("elt.onmouseout = function() {elt.src ='"+elt.getAttribute('offimage')+"'}");
	}
}


//  not strictly necessary, as this is a fixed width and left-justified implementation

function resizeHandler() {
	if (chambDropdownMenu) chambDropdownMenu.setupMenuPositions();
}

function mouseMoveHandler(e){
	if (chambDropdownMenu) chambDropdownMenu.mouseMoveHandler(e);
}

function potentiallyCloseSubnav() {
	if (chambDropdownMenu) chambDropdownMenu.potentiallyCloseSubnav();
}

function potentiallyCloseSubSubnav() {
	if (chambDropdownMenu) chambDropdownMenu.potentiallyCloseSubSubnav();
}

function menuMouseOut() {
	if (chambDropdownMenu) chambDropdownMenu.menuMouseOut();
}

function subMenuMouseOut() {
	if (chambDropdownMenu) chambDropdownMenu.subMenuMouseOut();
}


function pulldownRedirect(formName) {
	var selectReference = eval("document."+formName+".innerSelectElement");
	var projectName = selectReference[selectReference.selectedIndex].value;
	if (projectName != "")  document.location = projectName;
}

var popupWin;
function popup(url,w,h,target,windowOptions) {
	if ((!target)||(target=="")) target="_blank";
	if ((!windowOptions)||(windowOptions==""))  windowOptions= 'scrollbars,titlebar,resizable';
	popupWin = window.open(url,target,'width='+w+',height='+h+','+windowOptions);
	setTimeout("popupWin.focus();",250);
}

var nIE4Win;    
var nCanPrint;
var printed;

function printme() {
        printed = "no";
        if (window.print) {
                nCanPrint = "yes";
        } else {
                nCanPrint = "no";
        }

    var agt=navigator.userAgent.toLowerCase()

    nVersion = parseInt(navigator.appVersion);
    nIE  = (agt.indexOf("msie") != -1);
    nWin   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
        nMac = (agt.indexOf("mac") != -1);
        nIE4Win  = (nIE && (nVersion == 4) && nWin);
        doPrint();
}

function doPrint() {
        if (nCanPrint == "yes") {
                printed="yes";
                window.print();

        } else if (nIE4Win) {
                printed="yes";
                IEPrint();
        }
        else
        {
        alert("To print this page, click your browser's Print button or select File - Print from your browser menu.");          
        }
}
