// <!--code and design via focus design, 2006, zenforge -->

// ---------------------------------------------------------------------------------
// configuration
// ---------------------------------------------------------------------------------

var imgroot = "/wsimages/";				/* where are my images */
var menuroot = "/wsimages/menu/";		/* where are menu files */
var ZF_inEL = false;					/* are we in IE 5.5/6? because we have to hack that, damn M$ */
var ZF_activemenuitem = "";				/* pointer to active submenu item, if any is active */
var submenuobj = null;					/* dummy object for submenu animation - becomes global! */
var submenutextin = null;				/* dummy object for submenu animation - becomes global! */
var submenutextout = null;				/* dummy object for submenu animation - becomes global! */

// ---------------------------------------------------------------------------------
// runtime - such as normal preloading
// ---------------------------------------------------------------------------------


// ---------------------------------------------------------------------------------
// functions
// ---------------------------------------------------------------------------------

// any js body onload startup code goes here
function ZF_setBody() {
	
	// set navigation?  none in this case...

	/* skip preloading, since it really messes stuff up with the alpha channel hacks
	var imgArray = new Array(18); var i = 0;
	var basepath = "/wsimages/menu/";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b1-on.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b2-on.png";
	imgArray[i] = new Image(110,34); imgArray[i++].src = basepath + "b3-on.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b4-on.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b5-on.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b6-on.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b0-off.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b1-off.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b2-off.png";
	imgArray[i] = new Image(110,34); imgArray[i++].src = basepath + "b3-off.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b4-off.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b5-off.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b6-off.png";
	imgArray[i] = new Image(110,35); imgArray[i++].src = basepath + "b6-off.png";
	imgArray[i] = new Image(192,278); imgArray[i++].src = basepath + "../" + "submenu-bg.png";
	imgArray[i] = new Image(95,18); imgArray[i++].src = basepath + "../" + "tab-whatsnew.png";
	imgArray[i] = new Image(95,18); imgArray[i++].src = basepath + "../" + "tab-casestudies.png";
	*/
	
} // end function

// reuturn the text object to move in/out for menu (returns/localizes a global)
function ZF_getSMTObjectname(subitem) {

	submenuname = "submenu-text-" + subitem;
	return submenuname;
}

// set a menu object on or off, activate submenu (deactivating others as appropriate
// objectprefix can be any id substring that exists (b1..b6)
function ZF_menuclick(objectname) {

	// turn off the active menu first, if any
	if (ZF_activemenuitem != "") {
		// main menu
		ZF_setmenu(ZF_activemenuitem, "off");	
		// submenu
		submenuname = ZF_getSMTObjectname(ZF_activemenuitem);
		submenutextin = MM_findObj(submenuname);
		ZF_closeSubmenu();
	}
	if (ZF_activemenuitem == objectname) {
		ZF_activemenuitem = "";
	} else {
		ZF_activemenuitem = objectname;
		ZF_setmenu(ZF_activemenuitem, "on");
		// second level menu
		submenuobj = MM_findObj("submenu-frame");
		//submenutext = MM_findObj("submenu-text-b3");
		submenuname = ZF_getSMTObjectname(objectname);
		submenutextout = MM_findObj(submenuname);
		submenuobj.style.marginLeft = '10px';
		submenutextout.style.marginLeft = '10px';
		ZF_openSubmenu();
	}
	
	// done, return
	return false;
}

// set a main menu graphic item on or off
function ZF_setmenu(objectname, newstate) {

	if (newstate == "off") {
		oldstate = "on";
	} else {
		oldstate = "off";
	}

	if (ZF_inEL) {
		// exception land: due to alphachannel filter, we're making exceptions.  Joy.

		var oSpan = document.getElementById("menu" + objectname);
		var currentAlphaImg = oSpan.filters(0).src;
		if (currentAlphaImg.indexOf("-" + oldstate) != -1) {
			oSpan.filters(0).src = currentAlphaImg.replace("-" + oldstate,"-" + newstate);
		}
	
	} else {
		// normal compliant browser
		imgobj = MM_findObj("menu" + objectname);
		imgobj.src = menuroot + objectname + "-" + newstate + ".png";
	}
	
	return false;
}

// open a submenu up
function ZF_openSubmenu() {
	
	var increment = 11;
	var minvalue = 10;
	var maxvalue = 72;
	
	// submenuobj.innerHTML = '<img src="/wsimages/submenu-bg.png" height="278" width="192">';
	
	myvalue = parseInt(submenuobj.style.marginLeft) + increment;
	if (myvalue > maxvalue) {
		myvalue = maxvalue;
	}
	if (myvalue-increment == minvalue) {
		// turn visibility on first
		submenuobj.style.visibility = "visible";
		submenutextout.style.visibility = "visible";
	}
	submenuobj.style.marginLeft = myvalue + 'px';
	submenutextout.style.marginLeft = myvalue + 'px';
	// alert(myvalue);
	if (myvalue < maxvalue) {
		setTimeout("ZF_openSubmenu()", 1);
	} else {
		submenutextout.style.zIndex = 18;
	}
}

// close a submenu down
function ZF_closeSubmenu() {
	
	var increment = 11;
	var minvalue = 10;
	var maxvalue = 72;

	submenutextin.style.zIndex = 14;
	myvalue = parseInt(submenuobj.style.marginLeft) - increment;
	if (myvalue < minvalue) {
		myvalue = minvalue;
	}
	if (myvalue == minvalue) {
		// turn visibility off first
		submenuobj.style.visibility = "hidden";
		submenutextin.style.visibility = "hidden";
	}
	submenuobj.style.marginLeft = myvalue + 'px';
	submenutextin.style.marginLeft = myvalue + 'px';
	// submenuobj.innerHTML = '<img src="/wsimages/submenu-bg.png" height="278" width="' + myvalue + '">';

	// alert(myvalue);
	if (myvalue > minvalue) {
		setTimeout("ZF_closeSubmenu()", 1);
	}
}

// open a new window for offsite URL or URL that needs a new window
function ZF_popup(popupurl) {

	window.open(popupurl, "dummyname", "");
	
}

// MacroMedia - Find an object n in a document d (or default document).  returns ptr to obj
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// clear the project search search menu
function ZF_clearsearch() {

	selectind = MM_findObj("sind");
	selectind.selectedIndex = 0;
	selectind = MM_findObj("sloc");
	selectind.selectedIndex = 0;
	
}

//-->
