// vars.js

var featured_product_name = new Array();
var featured_product_number = new Array();
var featured_product_descr = new Array();
var featured_product_url = new Array();

var	new_product_descr = new Array();
var new_product_url = new Array();

var sb1_obj;
var sb2_obj;
var	news_width;
var	event_width = 140;
var	num_events = 2;		
var news_height = 145;	
var scroll_bar_width = 10;
var	arrow_height = 16;		

function recalc_news_dims() {	
	var o_news_window_div = document.getElementById( 'news1_window_div' );
	news_width = (client_width() - (num_events * event_width) - (scroll_bar_width * (num_events + 8))) / 2;
	if ( news_width < 10 )
		news_width = 10;
	o_news_window_div.style.width = news_width + "px";
	o_news_window_div.style.height = news_height + "px";
	o_news_window_div = document.getElementById( 'news2_window_div' );
	o_news_window_div.style.width = news_width + "px";
	o_news_window_div.style.height = news_height + "px";
}

// rndfeature.js - purple crayons / randomized featured product / definition

var num_featured_products = 6;
var num_new_products = 4;
var new_product_root = "/prof/images/home/new_product/product_";
var featured_product_root = "/prof/images/home/featured_products/product_";
var new_product_image = new Array();
var new_product_name = new Array();
var featured_product_image = new Array();
var featured_product_on_image = new Array();
var featured_product_off_image = new Array();

/*
for ( var i = 0;  i < num_featured_products;  i++ ) {
	featured_product_on_image[i] = new Image();
	featured_product_on_image[i].src = featured_product_root + (i + 1) + "/on.gif";
	featured_product_off_image[i] = new Image();
	featured_product_off_image[i].src = featured_product_root + (i + 1) + "/off.gif";
	featured_product_image[i] = new Image();
	featured_product_image[i].src = featured_product_root + (i + 1) + "/product.jpg";
}
*/

function load_featured_product( n ) {

	var	cnt_div;
	
	n--;

	for ( var i = 0;  i < num_featured_products;  i++ ) {
		if ( i != n ) {
			eval( "document.featured_onoff_" + (i + 1) + ".src = featured_product_off_image[i].src" );
		}
	}	
	
	document.featured_product_image.src = featured_product_image[n].src;
	eval( "document.featured_onoff_" + (n + 1) + ".src = featured_product_on_image[n].src" );
	
	
	n++;
	cnt_div = document.getElementById( 'featured_product_name_div' );
	cnt_div.innerHTML = featured_product_name[n];
	cnt_div = document.getElementById( 'featured_product_number_div' );
	cnt_div.innerHTML = featured_product_number[n];
	cnt_div = document.getElementById( 'featured_product_descr_div' );
	cnt_div.innerHTML = featured_product_descr[n];
	if(featured_product_url[n]=='') featured_product_url[n]='#';
	if(document.getElementById( 'featured_product_url' )) {
		cnt_div = document.getElementById( 'featured_product_url' );
		cnt_div.href = featured_product_url[n];
	}
}

function randomize_products() {

	var img_num = Math.floor( Math.random() * num_new_products );
	img_num = Math.floor( Math.random() * num_featured_products );
	load_featured_product( img_num + 1 );
}

// master.js

var homePage = 0;
var dimensScreen = screen.width ;

 if ( document.images ) {
	toc1on = new Image();
	toc1on.src = "/prof/images/alpha_nav/a_1_on.gif";
	toc2on = new Image();
	toc2on.src = "/prof/images/alpha_nav/a_2_on.gif";
	toc3on = new Image();
	toc3on.src = "/prof/images/alpha_nav/a_3_on.gif";
	toc4on = new Image();
	toc4on.src = "/prof/images/alpha_nav/a_4_on.gif";
	toc5on = new Image();
	toc5on.src = "/prof/images/beta_nav/b_about_on.gif";
	toc6on = new Image();
	toc6on.src = "/prof/images/beta_nav/b_contact_on.gif";
	toc7on = new Image();
	toc7on.src = "/prof/images/beta_nav/b_registration_on.gif";
	toc8on = new Image();
	toc8on.src = "/prof/images/beta_nav/b_events_on.gif";
	toc9on = new Image();
	toc9on.src = "/prof/images/beta_nav/b_trade_on.gif";
	toc10on = new Image();
	toc10on.src = "/prof/images/beta_nav/b_mail_on.gif";
	/*toc11on = new Image();
	toc11on.src = "/prof/images/home/products/b_video_on.gif";
	toc12on = new Image();
	toc12on.src = "/prof/images/home/products/b_storage_on.gif";
	toc13on = new Image();
	toc13on.src = "/prof/images/home/products/b_presentation_on.gif";
	toc14on = new Image();
	toc14on.src = "/prof/images/home/products/b_security_on.gif";*/
	//toc20on = new Image();
	//toc20on.src = "/prof/images/universal/b_button_on.gif";
	
	toc1off = new Image();
	toc1off.src = "/prof/images/alpha_nav/a_1_off.gif";
	toc2off = new Image();
	toc2off.src = "/prof/images/alpha_nav/a_2_off.gif";
	toc3off = new Image();
	toc3off.src = "/prof/images/alpha_nav/a_3_off.gif";
	toc4off = new Image();
	toc4off.src = "/prof/images/alpha_nav/a_4_off.gif";
	toc5off = new Image();
	toc5off.src = "/prof/images/beta_nav/b_about_off.gif";			
	toc6off = new Image();
	toc6off.src = "/prof/images/beta_nav/b_contact_off.gif";
	toc7off = new Image();
	toc7off.src = "/prof/images/beta_nav/b_registration_off.gif";
	toc8off = new Image();
	toc8off.src = "/prof/images/beta_nav/b_events_off.gif";
	toc9off = new Image();
	toc9off.src = "/prof/images/beta_nav/b_trade_off.gif";
	toc10off = new Image();
	toc10off.src = "/prof/images/beta_nav/b_mail_off.gif";
	/*toc11off = new Image();
	toc11off.src = "/prof/images/home/products/b_video_off.gif";
	toc12off = new Image();
	toc12off.src = "/prof/images/home/products/b_storage_off.gif";
	toc13off = new Image();
	toc13off.src = "/prof/images/home/products/b_presentation_off.gif";
	toc14off = new Image();
	toc14off.src = "/prof/images/home/products/b_security_off.gif";*/
	//toc20off = new Image();
	//toc20off.src = "/prof/images/universal/b_button_off.gif";
}

var img_ar = new Array();
img_ar[0] = new Image();
img_ar[0].src = "/prof/images/alpha_nav/a_1_off.gif";
img_ar[1] = new Image();
img_ar[1].src = "/prof/images/alpha_nav/a_1_on.gif";
img_ar[2] = new Image();
img_ar[2].src = "/prof/images/alpha_nav/a_2_off.gif";
img_ar[3] = new Image();
img_ar[3].src = "/prof/images/alpha_nav/a_2_on.gif";
img_ar[4] = new Image();
img_ar[4].src = "/prof/images/alpha_nav/a_3_off.gif";
img_ar[5] = new Image();
img_ar[5].src = "/prof/images/alpha_nav/a_3_on.gif";
img_ar[6] = new Image();
img_ar[6].src = "/prof/images/alpha_nav/a_4_off.gif";
img_ar[7] = new Image();
img_ar[7].src = "/prof/images/alpha_nav/a_4_on.gif";
img_ar[8] = new Image();
img_ar[8].src = "/prof/images/alpha_nav/a_5_off.gif";
img_ar[9] = new Image();
img_ar[9].src = "/prof/images/alpha_nav/a_5_on.gif";

// onoff.js
 if (document.images){
 				scr1dnon = new Image();
				scr1dnon.src = "/prof/images/scroll/newsarrowdown_on.gif";
 				scr1dnoff = new Image();
				scr1dnoff.src = "/prof/images/scroll/newsarrowdown_off.gif";
 				scr1upon = new Image();
				scr1upon.src = "/prof/images/scroll/newsarrowup_on.gif";
 				scr1upoff = new Image();
				scr1upoff.src = "/prof/images/scroll/newsarrowup_off.gif";
 				scr2dnon = new Image();
				scr2dnon.src = "/prof/images/scroll/newsarrowdown_on.gif";
 				scr2dnoff = new Image();
				scr2dnoff.src = "/prof/images/scroll/newsarrowdown_off.gif";
 				scr2upon = new Image();
				scr2upon.src = "/prof/images/scroll/newsarrowup_on.gif";
 				scr2upoff = new Image();
				scr2upoff.src = "/prof/images/scroll/newsarrowup_off.gif";
         }

function img_act(imgName) {
        if (document.images) {
                imgOn = eval(imgName + "on.src");
                document [imgName].src = imgOn;
        }}

function img_inact(imgName) {
        if (document.images) {
                imgOff = eval(imgName + "off.src");
                document [imgName].src = imgOff;
        }}
function openWin( windowURL, windowName, windowFeatures ) { 
                return window.open( windowURL, windowName, windowFeatures ) ; 
        } 

// jslib.js - javascript utility library / implementation code

function browser_type() {

	agent = navigator.userAgent.toLowerCase();
	this.major = parseInt( navigator.appVersion );
	this.minor = parseFloat( navigator.appVersion );

	this.ns = (
		(agent.indexOf( 'mozilla' ) != -1) &&
		(agent.indexOf( 'spoofer' ) == -1) &&
		(agent.indexOf( 'compatible' ) == -1) &&
		(agent.indexOf( 'opera' ) == -1) &&
		(agent.indexOf( 'webtv' ) == -1) &&
		(agent.indexOf( 'hotjava' ) == -1)
	);

	this.opera = (
		(agent.indexOf( 'mozilla' ) == -1) &&
		(agent.indexOf( 'spoofer' ) == -1) &&
		(agent.indexOf( 'compatible' ) == -1) &&
		(agent.indexOf( 'opera' ) != -1) &&
		(agent.indexOf( 'webtv' ) == -1) &&
		(agent.indexOf( 'hotjava' ) == -1)
	);

	this.ns4 = (this.ns && (this.major == 4));
	this.ns6 = (this.ns && (this.major >= 5));

	this.ie = (
		(agent.indexOf( "msie" ) != -1) &&
		(agent.indexOf( "opera" ) == -1)
	);

	this.ie4 = (
		this.ie &&
		(this.major ==  4) &&
		(agent.indexOf( "msie 4" ) != -1)
	);

	this.ie5 = (
		this.ie &&
		(this.major == 4) &&
		(agent.indexOf( "msie 5." ) != -1) &&
		(agent.indexOf( "msie 5.5" ) == -1) &&
		(agent.indexOf( "mac" ) == -1)
	);

	this.iem5 = (
		this.ie &&
		(this.major == 4) &&
		(agent.indexOf( "msie 5." ) != -1) &&
		(agent.indexOf( "mac" ) != -1)
	);

	this.ie55 = (
		this.ie &&
		(this.major == 4) &&
		(agent.indexOf( "msie 5.5" ) != -1)
	);

	this.ie6 = (
		this.ie &&
		(this.major == 4) &&
		(agent.indexOf( "msie 6." ) != -1)
	);

	this.nsdom = (this.ns4 || this.ns6);
	this.ie5dom = (this.ie5 || this.iem5 || this.ie55);
	this.iedom = (this.ie4 || this.ie5dom || this.ie6);
	this.w3dom = (this.ns6 || this.iem5 || this.ie55 || this.ie6);
}

function client_width() {

	var	w;
	
	if ( typeof( window.innerWidth ) == 'number' )
		w = window.innerWidth;
	else {
		if ( document.documentElement && document.documentElement.clientWidth ) 
			w = document.documentElement.clientWidth;
		else
			if ( document.body && document.body.clientWidth )
				w = document.body.clientWidth;
	}
	
	return w;
}

function client_height() {

	var	h;
	
	if ( typeof( window.innerHeight ) == 'number' )
		h = window.innerHeight;
	else {
		if ( document.documentElement && document.documentElement.clientHeight ) 
			h = document.documentElement.clientHeight;
		else
			if ( document.body && document.body.clientHeight )
				h = document.body.clientHeight;
	}
	
	return h;
}

function element_position( id ) {

	if ( !(document.getElementById || document.all) )
		return null;
	
	var elem = document.getElementById( id );
	
	this.x = 0;
	this.y = 0;

	while ( elem.offsetParent ) {
		this.x += elem.offsetLeft;
		this.y += elem.offsetTop;
		elem = elem.offsetParent;
	}
}

function event_handler( e, h, b, o ) {
	
	var	obj = document;
	
	if ( o && (o != '') ) 
		obj = document.getElementById( o );
	
	if ( document.addEventListener ) {
    	obj.addEventListener( e, h, b );
		this.detach = function() {
			obj.removeEventListener( e, h, b );
		}
	}
	else if ( document.attachEvent ) {
    	obj.attachEvent( 'on' + e, aeh_ie_handler );
		this.detach = function() {
			obj.detachEvent( 'on' + e, aeh_ie_handler );
		}
	}
	
	function aeh_ie_handler() {
		h( window.event );
	}
}

function event_stop_propagation( event ) {

	if ( event.stopPropagation )	
		event.stopPropagation();
	else
		event.cancelBubble = true;
}

function event_stop_default( event ) {
	
	if ( event.preventDefault )
		event.preventDefault();
	else
		event.returnValue = false;
}

// menucfg.js - javascript tree-style menu | menu configuration file

var icon_path = '/prof/includes/js/treemenu/images/icons/';

var menu_cfg_geo = {

	'target'	: 'content_layer',			

	'icon_e'	: icon_path + 'empty.gif',	
	'icon_l'	: icon_path + 'line.gif',

	'icon_48'	: icon_path + 'plus.gif',
	'icon_52'	: icon_path + 'plus.gif',
	'icon_56'	: icon_path + 'minus.gif',
	'icon_60'	: icon_path + 'minus.gif',

	'icon_16'	: icon_path + 'triangle.gif',
	'icon_20'	: icon_path + 'triangle.gif',
	'icon_24'	: icon_path + 'triangle-down.gif',
	'icon_28'	: icon_path + 'triangle-down.gif',

	'icon_0'	: icon_path + 'dot.gif',
	'icon_4'	: icon_path + 'dot.gif',
	'icon_8'	: icon_path + 'dot.gif',
	'icon_12'	: icon_path + 'dot.gif',

	'icon_2'	: icon_path + 'joinbottom.gif',
	'icon_3'	: icon_path + 'join.gif',
	'icon_18'	: icon_path + 'plusbottom.gif',
	'icon_19'	: icon_path + 'plus.gif',
	'icon_26'	: icon_path + 'minusbottom.gif',
	'icon_27'	: icon_path + 'minus.gif',
	
	'icon_32'	: icon_path + 'blockbottom.gif',
	'icon_34'	: icon_path + 'block.gif',
	'icon_36'	: icon_path + 'blockbottom.gif',
	'icon_38'	: icon_path + 'block.gif',
	
	'icon_66'	: icon_path + 'joinbottom.gif',
	'icon_67'	: icon_path + 'join.gif',
	'icon_82'	: icon_path + 'circle-hollow-bottom.gif',
	'icon_83'	: icon_path + 'circle-hollow.gif',
	'icon_90'	: icon_path + 'circle-filled-bottom.gif',
	'icon_91'	: icon_path + 'circle-filled.gif'			
};

var menu_cfg_empty = {

	'target'	: 'content_layer',			

	'icon_e'	: icon_path + 'empty2.gif',
	'icon_l'	: icon_path + 'empty2.gif',

	'icon_48'	: icon_path + 'empty2.gif',
	'icon_52'	: icon_path + 'empty2.gif',
	'icon_56'	: icon_path + 'empty2.gif',
	'icon_60'	: icon_path + 'empty2.gif',

	'icon_16'	: icon_path + 'empty2.gif',	
	'icon_20'	: icon_path + 'empty2.gif',	
	'icon_24'	: icon_path + 'empty2.gif',	
	'icon_28'	: icon_path + 'empty2.gif',	

	'icon_0'	: icon_path + 'empty2.gif',	
	'icon_4'	: icon_path + 'empty2.gif', 
	'icon_8'	: icon_path + 'empty2.gif', 
	'icon_12'	: icon_path + 'empty2.gif', 

	'icon_2'	: icon_path + 'empty2.gif', 
	'icon_3'	: icon_path + 'empty2.gif', 
	'icon_18'	: icon_path + 'empty2.gif',
	'icon_19'	: icon_path + 'empty2.gif',
	'icon_26'	: icon_path + 'empty2.gif',
	'icon_27'	: icon_path + 'empty2.gif'	
};

var menu_cfg_win = {

	'target'  : 'content_layer',

	'icon_e'  : icon_path + 'empty.gif',
	'icon_l'  : icon_path + 'line.gif',

	'icon_48' : icon_path + 'diskdrive.gif',
	'icon_52' : icon_path + 'diskdrive.gif',
	'icon_56' : icon_path + 'diskdrive.gif',
	'icon_60' : icon_path + 'diskdrive.gif',

	'icon_16' : icon_path + 'folder.gif',
	'icon_20' : icon_path + 'folder.gif',
	'icon_24' : icon_path + 'folderopen.gif',
	'icon_28' : icon_path + 'folderopen.gif',

	'icon_0'  : icon_path + 'page.gif',
	'icon_4'  : icon_path + 'page.gif',
	'icon_8'  : icon_path + 'page.gif',
	'icon_12' : icon_path + 'page.gif',

	'icon_2'  : icon_path + 'joinbottom.gif',
	'icon_3'  : icon_path + 'join.gif',
	'icon_18' : icon_path + 'plusbottom.gif',
	'icon_19' : icon_path + 'plus.gif',
	'icon_26' : icon_path + 'minusbottom.gif',
	'icon_27' : icon_path + 'minus.gif'
};

// scrollbar.js - purple crayons / scrollbar / definition

function scrollbar( gid, wid, cid, tid, bid, gri, upi, dni, axi ) {
	
	this.grip_id = gid;
	this.window_id = wid;
	this.content_id = cid;
	this.top_id = tid;
	this.bot_id = bid;
	this.axis = axi;
	this.dy = 0;
	this.elem = 0;
	this.grimg_id = gri;
	this.upimg_id = upi;
	this.dnimg_id = dni;
	this.scroll_active = false;
	this.scroll_spam = 0;
	this.scroll_delay = 10;
	this.dragging = false;

	this.recalc_layout();
}

scrollbar.prototype.begin_drag = function( elem, event ) {

	var sb_object = this;
	
	var	mm_event_handler = new event_handler( 'mousemove', sb_move_handler, true );
	var	mu_event_handler = new event_handler( 'mouseup', sb_up_handler, true );
	
	this.elem = document.getElementById( this.grip_id );
	this.dy = event.clientY;
	this.dragging = true;
	
	event_stop_propagation( event );
	event_stop_default( event );
	
	function sb_move_handler( event ) {
		
		var c, y;
	
		if ( sb_object.axis == 'vertical' ) {
			y = event.clientY - sb_object.dy;
			sb_object.dy = event.clientY;
			c = parseInt( sb_object.elem.style.top );
		}
		else {
			y = event.clientX - sb_object.dy;
			sb_object.dy = event.clientX;
			c = parseInt( sb_object.elem.style.left );
		}
		
		c += y;
			
		if ( c > sb_object.max_pos ) 
			c = sb_object.max_pos;
		if ( c < sb_object.min_pos ) 
			c = sb_object.min_pos;
	
		if ( sb_object.axis == 'vertical' )
			sb_object.elem.style.top = c + "px";
		else
			sb_object.elem.style.left = c + "px";
		
		sb_object.set_pos( c );
	
		event_stop_propagation( event );
		event_stop_default( event );
	}

	function sb_unregister_handlers() {

		sb_object.dragging = false;
		mm_event_handler.detach();
		mu_event_handler.detach();
	}

	function sb_up_handler( event ) {
		sb_unregister_handlers();
		event_stop_propagation( event );
		event_stop_default( event );
	}
}

scrollbar.prototype.recalc_layout = function() {
	
	var	obj_win = document.getElementById( this.window_id );
	var	obj_con = document.getElementById( this.content_id );
	var	obj_grp = document.getElementById( this.grip_id );
	var	pos;
	
	pos = new element_position( this.top_id );
	if ( this.axis == 'vertical' )
		this.min_pos = pos.y;
	else
		this.min_pos = pos.x;
	
	pos = new element_position( this.bot_id );
	if ( this.axis == 'vertical' )
		this.max_pos = pos.y - parseInt( obj_grp.style.height ) + 1;
	else
		this.max_pos = pos.x - parseInt( obj_grp.style.width ) + 1;
		
	if ( this.axis == 'vertical' )
		this.content_span = parseInt( obj_con.offsetHeight );
	else
		this.content_span = parseInt( obj_con.offsetWidth );
		
	if ( this.axis == 'vertical' )
		this.window_span = parseInt( obj_win.offsetHeight );
	else
		this.window_span = parseInt( obj_win.offsetWidth );
	
	this.grip_span = this.max_pos - this.min_pos + 1; 
	
	if ( this.content_span > this.window_span ) {
		obj_grp.style.top = this.min_pos + "px";
		obj_grp.style.visibility = 'visible';
	}
	
	obj_win.style.clip = "rect( 0px " + parseInt( obj_win.offsetWidth ) + "px " + parseInt( obj_win.offsetHeight ) + "px 0px )";
	obj_win.style.visibility = 'visible';
}

scrollbar.prototype.scroll_dec = function( sb, speed ) {

	var	obj = document.getElementById( this.grip_id );
	var	y;
	
	if ( this.scroll_active && (this.content_span > this.window_span) ) {
	
		if ( this.axis == 'vertical' ) 
			y = parseInt( obj.style.top );
		else 
			y = parseInt( obj.style.left );
			
		if ( y < this.max_pos )
			y++;
			
		if ( y >= this.max_pos )
			y = this.max_pos;

		if ( this.axis == 'vertical' )
			obj.style.top = y + 'px';
		else
			obj.style.left = y + 'px';
			
		this.set_pos( y );
	}
	
	this.scroll_spam = setTimeout( sb + '.scroll_dec(\'' + sb + '\',' + speed + ')', this.scroll_delay );
}

scrollbar.prototype.scroll_inc = function( sb, speed ) {

	var	obj = document.getElementById( this.grip_id );
	var	y;
	
	if ( this.scroll_active && (this.content_span > this.window_span) ) {
	
		if ( this.axis == 'vertical' ) 
			y = parseInt( obj.style.top );
		else 
			y = parseInt( obj.style.left );
			
		if ( y > this.min_pos )
			y--;
			
		if ( y < this.min_pos )
			y = this.min_pos;
			
		if ( this.axis == 'vertical' )
			obj.style.top = y + 'px';
		else
			obj.style.left = y + 'px'; 
			
		this.set_pos( y );
	}
	
	this.scroll_spam = setTimeout( sb + '.scroll_inc(\'' + sb + '\',' + speed + ')', this.scroll_delay );
}

scrollbar.prototype.set_pos = function( grip_pos ) {

	var p = -Math.floor( Math.abs( ((grip_pos - this.min_pos) * (this.content_span - this.window_span)) / this.grip_span ) * 1.01 );
	
	var o = document.getElementById( this.content_id );
	
	if ( this.axis == 'vertical' )
		o.style.top = p + "px";
	else
		o.style.left = p + "px";
}

scrollbar.prototype.start_scroll = function( sb, dir, speedVal ) {

	if ( this.dragging )
		return;
		
	this.scroll_active = 1;
	
	if ( dir == "up" || dir == "left" )
		this.scroll_dec( sb, speedVal );
	if ( dir == "dn" || dir == "right" )
		this.scroll_inc( sb, speedVal );
}

scrollbar.prototype.stop_scroll = function() {

	this.scroll_active = 0;
	
	clearTimeout( this.scroll_spam );
}

function PurpleMenu( text, divclass, x, y, w, h, dropdown, fs ) {

	this.menu_text = text;
	this.subiconon = null;
	this.subiconoff = null;
	this.menuid = "main";
	this.menuname = "main";
	this.selected = new Array();
	this.alignwith = null;		
	this.drop_down = dropdown;
	
	this.prev_menu = null;
	this.prev_highlight = -1;

	this.on_hide = "";
	this.on_show = "";
	
	this.normal_background_color = "#000000";
	this.highlight_background_color = "#cc0000";
	this.normal_text_color = "#cccccc";
	this.highlight_text_color = "#000000";
	this.border_color = "#000000";
	
	this.separator = false;
	this.separator_color = "#000000";
	this.separator_height = 1;			
	this.bottom_separator = false;

	this.x = x;
	this.y = y;

	this.w = w;
	this.h = h;
	this.div_class = divclass;
	this.font_size = fs;
	this.font_height = parseInt( fs ) + 3;
	this.font_width = parseInt( fs ) - 3;	
	this.visible = false;
	this.parent = null;		
	this.open_submenu = null;
	this.orientation = "vertical";

	this.items = new Array();
	this.num_items = 0;			
	this.max_item_length = 0;	

	this.menu_window = null;	
}

PurpleMenu.prototype.AddItem = function( subitem, target ) {

	var	w;
	
	this.items[this.num_items] = new Object();

	if ( typeof( subitem ) == "string" ) {
		w = subitem.length * this.font_width;
		if ( this.orientation == "vertical" ) {
			if ( w > this.max_item_length )
				this.max_item_length = w;
		}
		else
			this.max_item_length += subitem.length;
		this.items[this.num_items].item_text = subitem;
		this.items[this.num_items].item_url = target;
		this.items[this.num_items].submenu = null;
	}

	else {
		w = subitem.toString().length * this.font_width + 8;
 		if ( this.orientation == "vertical" ) {
			if ( w > this.max_item_length )
				this.max_item_length = w;
		}
		else
			this.max_item_length += subitem.length + 2;
		this.items[this.num_items].item_text = subitem.toString();
		this.items[this.num_items].item_url = target;
		this.items[this.num_items].submenu = subitem;
		subitem.parent = this;
		subitem.menuid = this.menuid + "_" + target;
		subitem.menuname = target;
	}

	this.num_items++;

	return this.num_items;
}

PurpleMenu.prototype.AlignWithElement = function( name, ofs_x, ofs_y ) {

	this.alignwith = name;
	this.alignoffs_x = ofs_x;
	this.alignoffs_y = ofs_y;
}

PurpleMenu.prototype.CloseSiblings = function() {

	var parent = this.parent;

	if ( parent == null )
		return;

	parent.CloseSiblings();

	for ( var i = 0;  i < parent.num_items;  i++ )
		if ( (parent.items[i].submenu != null) && (parent.items[i].submenu != this) )
			parent.items[i].submenu.HideMenu();
}

PurpleMenu.prototype.EnableSeparator = function( color, height, bottom ) {

	this.separator = true;
	this.separator_color = color;
	this.separator_height = height;
	this.bottom_separator = bottom;

	for ( var i = 0;  i < this.num_items;  i++ )
		if ( this.items[i].submenu != null )
			this.items[i].submenu.EnableSeparator( color, height );
}

PurpleMenu.prototype.HideMenu = function() {

	var o = this;
		
	if ( o.menu_window == null )
		return;

	if ( !o.visible )
		return;

	for ( var i = 0;  i < o.num_items;  i++ ) {
		o.selected[i] = false;
		if ( o.items[i].submenu != null ) {
			o.NormalBackground( i );
			o.items[i].submenu.HideMenu();
		}
	}

	if ( o.border > 0 )
		o.border_window.style.visibility = "hidden";
	o.menu_window.style.visibility = "hidden";
	
	if ( o.on_hide != "" ) {
		eval( o.on_hide );
	}

	o.visible = false;
}

PurpleMenu.prototype.HighlightBackground = function( ord ) {

	var	element = document.getElementById( this.menuid + ord + '_div' );

	if ( this.prev_highlight != -1 )
		this.NormalBackground( this.prev_highlight );
		
	element.style.backgroundColor = this.highlight_background_color;
	element.style.color = this.highlight_text_color;
	this.prev_highlight = ord;

	if ( element = document.getElementById( this.menuid + ord + '_subicon' ) ) 
		element.src = this.subiconon.src;

	if ( this.prev_menu != null )
		this.prev_menu.HideMenu();
	
	if ( this.items[ord].submenu != null ) {
		this.items[ord].submenu.ShowMenu();
		this.prev_menu = this.items[ord].submenu;
	}
}

PurpleMenu.prototype.IsInMenu = function( x, y ) {

	if ( !this.visible )
		return false;
		
	return ((x >= this.x) && (x < (this.x + this.w)) && (y >= this.y) && (y < (this.y + this.h)));
}

PurpleMenu.prototype.IsVisible = function() {

	return this.visible;
}

PurpleMenu.prototype.NormalBackground = function( ord ) {

	if ( this.selected[ord] ) return;

	var	element = document.getElementById( this.menuid + ord + '_div' );

	element.style.backgroundColor = this.normal_background_color;
	element.style.color = this.normal_text_color;
	
	this.prev_highlight = -1;

	if ( element = document.getElementById( this.menuid + ord + '_subicon' ) )
		element.src = this.subiconoff.src;
}

PurpleMenu.prototype.OnHide = function( c ) {

	this.on_hide = this.on_hide + c;
}

PurpleMenu.prototype.OnShow = function( c ) {

	this.on_show = this.on_show + c;
}

PurpleMenu.prototype.SelectItem = function( ord ) {

	this.CloseSiblings();
	this.selected[ord] = true;
	this.HighlightBackground( ord );
}

PurpleMenu.prototype.SetHighlightColor = function( bg, fg ) {

	this.highlight_background_color = bg;
	this.highlight_text_color = fg;
	
	for ( var i = 0;  i < this.num_items;  i++ )
		if ( this.items[i].submenu != null )
			this.items[i].submenu.SetHighlightColor( bg, fg );
}

PurpleMenu.prototype.SetNormalColor = function( bg, fg ) {

	this.normal_background_color = bg;
	this.normal_text_color = fg;
	
	for ( var i = 0;  i < this.num_items;  i++ )
		if ( this.items[i].submenu != null )
			this.items[i].submenu.SetNormalColor( bg, fg );
}

PurpleMenu.prototype.SetOrientation = function( orientation ) {

	this.orientation = orientation;
}

PurpleMenu.prototype.SetSubmenuIcons = function( menu_on, menu_off ) {

	this.subiconon = new Image();
	this.subiconoff = new Image();

	this.subiconon.src = menu_on;
	this.subiconoff.src = menu_off;
	
	for ( var i = 0;  i < this.num_items;  i++ )
		if ( this.items[i].submenu != null )
			this.items[i].submenu.SetSubmenuIcons( menu_on, menu_off );
}

PurpleMenu.prototype.ShowMenu = function( force ) {

	var	obj = this;
	var	a_tag = "";
	var	content = "";
	var	agent;
	var	w;
	var	y;

	if ( !force ) force = 'no';
	
	if ( this.visible && (force == "off" || force == "no") ) {
		this.HideMenu();
		return;
	}

	agent = navigator.userAgent.toLowerCase();

	this.CloseSiblings();

	if ( this.menu_window == null ) {

		this.menu_window = document.createElement( "div" );
		this.menu_window.className = this.div_class;
				
		if ( this.w == -1 ) this.w = this.max_item_length;
		if ( this.h == -1 ) {
			this.h = (((this.font_height + this.separator_height) * this.num_items) + 2);
			if ( this.bottom_separator )
				this.h += this.separator_height;
		}

		for ( var i = 0;  i < this.num_items;  i++ ) {
			if ( this.items[i].submenu == null ) {
				a_tag = '<a ' +
					'href="' +
						this.items[i].item_url +
					'" ' +
					'style="color:' + this.normal_text_color + ';text-decoration:none;"' +
				'>';
			}
			else {
				a_tag = '<a ' +
					'href="' +
						this.items[i].item_url + '.ShowMenu();' +
					'" ' +
					'style="color:' + this.normal_text_color + ';text-decoration:none;"' +
				'>';
			}
			content = content + a_tag + '<div id="' + this.menuid + i + '_div" style="cursor:hand;position:absolute;font-size:' + this.font_size + ';top:' + (i * (this.font_height + this.separator_height)) + 'px;width:' + this.w + 'px;background-color:' + this.normal_background_color + ';overflow:clip;" onmouseover="' + this.menuname + '.HighlightBackground(' + i + ');">';
			content = content + "&nbsp;" + this.items[i].item_text + "&nbsp;";
			if ( (this.subiconoff != null) && (this.items[i].submenu != null) )
				content = content + '<div id="' + this.menuid + i + '_div_subicon" style="cursor:hand;position:absolute;font-size:' + this.font_size + ';"><img style="border:none;" id="' + this.menuid + i + '_subicon" name="' + this.menuid + i + '_subicon" src="' + this.subiconoff.src + '"></div>';
			content = content + '</div></a>';
		}
		
		this.menu_window.innerHTML = content;

		document.body.appendChild( this.menu_window );
	}

	if ( this.alignwith == null ) {
		if ( this.x == -1 ) {
			if ( this.parent != null )
				this.x = this.parent.x + this.parent.w + (this.parent.border * 2) + 1;
			if ( this.x > (client_width() / 2) )
				this.x = this.parent.x - this.w - (this.border * 2) - 1;
		}
		if ( this.y == -1 )
			if ( this.parent != null )
				for ( var i = 0;  i < this.parent.num_items;  i++ )
					if ( this.parent.items[i].submenu == this ) {
						this.y = this.parent.y + (this.parent.font_height * i);
						if ( this.parent.separator )
							this.y += ((this.parent.separator_height + ie) * i);
						break;
					}
	}
	else {
		var elem = document.getElementById( this.alignwith );
		this.x = 0;
		this.y = 0;
		while ( elem.offsetParent ) {
			this.x += elem.offsetLeft;
			this.y += elem.offsetTop;
			elem = elem.offsetParent;
		}
		elem = document.getElementById( this.alignwith );
		this.y += elem.offsetHeight;
		this.y += this.separator_height * 5;
		this.x += this.alignoffs_x;
		this.y += this.alignoffs_y;
	}

	if ( !this.drop_down )
		this.y -= (this.h + 2);
	this.menu_window.style.left = this.x + "px";
	this.menu_window.style.width = this.w + "px";
	this.menu_window.style.height = this.h + "px";
	this.menu_window.style.top = this.y + "px";
	this.menu_window.style.overflow = "hidden";
	this.menu_window.style.backgroundColor = this.separator_color;
	this.menu_window.style.color = this.normal_text_color;

	this.menu_window.style.visibility = "visible";
	this.visible = true;
	
	for ( i = y = 0;  i < this.num_items;  i++ ) {
		if ( this.items[i].submenu != null ) {
			elem = document.getElementById( this.menuid + i + "_div_subicon" );
			elem.style.left = this.w - 15 + "px";
			elem.style.width = "15px";
			elem.style.top = y + "px";
			elem.style.backgroundColor = this.normal_background_color;
			elem.style.color = this.normal_text_color;
		}
		y += this.font_height;
		if ( this.separator )
			y += this.separator_height;
	}
	
	if ( this.on_show != "" ) {
		eval( this.on_show );
	}

}

PurpleMenu.prototype.toString = function() {

	return this.menu_text;
}

PurpleMenu.prototype.valueOf = function() {

	return this.menu_text;
}

// Main Menus
var menu_bot = new PurpleMenu( "MainBot", "purple_menu_main", -1, -1, -1, -1, false, "9px" );

var menu_broad = new PurpleMenu( "Broadcast/Professional Video", "purple_menu", -1, -1, 152, -1, false, "9px" );
var menu_digit = new PurpleMenu( "IP Network Solutions", "purple_menu", -1, -1, 123, -1, false, "9px" );
var menu_prese = new PurpleMenu( "Presentation Products", "purple_menu", -1, -1, 114, -1, false, "9px" );
var menu_secur = new PurpleMenu( "Video Security & Imaging", "purple_menu", -1, -1, 130, -1, false, "9px" );

/*
menu_broad.AlignWithElement( 'broad_td', 4, -17 );
menu_broad.OnShow( "img_act('toc11');" );
menu_broad.OnHide( "img_inact('toc11');" );
menu_broad.AddItem( "D9 VTR's & Camcorders", "javascript:qmlSection('1.1.1')" );
menu_broad.AddItem( "Professional DV", "javascript:qmlSection('1.2.1')" );
menu_broad.AddItem( "Cameras", "javascript:qmlSection('1.3.0')" );
menu_broad.AddItem( "Professional Monitors", "javascript:qmlSection('1.4.1')" );
menu_broad.AddItem( "High Definition Products", "javascript:qmlSection('1.5.1')" );
menu_broad.AddItem( "S-VHS, VHS Products", "javascript:qmlSection('1.6.1')" );
menu_broad.AddItem( "DVD Recorders", "javascript:qmlSection('1.0.1')" );
menu_broad.AddItem( "Editing Controllers", "javascript:qmlSection('1.8.1')" );

menu_digit.AlignWithElement( 'digit_td', 10, -17 );
menu_digit.OnShow( "img_act('toc12');" );
menu_digit.OnHide( "img_inact('toc12');" );
menu_digit.AddItem( "IP Network Solutions", "javascript:qmlSection('3')" ); // NO ENTRY IN PRODUCT TREE MENU
menu_digit.AddItem( "Network Codec", "/prof/attributes/features.jsp?model_id=MDL101395" );
menu_digit.AddItem( "IP Security Cameras", "javascript:qmlSection('3.1')" );
menu_digit.AddItem( "Streamcorder Products", "javascript:qmlSection('3.2')" );
menu_digit.AddItem( "Library System", "/prof/attributes/features.jsp?feature_id=01&tree=&itempath=&model_id=MDL101224" );
menu_digit.AddItem( "V.Networks Website", "javascript:window.open('http://www.jvc-victor.co.jp/english/pro/vnetworks/index-e.html');document.location.href='/prof/main.jsp'" );

menu_prese.AlignWithElement( 'prese_td', 5, -17 );
menu_prese.OnShow( "img_act('toc13');" );
menu_prese.OnHide( "img_inact('toc13');" );
menu_prese.AddItem( "Video Projectors", "javascript:qmlSection('2.1')" );
menu_prese.AddItem( "Flat Panel Display", "javascript:qmlSection('2.2')" );
menu_prese.AddItem( "Audio Guide System", "/prof/attributes/features.jsp?feature_id=01&tree=&itempath=&model_id=MDL101270" );

menu_secur.AlignWithElement( 'secur_td', 5, -17 );
menu_secur.OnShow( "img_act('toc14');" );
menu_secur.OnHide( "img_inact('toc14');" );
menu_secur.AddItem( "V.Networks Website", "javascript:window.open('http://www.jvc-victor.co.jp/english/pro/vnetworks/index-e.html');document.location.href='/prof/main.jsp'" );
menu_secur.AddItem( "Security Cameras", "javascript:qmlSection('4.1.1')" );
menu_secur.AddItem( "Network (IP) Cameras", "javascript:qmlSection('4.1.4')" );
menu_secur.AddItem( "Network Video Recorder", "/prof/attributes/features.jsp?feature_id=01&tree=&itempath=&model_id=MDL101512" );
menu_secur.AddItem( "Imaging Cameras", "javascript:qmlSection('4.7')" );
menu_secur.AddItem( "Timelapse Recorders", "javascript:qmlSection('4.5')" );
menu_secur.AddItem( "CCTV Monitors", "javascript:qmlSection('4.3')" );
*/

menu_bot.AddItem( menu_broad, "menu_broad" );
menu_bot.AddItem( menu_digit, "menu_digit" );
menu_bot.AddItem( menu_prese, "menu_prese" );
menu_bot.AddItem( menu_secur, "menu_secur" );

menu_bot.SetOrientation( "horizontal" );

menu_bot.EnableSeparator( "#333333", 1 );

//menu_bot.SetSubmenuIcons( "/prof/images/universal/menu_dot_on.gif", "/prof/images/universal/menu_dot_off.gif" );

menu_bot.SetNormalColor( "#000000", "#999999" );
menu_bot.SetHighlightColor( "#cc0000", "#000000" );

