
	var currentProductsList
	var currentLinksList
	var cancelPropagation = function( e ) {
		var e = getEventObj( e )
		if (e) {
			if (e.stopPropagation)
				e.stopPropagation()
				else
				e.cancelBubble = true
			return true
			}
		return false
		}
		
	function getEventObj( e ) {
		return e ? e : event
		}
		
	function getGlobalOffset( obj ) {
		var xy = {x:0, y:0}
		do {
			xy.x += obj.offsetLeft
			xy.y += obj.offsetTop
			} while ((obj = obj.offsetParent) && (!arguments[1] || arguments[1] != obj))
		return xy
		}

	function getCentered( oDiv ) {
		
		if (oDiv) {
			var aS = oDiv.getElementsByTagName('a')
			var aSHeight = 0
			for (var i=0; i<aS.length; i++)
				aSHeight += aS[i].offsetHeight
			aS[0].style.marginTop = Math.floor((165-aSHeight)/2) + 'px'		
			return true
			}
			
		return false
		}
		
	function correctMenu() {
		var menuObj = document.getElementById('menu')
		var currentList = document.getElementById('currentList')
		var relObj = document.getElementById('productsImages')
		var productsList = document.getElementById('productsImages')
		var colorsList = document.getElementById('colors')
		
		// Выбор позиции
		if (menuObj) {
			if (currentList) {
				getCentered( currentList )
				if (!/static/.test(currentList.className))
					currentList.style.height = '1px'   
				else
					currentList.style.visibility = 'visible'
				}
			with (menuObj.style) {
				top = (relObj) 
					? relObj.offsetTop - currentList.offsetTop + 75 + 'px'
					: '235px'
				visibility = 'visible'
				}
			}
			
		// Задание hover для картинок
		if (productsList && currentList) {
			currentLinksList = currentList.getElementsByTagName('a')
			currentProductsList = productsList.getElementsByTagName('a')
			for (var i=0; i<currentLinksList.length && i<currentProductsList.length; i++) {
			//	currentProductsList[i].onmouseover = new Function('currentLinksList['+i+'].className+=" this"')
			//	currentProductsList[i].onmouseout = new Function('currentLinksList['+i+'].className=currentProductsList['+i+'].className.replace(/ ?this/, "")')
				}
			}
			
		// Параметры объекта
		if (productsList) {
			var sumWidth = 0
			for (var i=0; i<currentProductsList.length; i++)
				sumWidth += currentProductsList[i].offsetWidth
			productsList.style.width = sumWidth + 10 + 'px'
			}
			
		// Установка цветного меню
		if (window.coloredMenu) {
			var colors = colorsList.getElementsByTagName('a')
			var colorsObjs = []
			for (var i=0; i<colors.length; i++)
				colorsObjs[i] = colors[i]
			for (var i=0; i<colorsObjs.length; i++) {
				if (coloredMenu[i]) {
					var a = document.createElement('a')
					with (a) {
						with(a.appendChild( document.createElement('span') ))
							appendChild( document.createTextNode(coloredMenu[i].title) )
						href = coloredMenu[i].href
						}
					
					colorsObjs[i].onmouseover = new Function('coloredMenu['+i+'].over=true; if (!coloredMenu['+i+'].rewindAnimation.isRunning()) { if (!coloredMenu['+i+'].hideAnimation.isRunning()) coloredMenu['+i+'].showAnimation.start(500); else { coloredMenu['+i+'].hideAnimation.stop(); coloredMenu['+i+'].rewindAnimation.start(); } } coloredMenu['+i+'].hideAnimation.clearStartDelay();') // Задержка при первичном выводе подсказки (в милисекундах)
					colorsObjs[i].onmouseout = new Function('coloredMenu['+i+'].over=false; if (!coloredMenu['+i+'].showAnimation.isRunning() && !coloredMenu['+i+'].rewindAnimation.isRunning()) coloredMenu['+i+'].hideAnimation.start(500); coloredMenu['+i+'].showAnimation.clearStartDelay(); ') // Задержка при скрытии подсказки
					colorsObjs[i].href = a.href
					colorsObjs[i].appendChild(a)
					
					// Анимация
					coloredMenu[i].showAnimation = new myAnimation({
						obj: a,
						duration: 500,
						speed: 35,
						motion: 'easeInOutQuint',
						transformations: [
							{ property: 'marginLeft', start: 0, end: -123 },
							{ property: 'width', start: 0, end: 123 }
							]
						})
					coloredMenu[i].hideAnimation = new myAnimation({
						obj: a,
						duration: 500,
						speed: 35,
						motion: 'easeInOutQuint',
						transformations: [
							{ property: 'marginLeft', start: -123, end: 0 },
							{ property: 'width', start: 123, end: 0 }
							]
						})
					
					coloredMenu[i].rewindAnimation = new myAnimation({
						obj: a,
						duration: 500,
						speed: 35,
						motion: 'easeOutQuint',
						transformations: [
							{ property: 'marginLeft', start: 0, end: -123 },
							{ property: 'width', start: 0, end: 123 }
							]
						})
						
					// Раздача слонов
					coloredMenu[i].showAnimation.addEventListener( 'complete', new Function('if (!coloredMenu['+i+'].over) { coloredMenu['+i+'].hideAnimation.start(0); } coloredMenu['+i+'].now = true; '), false) // Задержка при наведении и скрытии в процессе наведения
					coloredMenu[i].hideAnimation.addEventListener( 'complete', new Function('if (coloredMenu['+i+'].over) { coloredMenu['+i+'].showAnimation.start(0); } coloredMenu['+i+'].now = false; '), false) // Задержка при скрытии и наведении в процессе скрытия
					coloredMenu[i].rewindAnimation.addEventListener( 'beforeStart', new Function('coloredMenu['+i+'].rewindNow=true; coloredMenu['+i+'].rewindAnimation.transformations[0].start = parseInt(coloredMenu['+i+'].rewindAnimation.obj.style.marginLeft); coloredMenu['+i+'].rewindAnimation.transformations[1].start = parseInt(coloredMenu['+i+'].rewindAnimation.obj.style.width)'), false )
					coloredMenu[i].rewindAnimation.addEventListener( 'complete', new Function('coloredMenu['+i+'].hideAnimation.reset(); if (!coloredMenu['+i+'].over) coloredMenu['+i+'].hideAnimation.start(0) '), false )
					
					}
				}
			}
		
		return true
		}
	
function boxFly() {
	var destionationObj = document.getElementById('currentList')
	var colorsList = document.getElementById('colors')
	var productsList = document.getElementById('productsImages')
	
	// Если объекты не определены
	if (!colorsList || !destionationObj)
		return false
	
	// Ищем бокс заданного цвета
	var srcColorObj
	var colors = colorsList.getElementsByTagName('a')
	for (var i=0; i<colors.length && !srcColorObj; i++)
		if (colors[i].className == destionationObj.className)
			srcColorObj = colors[i]

	// Создаем клон бокса
	var boxObj = srcColorObj.cloneNode(true)
	with (boxObj) {
		boxObj.id = 'flyingBox'
		style.left = getGlobalOffset(srcColorObj).x + 'px'
		style.top = getGlobalOffset(srcColorObj).y + 'px'
		}
	colorsList.appendChild( boxObj )

	// Анимация бокса
	var boxAnimation = new myAnimation({
		obj: document.getElementById('flyingBox'),
		duration: 1000,
		speed: 35,
		motion: 'easeInOutQuint',
		transformations: [
			{ property: 'left', start: getGlobalOffset(srcColorObj).x, end: 0 },
			{ property: 'top', start: getGlobalOffset(srcColorObj).y, end: getGlobalOffset(destionationObj, document.body).y - 75 },
			{ property: 'width', start: srcColorObj.offsetWidth, end: destionationObj.offsetWidth },
			{ property: 'height', start: srcColorObj.offsetHeight, end: 165 }
			]
		})
		
	// Анимация меню
	var menuAnimation = new myAnimation({
		obj: document.getElementById('currentList'),
		duration: 800,
		speed: 35,
		motion: 'easeInOutQuint',
		transformations: [
			{ property: 'height', start: 1, end: document.all ? 165 : 164 }
			]
		})
	var rootMenuAnimation = new myAnimation({
		obj: document.getElementById('menu'),
		duration: 800,
		speed: 35,
		motion: 'easeInOutQuint',
		transformations: [
			{ property: 'marginTop', start: 0, end: -75 }
			]
		})
	
	// Анимация продуктов
	var productsAnimation = new myAnimation({
		obj: productsList,
		duration: 1500,
		speed: 20,
		transformations: [
			{ property: 'marginLeft', start: productsList.offsetWidth*-1+10, end: 0, motion: 'easeInOutQuint' }
			]
		})
	                    	
	// Раздача слонов
	menuAnimation.addEventListener( 'start', function() { document.getElementById('currentList').style.visibility='visible' }, false )
	boxAnimation.start()
	menuAnimation.start()
	rootMenuAnimation.start()
	productsAnimation.start( 650 )
	
	return true
	}
	
	function obj2str( obj ) {
		if (obj) {
			var arr = new Array()
			var isArray = (obj.constructor == Array) ? true : false
			for (var i in obj) {
				if (obj[i].constructor == Array || obj[i].constructor == Object)
					if (isArray)
						arr.push(obj2str(obj[i]))
						else
						arr.push(i+':'+obj2str(obj[i]))
					else { 
						var str = (obj[i].constructor == String) ? "'"+obj[i]+"'" : obj[i]
						if (isArray) 
							arr.push(str)
							else
							arr.push(i+':'+str)
						}
				}
			return (isArray) ? '['+arr.join(',')+']' : '{'+arr.join(',')+'}'
			} else
				return null
		}

