// contstants

nav = new Array(
		new Array("company", "company.html", new Array(
				new Array("property", "property.html"),
				new Array("leasing", "leasing.html"),
				new Array("development", "development.html")
			)
		),
		new Array("portfolio", "portfolio.html", new Array()),
		new Array("space", "space.html", new Array()),
		new Array("projects", "projects.html", new Array()),
		new Array("team", "team.html", new Array()),
		new Array("contact", "contact.html", new Array()),
		new Array("sitemap", "sitemap.html", new Array())
	);
	
nav_cnt = nav.length;
nav_step = 10;
nav_img_width = 123;
nav_img_path = "images/";
nav_spacer = false;
nav_spacer_width = 20;

var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var NS6 = (document.getElementById && !document.all) ? true : false;


// variable arrays

nav_unlinked = new Array();
nav_linked = new Array();
subnav_unlinked = new Array();
subnav_linked = new Array();
subnav_count = new Array();
on = new Array();
off = new Array();

   
// image preload script

for(i = 0; i < nav_cnt; i++) {
	id = (i + 1);
	nav_id = id * nav_step;
	on[nav_id] = new Image();
	on[nav_id].src = nav_img_path + "nav_" + nav[i][0] + "_on.gif";
	off[nav_id] = new Image();
	off[nav_id].src = nav_img_path + "nav_" + nav[i][0] + "_off.gif";

	subnav_count[nav_id] = nav[i][2].length;
	for(j = 0; j < subnav_count[nav_id]; j++) {
		subnav_id = nav_id + (j + 1);
		on[subnav_id] = new Image();
		on[subnav_id].src = nav_img_path + "subnav_" + nav[i][2][j][0] + "_on.gif";
		off[subnav_id] = new Image();
		off[subnav_id].src = nav_img_path + "subnav_" + nav[i][2][j][0] + "_off.gif";
	}
}


function writeNav(section,page) {

	for(i = 0; i < nav_cnt; i++) {
		id = (i + 1);
		nav_id = id * nav_step;
		nav_unlinked[id] = '<div id="nav' + nav_id + '" style="position:relative; z-index:30"><a href="' + nav[i][1] + '" onMouseOver="hideTimer(\'stop\',' + nav_id + '); swapOver(' + nav_id + ',\'nav\'); showSubNav(' + nav_id + ');" onMouseOut="hideTimer(\'start\',' + nav_id + '); swapOut(' + nav_id + ',\'nav\');"><img name="image' + nav_id + '" src="' + nav_img_path + 'nav_' + nav[i][0] + '_off.gif" border=0></a></div>';
	    nav_linked[id] = '<div id="nav' + nav_id + '" style="position:relative; z-index:30"><a href="' + nav[i][1] + '" onMouseOver="hideTimer(\'stop\',' + nav_id + '); swapOver(' + nav_id + ',\'nav\'); showSubNav(' + nav_id + ');" onMouseOut="hideTimer(\'start\',' + nav_id + '); swapOut(' + nav_id + ',\'nav\');"><img name="image' + nav_id + '" src="' + nav_img_path + 'nav_' + nav[i][0] + '_off.gif" border=0></a></div>';
		
		for(j = 0; j < subnav_count[nav_id]; j++) {
			subnav_id = nav_id + (j + 1);
	        subnav_unlinked[subnav_id] = '<div id="sub' + subnav_id + '" style="position:relative; z-index:30; visibility:hidden"><img name="image' + subnav_id + '" src="' + nav_img_path + 'subnav_' + nav[i][2][j][0] + '_off.gif" border=0 onMouseOver="hideTimer(\'stop\',' + nav_id + ');" onMouseOut="hideTimer(\'start\',' + nav_id + ');"></div>';
	        subnav_linked[subnav_id] = '<div id="sub' + subnav_id + '" style="position:relative; z-index:30; visibility:hidden"><a href="' + nav[i][2][j][1] + '" onMouseOver="hideTimer(\'stop\',' + nav_id + '); swapOver(' + subnav_id + ',\'sub\')" onMouseOut="hideTimer(\'start\',' + nav_id + '); swapOut(' + subnav_id + ',\'sub\');"><img name="image' + subnav_id + '" src="' + nav_img_path + 'subnav_' + nav[i][2][j][0] + '_off.gif" border=0></a>%%SUBNAV_BOTTOM%%</div>';
			re = /%%SUBNAV_BOTTOM%%/g;
			subnav_linked[subnav_id] = subnav_linked[subnav_id].replace(re, ((j == (subnav_count[nav_id] - 1)) ? '<img src="' + nav_img_path + 'subnav_bottom.gif">' : ""));
		}
	}

    var html_str = '';
    html_str+= '<table border=0 cellspacing=0 cellpadding=0 width="99%">'
             + '<tr>';


    for (i = 1; i < nav_unlinked.length; i++) {
		nav_id = i * nav_step;

        if (i==1) {
            tdWidth = nav_img_width; // this value can be hard-coded to a static width for a non-navigational leading image;
        } else {
            tdWidth = nav_img_width;
        }

        html_str+= '<td align="center" valign="top" width="' + tdWidth + '">'
                 + nav_linked[i];
        for (j = 1; j < (subnav_count[nav_id] + 1); j++) {
            checkSub = parseInt(("" + i + j), 10);
            whichSub = parseInt(("" + section + page), 10);
            if (checkSub == whichSub) {
                html_str+= subnav_unlinked[checkSub];
            } else {
                html_str+= subnav_linked[checkSub];
            }
        }
        html_str+= '</td>';
		
		// spacer
		html_str+= (nav_spacer) ? '<td width="' + nav_spacer_width + '">&nbsp;</td>' : "";
    }
    html_str+= '</tr>'
             + '</table>';
    document.write(html_str);

}


// Navigation animation

var timeoutID = 0;
var timeoutID2 = 0;
        
function showSubNav(navID) {
    subNavID = navID + 1;
    animateSubNav(subNavID,subnav_count[navID],1);
}
        
function hideSubNav(navID) {
    subNavID = navID + 1;
    for(i = 0; i < subnav_count[navID]; i++) {
        outputResults(subNavID,"hidden");
        subNavID++;
    }
}
    
function animateSubNav(subNavID,subCountTotal,subCountCurrent) {
    sID = subNavID;
    sCT = subCountTotal;
    sCC = subCountCurrent;
    window.clearTimeout(timeoutID2);
    if (sCC != (parseInt(sCT, 10) + 1)) {
        outputResults(subNavID,"visible");
        sID++;
        sCC++;
        timeoutID2 = window.setTimeout("animateSubNav(sID,sCT,sCC)", 0);
    }
}

function hideTimer(actionType,navID) {
    aType = actionType;
    nID = navID;
    switch (aType) {
        case "start" :
            window.clearTimeout(timeoutID);
            timeoutID = window.setTimeout("hideSubNav(nID)", 100);
            break;
        case "stop" :
            window.clearTimeout(timeoutID);
            for (j = 0; j < nav_cnt; j++) {
                whichNav = (j + 1) * nav_step;
                if(whichNav != nID) {
                    hideSubNav(whichNav);
                }
            }
            break;
        default :
            break;
    }
}
        
function outputResults(subNavID,propertyValue) {
    whichLayer = "sub" + subNavID;
    if (IE4) {
        document.all[whichLayer].style.visibility = propertyValue;
    } else if (NS4) {
        switch (propertyValue) {
            case "visible" :
                propertyValue = "show";
                break;
            case "hidden" :
                propertyValue = "hide";
                break;
            default :
                break;
        }
        document.layers[whichLayer].visibility = propertyValue;
        return false;
    } else if (NS6 || IE5) {
        elm = document.getElementById(whichLayer);
        elm.style.visibility = propertyValue;
    } else {
        
    }
}

function reloadPage(page) {
    location.href = location.href;
}

// roll-over scripts

function swapOver(n,inLayer) {
    if (document.images) {
        if (inLayer && NS4) {
            document.layers[inLayer+n].document.images['image'+n].src = eval("on[" + n + "].src");
        } else {
            document.images['image'+n].src = eval("on[" + n + "].src");
        }
    }
}

function swapOut(n,inLayer) {
    if (document.images) {
        if (inLayer && NS4) {
            document.layers[inLayer+n].document.images['image'+n].src = eval("off[" + n + "].src");
        } else {
            document.images['image'+n].src = eval("off[" + n + "].src");
        }
    }
}

    
