<!-- Begin

// Pre-load images.
if (document.images)
{
	var nav0 = new Image();
	nav0.src = 'images/hdr_all_off.gif';
	var nav1 = new Image();
	nav1.src = 'images/hdr_cvp_home_on.gif';
	var nav2 = new Image();
	nav2.src = 'images/hdr_airwire900_on.gif';
	var nav3 = new Image();
	nav3.src = 'images/hdr_easydcc_on.gif';
	var nav4 = new Image();
	nav4.src = 'images/hdr_railcommand_on.gif';
	var nav5 = new Image();
	nav5.src = 'images/hdr_wireless_items_on.gif';
	var nav6 = new Image();
	nav6.src = 'images/hdr_other_products_on.gif';
	var nav7 = new Image();
	nav7.src = 'images/hdr_pricing_shipping_on.gif';
	var nav8 = new Image();
	nav8.src = 'images/hdr_ordering_on.gif';
	var nav9 = new Image();
	nav9.src = 'images/hdr_documentation_on.gif';
	var nav10 = new Image();
	nav10.src = 'images/hdr_contact_us_on.gif';
	var nav11 = new Image();
	nav11.src = 'images/hdr_tech_tips_on.gif';
	var nav12 = new Image();
	nav12.src = 'images/hdr_news_events_on.gif';
}

// Set name of current window so that it can be used as target when flowing to another window.
name = 'mainwindow';

// Determine if Netscape.
var isNav = (navigator.appName.indexOf("Netscape") !=-1);

// Turn on mousemove and mouseup events for Netscape.
if (isNav){
	document.captureEvents(Event.MOUSEMOVE);
	document.captureEvents(Event.MOUSEUP);
}

// OPEN NEW WINDOW IN CURRENT WINDOW:
// document.location does not work on all browsers; instead open in current window
function opennext(windowname) {
	var window_width = window.outerWidth;
	var window_height = window.outerHeight;
	var window_xpos = window.pageXOffset;
	var window_ypos = window.pageYOffset;
	var properties="width=" + window_width + ",height=" + window_height + ",left=" + window_xpos + ",top=" + window_ypos + ",toolbar=yes,scrollbars=yes,menubar=yes,resizable=yes";
	// open the new window in the same place as the current window
	nextwindow = window.open(windowname, "mainwindow", properties);
}

// ROLLOVERS:
// Determine x,y position of mouse and derive number of navigation image to display (number after "nav" above. 
// Entire set of "buttons" is one image, and just switches out entire image so that one button appears to be "on".
function navswitch(e,imgName) {
	pos_max = new Array (734,699,664,615,580,545,509,474,439,404,369,334);
	x_position = (isNav) ? e.pageX : event.clientX
	y_position = (isNav) ? e.pageY : event.clientY
	x_plus_y = x_position + (.979 * y_position);
	
	if (y_position > 140 || y_position < 25 || x_position < 140 || x_plus_y > 769) {
		image_suffix = '0';
	}
	else {
		for (i=0; i<12; i++) {
			if (x_plus_y > pos_max[i]) {
				image_suffix = 12-i; 
				break;
			}
		}
	}
	
	if (document.images) {
		document[imgName].src = eval('nav' + image_suffix + '.src');
		}
	return true;
}

// NAVIGATION:
// Determine x,y position of mouse and derive number of navigation image to display (number after "nav" above. 
// Entire set of "buttons" is one image, and just switches out entire image so that one button appears to be "on".
function urlselect(e) {
	// pos_max = new Array (699,664,629,580,545,510,474,439,404,369,334,299);
	pos_max = new Array (734,699,664,615,580,545,509,474,439,404,369,334);
	url_name = new Array ('news_show','tech_planning_tips','contact_us','doc_center','ordering','pricing_shipping','other_prod_bulb','wireless_throttle_rf1300','railcmd_system','easydcc_system_command_station','airwire900_system_info','index');
	x_position = (isNav) ? e.pageX : event.clientX
	y_position = (isNav) ? e.pageY : event.clientY
	x_plus_y = y_position + (.979 * x_position);
	
	if (y_position > 140 || y_position < 25 || x_position < 140 || x_plus_y > 760) {
	}
	else {
		for (i=0; i<12; i++) {
			if (x_plus_y > pos_max[i]) {
				break;
			}
		}
		opennext(url_name[i] + '.php');
	}
	return true;
}

// Determine x,y position values when mouse moves, and call nav image switcher
function handlerMM(e){
	Xmm = (isNav) ? e.pageX : event.clientX;
	Ymm = (isNav) ? e.pageY : event.clientY;
	navswitch(e, 'nav');
	// The following are to display x,y positions of mouse for debugging.
	//document.dataholder.mmX.value=Xmm;
	//document.dataholder.mmY.value=Ymm;
}

// Determine x,y position values on mouse up, and determine url
function handlerMU(e){
	Xmu = (isNav) ? e.pageX : event.clientX;
	Ymu = (isNav) ? e.pageY : event.clientY;
	urlselect(e);
	// The following are to display x,y positions of mouseup for debugging.
	//document.dataholder.muX.value=Xmu;
	//document.dataholder.muY.value=Ymu;
}

// Call handler function when mouse moves. This determines rollover image to use based on mouse position.
document.onmousemove = handlerMM;

// Call handler function on mouse up. This determines url of page to display.
document.onmouseup = handlerMU;

// End -->