PINT.vs = { 
menus : [{'title':'Desktop Monitors ', 'href':'/lv/products/desktop-monitors/', items: [{'title':'Size', 'href':'/lv/products/desktop-monitors/search-results.php?&', items: [{'title':'39cm-43cm (15-17&quot;)', 'href':'/lv/products/desktop-monitors/search-results.php?&x=43&y=5&y=14', items: [{'title':'VA705b', 'href':'/lv/products/desktop-monitors/lcd/value-series/va705b.htm'}]},{'title':'48cm-51cm (19-20&quot;)', 'href':'/lv/products/desktop-monitors/search-results.php?&x=31&y=15', items: [{'title':'VP930', 'href':'/lv/products/desktop-monitors/lcd/pro-series/vp930.htm'},{'title':'VA916', 'href':'/lv/products/desktop-monitors/lcd/value-series/va916.htm'},{'title':'VA1932wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1932wa.htm'},{'title':'VA1931wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wa.htm'},{'title':'VA1931wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wma.htm'},{'title':'VA2014wm', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2014wm.htm'},{'title':'VA2014w', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2014w.htm'},{'title':'VA1931wa-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va1931waled.htm'},{'title':'VA916g', 'href':'/lv/products/desktop-monitors/lcd/value-series/va916g.htm'},{'title':'VA926g', 'href':'/lv/products/desktop-monitors/lcd/value-series/va926g.htm'},{'title':'VA1948m-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1948mled.htm'},{'title':'VA2038w-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va2038wled.htm'},{'title':'VA1948a-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1948aled.htm'},{'title':'VA1931w-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wled.htm'},{'title':'VA1931wma-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wmaled.htm'}]},{'title':'56cm (22&quot;)', 'href':'/lv/products/desktop-monitors/search-results.php?&x=28&y=13', items: [{'title':'VX2268wm', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2268wm.htm'},{'title':'VA2232w', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2232w.htm'},{'title':'VA2231wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wa.htm'},{'title':'VA2231wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wma.htm'},{'title':'VX2239wm', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2239wm.htm'},{'title':'VA2232wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2232wa.htm'},{'title':'VG2236wm-LED', 'href':'/lv/products/desktop-monitors/lcd/graphic-series/vg2236wmled.htm'},{'title':'VA2248-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2248led.htm'},{'title':'VX2253mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2253mhled.htm'},{'title':'VA2231wma-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wma-led.htm'},{'title':'VA2231wa-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va2231waled.htm'}]},{'title':'58cm (23&quot;)', 'href':'#', items: [{'title':'VP2365-LED   ', 'href':'/lv/products/desktop-monitors/led-lcd/vp2365led.htm'},{'title':'V3D231', 'href':'/lv/products/desktop-monitors/lcd/3d-series/v3d231.htm'},{'title':'VX2336S-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2253mhled.htm'}]},{'title':'61cm (24&quot;) -up', 'href':'#', items: [{'title':'VA2431wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2431wma.htm'},{'title':'V3D241wm-LED', 'href':'/lv/products/desktop-monitors/led-lcd/v3d241wmled.htm'},{'title':'VG2436wm-LED', 'href':'/lv/products/vg2436wmled.htm?&parent'},{'title':'VX2451mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2451mhled.htm'},{'title':'VX2453mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2453mhled.htm'},{'title':'VX2451mph-LED ', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2451mhled487777.htm'},{'title':'VX2753mh-LED ', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2753mhled.htm'},{'title':'VP2765-LED  ', 'href':'/lv/products/desktop-monitors/led-lcd/vp2765led.htm'},{'title':'V3D245', 'href':'/lv/products/desktop-monitors/lcd/3d-series/v3d245.htm'}]}]},{'title':'Application', 'href':'#', items: [{'title':'Home &amp; Office', 'href':'/lv/home-office/desktop-monitors/'},{'title':'Entertainment', 'href':'/lv/entertainment/desktop-monitors/'},{'title':'Business', 'href':'/lv/business/desktop-monitors/'}]},{'title':'Technology', 'href':'#', items: [{'title':'LED', 'href':'/lv/products/desktop-monitors/lcd/led-lcd/', items: [{'title':'VA1931wa-LED', 'href':'http://pwp.viewsonic.com/?cid=414992&modulePageId=284&parentCid=415068'},{'title':'V3D241wm-LED', 'href':'/lv/products/desktop-monitors/led-lcd/v3d241wmled.htm'},{'title':'VG2236wm-LED', 'href':'/lv/products/desktop-monitors/lcd/graphic-series/vg2236wmled.htm'},{'title':'VG2436wm-LED', 'href':'/lv/products/vg2436wmled.htm?&parent'},{'title':'VA1948m-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1948mled.htm'},{'title':'VA2248-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2248led.htm'},{'title':'VX2253mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2253mhled.htm'},{'title':'VX2451mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2451mhled.htm'},{'title':'VX2453mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2453mhled.htm'},{'title':'VX2451mph-LED  ', 'href':'/lv/products/desktop-monitors/led-lcd/vx2451mhled487777.htm'},{'title':'VX2753mh-LED', 'href':'/lv/products/desktop-monitors/led-lcd/vx2753mhled.htm'},{'title':'VP2365-LED   ', 'href':'/lv/products/desktop-monitors/led-lcd/vp2365led.htm'},{'title':'VP2765-LED    ', 'href':'/lv/products/desktop-monitors/led-lcd/vp2765led.htm'},{'title':'VA2231wma-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va2231wma-led.htm'},{'title':'VA2231wa-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va2231waled.htm'},{'title':'VX2336S-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va2231waled.htm'},{'title':'VA1948a-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va1948aled.htm'},{'title':'VA1931w-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va1931wled.htm'},{'title':'VA1931wma-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va1931wmaled.htm'}]},{'title':'LCD', 'href':'/lv/products/desktop-monitors/lcd/', items: [{'title':'VA916', 'href':'/lv/products/desktop-monitors/lcd/value-series/va916.htm'},{'title':'VX2268wm', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2268wm.htm'},{'title':'VP2365wb', 'href':'/lv/products/desktop-monitors/lcd/pro-series/vp2365wb.htm'},{'title':'VA1932wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1932wa.htm'},{'title':'VA2232w', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2232w.htm'},{'title':'VA705b', 'href':'/lv/products/desktop-monitors/lcd/value-series/va705b.htm'},{'title':'VA1931wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wa.htm'},{'title':'VA2431wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2431wma.htm'},{'title':'VA1931wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wma.htm'},{'title':'VA2231wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wa.htm'},{'title':'VA2231wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wma.htm'},{'title':'VX2239wm', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2239wm.htm'},{'title':'VA2014wm', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2014wm.htm'},{'title':'VA2014w', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2014w.htm'},{'title':'VA2232wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2232wa.htm'},{'title':'VA916g', 'href':'/lv/products/desktop-monitors/lcd/value-series/va916g.htm'},{'title':'VA926g', 'href':'/lv/products/desktop-monitors/lcd/value-series/va926g.htm'}]}]},{'title':'Series', 'href':'/lv/products/desktop-monitors/', items: [{'title':'X Series', 'href':'/lv/products/desktop-monitors/lcd/x-series/', items: [{'title':'VX2268wm', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2268wm.htm'},{'title':'VX2239wm', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2239wm.htm'},{'title':'VX2253mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2253mhled.htm'},{'title':'VX2451mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2451mhled.htm'},{'title':'VX2453mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2453mhled.htm'},{'title':'VX2451mph-LED ', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2451mhled487777.htm'},{'title':'VX2753mh-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2753mhled.htm'},{'title':'VX2336S-LED', 'href':'/lv/products/desktop-monitors/lcd/x-series/vx2253mhled.htm'}]},{'title':'Pro Series', 'href':'/lv/products/desktop-monitors/lcd/pro-series/', items: [{'title':'VP2365-LED  ', 'href':'/lv/products/desktop-monitors/led-lcd/vp2365led.htm'},{'title':'VP2765-LED', 'href':'/lv/products/desktop-monitors/led-lcd/vp2765led.htm'}]},{'title':'Graphic Series', 'href':'/lv/products/desktop-monitors/lcd/graphic-series/', items: [{'title':'VG2236wm-LED', 'href':'/lv/products/desktop-monitors/lcd/graphic-series/vg2236wmled.htm'},{'title':'VG2436wm-LED', 'href':'/lv/products/vg2436wmled.htm?&parent'}]},{'title':'Value Series', 'href':'/lv/products/desktop-monitors/lcd/value-series/', items: [{'title':'VA916', 'href':'/lv/products/desktop-monitors/lcd/value-series/va916.htm'},{'title':'VA1932wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1932wa.htm'},{'title':'VA2232w', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2232w.htm'},{'title':'VA705b', 'href':'/lv/products/desktop-monitors/lcd/value-series/va705b.htm'},{'title':'VA1931wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wa.htm'},{'title':'VA2431wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2431wma.htm'},{'title':'VA1931wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wma.htm'},{'title':'VA2231wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wa.htm'},{'title':'VA2231wma', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wma.htm'},{'title':'VA2014wm', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2014wm.htm'},{'title':'VA2014w', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2014w.htm'},{'title':'VA2232wa', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2232wa.htm'},{'title':'VA1931wa-LED', 'href':'/lv/products/desktop-monitors/led-lcd/va1931waled.htm'},{'title':'VA916g', 'href':'/lv/products/desktop-monitors/lcd/value-series/va916g.htm'},{'title':'VA926g', 'href':'/lv/products/desktop-monitors/lcd/value-series/va926g.htm'},{'title':'VA1948m-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1948mled.htm'},{'title':'VA2248-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2248led.htm'},{'title':'VA2231wma-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231wma-led.htm'},{'title':'VA2038w-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2038wled.htm'},{'title':'VA2231wa-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va2231waled.htm'},{'title':'VA1948a-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1948aled.htm'},{'title':'VA1931w-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wled.htm'},{'title':'VA1931wma-LED', 'href':'/lv/products/desktop-monitors/lcd/value-series/va1931wmaled.htm'}]},{'title':'3D Series', 'href':'/lv/products/desktop-monitors/lcd/3d-series/', items: [{'title':'V3D231', 'href':'/lv/products/desktop-monitors/lcd/3d-series/v3d231.htm'},{'title':'V3D245', 'href':'/lv/products/desktop-monitors/lcd/3d-series/v3d245.htm'},{'title':'VX2268wm', 'href':'/lv/products/desktop-monitors/lcd/3d-series/vx2268wm.htm'}]}]}]},{'title':'Projectors', 'href':'/lv/products/projectors/', items: [{'title':'Application', 'href':'/lv/entertainment/', items: [{'title':'Home &amp; Office', 'href':'/lv/home-office/projectors/'},{'title':'Entertainment', 'href':'/lv/entertainment/projectors/'},{'title':'Business', 'href':'/lv/business/projectors/'}]},{'title':'Technology', 'href':'#', items: [{'title':'DLP', 'href':'#', items: [{'title':'PJD6211', 'href':'/lv/products/projectors/pjd6211.htm'},{'title':'PJD6221', 'href':'/lv/products/projectors/pjd6221.htm'},{'title':'PJD6241', 'href':'/lv/products/projectors/pjd6241.htm'},{'title':'PJD6251', 'href':'/lv/products/projectors/pjd6251.htm'},{'title':'PJD6381', 'href':'/lv/products/projectors/pjd6381.htm'},{'title':'PJD5112', 'href':'/lv/products/projectors/pjd5112.htm'},{'title':'PJD6531', 'href':'/lv/products/projectors/pjd6531w.htm'},{'title':'PJD5352', 'href':'/lv/products/projectors/pjd5352.htm'},{'title':'PJD5152', 'href':'/lv/products/projectors/pjd5152.htm'},{'title':'PJD5221', 'href':'/lv/products/projectors/pjd5221.htm'},{'title':'PJD5231', 'href':'/lv/products/projectors/pjd5231.htm'},{'title':'PJD7382', 'href':'/lv/products/projectors/pjd7382.htm'},{'title':'PJD7383i', 'href':'/lv/products/projectors/pjd7383i.htm'},{'title':'Pro8200', 'href':'/lv/products/projectors/pro8200.htm'},{'title':'Pro8400', 'href':'/lv/products/projectors/viewsonic-all-projectors/pro8400.htm'},{'title':'Pro8450w', 'href':'/lv/products/projectors/pro8450w480677.htm'},{'title':'Pro8500', 'href':'/lv/products/projectors/pro8500.htm'},{'title':'PJD5133', 'href':'/lv/products/projectors/pjd5133.htm'},{'title':'PJD6223', 'href':'/lv/products/projectors/pjd6223.htm'},{'title':'PJD6253', 'href':'/lv/products/projectors/pjd6253.htm'},{'title':'PJD6553w', 'href':'/lv/products/projectors/pjd6553w.htm'},{'title':'PJD7383', 'href':'/lv/products/projectors/pjd7383.htm'},{'title':'PJD7583w', 'href':'/lv/products/projectors/pjd7583w.htm'},{'title':'PJD5353', 'href':'/lv/products/projectors/pjd5353.htm'}]},{'title':'LCD', 'href':'#'}]},{'title':'Wireless Presentation Gateway', 'href':'/lv/products/projectors/wireless-presentation-gateway/', items: [{'title':'WPG-150', 'href':'/lv/products/projectors/wireless-presentation-gateway/wireless-presentation-gateways-wpg150.htm'},{'title':'WPG-350', 'href':'/lv/products/projectors/wireless-presentation-gateway/wpg350.htm'}]},{'title':'Accessories', 'href':'/lv/products/projectors/accessories/', items: [{'title':'PGD-250', 'href':'/lv/products/projectors/accessories/pgd250.htm'},{'title':'VP3D1', 'href':'/lv/products/projectors/accessories/vp3d1.htm'}]}]},{'title':'ViewPad', 'href':'/lv/products/viewpad/', items: [{'title':'ViewPad 7', 'href':'/lv/products/viewpad/viewpad-7.htm'},{'title':'ViewPad 10', 'href':'/lv/products/viewpad/viewpad-10.htm'},{'title':'ViewPad 10pro', 'href':'/lv/products/viewpad/viewpad-10pro522552.htm'},{'title':'ViewPad 10e', 'href':'/lv/products/viewpad/viewpad-10e.htm'}]},{'title':'Consumer Electronics', 'href':'/lv/products/digital-photo-frames/', items: [{'title':'Digital Photo Frames', 'href':'/lv/products/digital-photo-frames/', items: [{'title':'VFA724W-50E', 'href':'/lv/products/digital-photo-frames/vfa724w50e.htm'},{'title':'VFD824-50E', 'href':'/lv/products/digital-photo-frames/vfd82450e.htm'},{'title':'VFM1036W-51E', 'href':'/lv/products/digital-photo-frames/vfm1036w51e.htm'},{'title':'DPF8-CAM', 'href':'/lv/products/digital-photo-frames/7-9/dpf8cam442194.htm'},{'title':'VFD873-50E', 'href':'/lv/products/digital-photo-frames/7-9/vfd87350e.htm'},{'title':'VFM886-50E', 'href':'/lv/products/vfm88650e.htm'},{'title':'VFA770w-50E', 'href':'/lv/products/digital-photo-frames/vfa770w50e.htm'}]},{'title':'Digital Media Player', 'href':'/lv/products/digital-media-player/', items: [{'title':'VMP73', 'href':'/lv/products/digital-media-player/vmp73.htm'},{'title':'VMP74', 'href':'/lv/products/digital-media-player/vmp74.htm'}]},{'title':'eBook', 'href':'/lv/products/ebook/', items: [{'title':'VEB620', 'href':'/lv/products/ebook/veb620.htm'},{'title':'VEB625', 'href':'/lv/products/ebook/veb625.htm'}]},{'title':'Smartphones    ', 'href':'/lv/products/smartphones/', items: [{'title':'V350  ', 'href':'/lv/products/v350.htm'}]},{'title':'Camcorder', 'href':'/lv/products/camcorder/', items: [{'title':'VC310', 'href':'/lv/products/camcorder/vc310.htm'},{'title':'VC320', 'href':'/lv/products/camcorder/vc320.htm'},{'title':'VC3D2', 'href':'/lv/products/camcorder/vc3d2.htm'},{'title':'VC415', 'href':'/lv/products/camcorder/vc415.htm'}]},{'title':'LED TV', 'href':'/lv/products/led-tv/', items: [{'title':'VT3250LED', 'href':'/lv/products/led-tv/vt3250led.htm'},{'title':'VT4250LED', 'href':'?cid=603323&modulePageId=284&parentCid=604505'}]}]},{'title':'Digital Signage', 'href':'/lv/products/digital-signage/', items: [{'title':'Type', 'href':'#', items: [{'title':'Commercial Display', 'href':'/lv/products/digital-signage/products/commercial-display178080/', items: [{'title':'CD3200', 'href':'/lv/products/digital-signage/products/commercial-display178080/cd3200.htm'},{'title':'CD4220', 'href':'/lv/products/digital-signage/products/commercial-display178080/cd4220.htm'}]},{'title':'Media Players', 'href':'/lv/products/digital-signage/products/media-players/', items: [{'title':'NMP-530', 'href':'/lv/products/digital-signage/products/media-players/nmp530.htm'}]}]},{'title':'Application', 'href':'#', items: [{'title':'Business', 'href':'/lv/business/digital-signage/'}]}]}],
_createMenu : function (items, level, genealogy) {

	// Create the menu element
	var div = document.createElement('div');
	
	// Add the genealogy ID and set the level className
	div.setAttribute('id', 'menu_' + genealogy.join('_'));
	div.className = 'level_'+level;
	
	// Begin the links inside our menu
	var html = '<div id="submenu_' + genealogy.join('_') + '" class="scroll"><ul>';
	for (var i=0; i<items.length; i++) {
		// If there are children inside the current list item
		var isParent = (items[i].items && items[i].items.length) ? true : false;
		html = html + '<li';
		if (i==items.length-1) html = html + ' class="last"';
		html = html + '><a href="'+items[i].href+'" class="link_'+(i+1);
		if (isParent) html = html + ' parent';
		html = html + '">'+items[i].title+'</a>';
		
		if (isParent) {
		
			// Increase the genealogy for the children
			genealogy[level]++;
			
			// Reset genealogy if we are on a top level item or a first level item 
			if (level == 0) genealogy = [genealogy[0]++,0,0];
			else if (level == 1) genealogy = [genealogy[0], genealogy[1], 0];

			// Recursion: create the child menu and increase the level by 1
			PINT.vs._createMenu(items[i].items, level+1, genealogy);
		}
	}
	html = html + '</ul></div>';
	div.innerHTML = html;
	
	// Add the menu to the document
	PINT.vs.menuContainer.appendChild(div);
	
	// Make the last div scrollable and then hide it (quirkiness of flexcroll)
	if (level == 3 && items.length > 6) { 
		
		// Creates the scroller and hides it (it has to be shown at first to get calculations right)
		CSBfleXcroll('submenu_' + genealogy.join('_'));
		div.style.display = 'none'; 
	}
	// Add listeners to the A tags
	YAHOO.util.Event.on(div.getElementsByTagName('a'), 'mouseover', PINT.vs._prepareMenu);
},
_prepareMenu : function(e) {
	var isLast = false;

	// Get the menu containing the link that was moused over.
	var menu = this.parentNode.parentNode.parentNode.parentNode;
	
	// Remove any previous selections
	YAHOO.util.Dom.removeClass(menu.getElementsByTagName('a'), 'selected');
	
	// Build out the genealogy of the current menu
	var genealogy = menu.id.split('_');
		genealogy = genealogy.slice(1,4);
		
	// Find the current menu level
	var level = menu.className.split('_')[1];
	
	// Find the level of the link (when added into the genealogy, we can figure out the menu to be shown)
	var nextLevel =  this.className.split(' ')[0].split('_')[1];
	if (genealogy[0] == 0) genealogy[0] = nextLevel;
	else if (genealogy[1] == 0) genealogy[1] = nextLevel;
	else if (genealogy[2] == 0) genealogy[2] = nextLevel;
	else isLast = true;
	
	if (!isLast) {
		// Select the link if it is a parent
		if (YAHOO.util.Dom.hasClass(this, 'parent')) YAHOO.util.Dom.addClass(this, 'selected');
		
		var genealogyId = 'menu_' + genealogy.join('_');
		
		// Hide previous divs by checking to see if they are a higher level than our current level AND making sure the next divToShow is not already showing
		var checkLevel = function(el) {
			return (el.className.split(' ')[0].split('_')[1] > level && el.id != genealogyId);
		}
		var divsToHide = YAHOO.util.Dom.getElementsBy(checkLevel, 'div', 'menu');
		YAHOO.util.Dom.setStyle(divsToHide, 'display', 'none');
		

		// Check to see if the next menu exists and that it's not currently showing
		var divToShow = YAHOO.util.Dom.get(genealogyId);
		
		// If it does, we show it
		if (divToShow && divToShow.style.display != 'block') PINT.vs._showMenu(divToShow, level);
	}
},
_showMenu : function(menu, level) {
	// by/from value default
	var position = [0,0];
	
	// Hardcoded by/from values
	if (level == 0) position = [162, 10];
	else if (level == 1) position = [182, 172];
	else if (level == 2) position = [182, 354];
	
	var slide = new YAHOO.util.Anim(menu, { 
	    left: { by : position[0], from : position[1] }  
	}, .25, YAHOO.util.Easing.easeOut); 
	slide.onStart.subscribe(function() { menu.style.left = position[1] + 'px'; menu.style.display = 'block'; });
	slide.animate();
	
	// Remove any pre-selections
	YAHOO.util.Dom.removeClass(menu.getElementsByTagName('a'), 'selected');
},
init : function() {
	PINT.vs.menuContainer = YAHOO.util.Dom.get('menu');	
    PINT.vs._createMenu(PINT.vs.menus, 0, [0,0,0]);
	PINT.vs.menuContainer.style.display = 'none';
	
	PINT.vs.menu = new PINT.MenuCreator({
        menus: [
			{ id: 'menu', trigger: 'productsMenuLink' },
			{ id: 'menu_shop', trigger: 'shopMenuLink' },
			{ id: 'menu_support', trigger: 'supportMenuLink' },
			{ id: 'menu_company', trigger: 'companyMenuLink' }

		],
        show:function(trigger,menu) {
			if (trigger.parentNode.className.substr(trigger.parentNode.className.length-6) !== '_hover') { 
                    trigger.parentNode.className += '_hover';
            }
			YAHOO.util.Dom.setStyle(menu, 'display', 'block');
			YAHOO.util.Dom.removeClass(menu.getElementsByTagName('a'), 'selected');
        },
        hide:function(trigger,menu) {
            if (trigger.parentNode.className.substr(trigger.parentNode.className.length-6) === '_hover') { 
                trigger.parentNode.className = trigger.parentNode.className.substr(0, trigger.parentNode.className.length-6);
            }
            if (menu.id == 'menu') YAHOO.util.Dom.setStyle(menu.childNodes, 'display', 'none');
           	YAHOO.util.Dom.setStyle(menu, 'display', 'none');
        }
	});

	// Removes the IE6 flicker during animation
	if (PINT.util.browser.bIe6) try { document.execCommand("BackgroundImageCache", false, true); } catch(err) {}
}
};

// This function creates a show/hide relationship between a trigger and menu object.
PINT.MenuCreator = function(obj) {
	PINT.checkMouseEvent = new YAHOO.util.CustomEvent();
	for (var oMenu in obj.menus) {
		(function(index, total) {
			var trigger = (obj.menus[index].trigger) ? YAHOO.util.Dom.get(obj.menus[index].trigger) : YAHOO.util.Dom.get(obj.menus[index]);
			var menu = (obj.menus[index].id) ? YAHOO.util.Dom.get(obj.menus[index].id) : YAHOO.util.Dom.get(obj.menus[index]).lastChild;

			if (!trigger || !menu || !obj.show || !obj.hide) return;

			function enterLink(e) {
				clearMenus();
				obj.show(trigger,menu);
				YAHOO.util.Event.stopEvent(e);
				YAHOO.util.Event.on(document.body, 'mouseout', exitField);
			}

			function exitLink(e) {
				if (!e) var e = window.event;
				if (e.stopPropagation) e.stopPropagation();
				else e.cancelBubble = true;
				var relTarg = e.relatedTarget || e.toElement;
				if (relTarg && relTarg != menu && relTarg.parentNode != menu && relTarg.parentNode.parentNode != menu) {
					obj.hide(trigger, menu);
                    YAHOO.util.Event.removeListener(document.body, 'mouseout', exitField);
					return false;
				}
				YAHOO.util.Event.stopEvent(e);
			}

			function exitField(e) {
				if (!e) var e = window.event;
				var tg = (window.event) ? e.srcElement : e.target;
				if (e.stopPropagation) e.stopPropagation();
				else e.cancelBubble = true;
				//if (tg.nodeName != 'DIV' && tg.nodeName != 'UL') return;
				var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
				while (reltg != tg && reltg.nodeName != 'BODY' && reltg.nodeName != 'HTML') {
					if (reltg == this) return;
					reltg = reltg.parentNode
				}
				if (reltg == tg) return;
				obj.hide(trigger, menu);
				YAHOO.util.Event.removeListener(document.body, 'mouseout', exitField);
				YAHOO.util.Event.stopEvent(e);
			}
			
			function clearMenus() {
				for (var i=0; i<total; i++) {
					obj.hide(YAHOO.util.Dom.get(obj.menus[i].trigger), YAHOO.util.Dom.get(obj.menus[i].id));
				}
			}
			YAHOO.util.Event.on(trigger, 'mouseover', enterLink);
			YAHOO.util.Event.on(trigger, 'mouseout', exitLink);
			YAHOO.util.Event.on(menu, 'mouseout', exitField);
		}(oMenu, obj.menus.length));
	}
};
if (!PINT.isEditing) YAHOO.util.Event.onAvailable('menu', PINT.vs.init);
