//  edisonweb.js

function init() {
    initMenu();
    initTopImage();
    initBreadcrumbs();
}


//  initialize pop-up menus
function initMenu() {
    var el;
    if ( (el=$("menu-go-resi")) )  el.style.display = "none";
    if ( (el=$("menu-go-comm")) )  el.style.display = "none";

    if ( (el=$("go-resi")) )  el.onmouseover = showMenu;
    if ( (el=$("go-comm")) )  el.onmouseover = showMenu;
}

//  this generates an image-file name by concatenating a random
//  three digit number between "001" and a specified maximum number,
//  with a specified file-name prefix and suffix
//
function initTopImage() {
    var el;
    if ( ! (el=$("pichead")) )  return;
    el.src = "images/topimage-" + randomZ3(10) + ".jpg";
}
function randomZ3( max ) {
	var num = Math.round( Math.random()*max+0.49999 ) + 1000;
	return ( (num+"").substr(1,4) );
}

//
var secname = {	'resi': 'Residential',
		'comm': 'Commercial',
		'news': 'News & Events',
		'jobs': 'Employment Opportunities'
	};
var secpage = { 'resi': 'residential.shtml',
		'comm': 'commercial.shtml'
	};
function initBreadcrumbs() {
    var el;
    if ( ! (el=$("breadcrumbs")) )  return;
    var text;
    if ( section ) {
    text = "<a href='index.shtml'>Our Home Page</a> &rarr; ";
        if ( topic ) {
	    text += "<a href='"+secpage[section]+"'>"
					+ secname[section]+"</a>";
	} else {
	    text += secname[section];
	}
    }
    if ( topic )  text += " &rarr; "+topic;
    if ( text )  el.innerHTML = text;
}

//  this will stick a "Call Me" object with the specified "about" (tool-tip)
//  at the specified location in the content area.
//  (Needs "section" and "ref" globals to be defined!)
//
function callMe( x,y, about ) {
    document.write( "<a href='"+section+"-request.html?ref="+topic+"'>" );
    document.write( "<img src='images/call-me-90x90.gif' "
		+ "width='90' height='90' "
    		+ "title=\"Request a call from Edison about "+about+"\" "
		+ "style='position:absolute;left:"+x+"px;top:"+y+"px;'/>" );
    document.write( "</a>\n");
}

