
function mclick(id){
	var state = $('m2_'+id).visible();
	var arr = $('menu_block').getElementsByClassName('submenu');
	arr.each(Element.hide);
	if (state == false){
		$('m2_'+id).show(); //$('m2_'+id).show();
		new Insertion.Top(document.body, '<div id="over" onmouseover="Effect.SlideUp(\'m2_'+id+'\');$(\'over\').remove()"></div>');
	}
}
 
/*var m2prev_state = false;
function mMenu2(id){
	if ($('menu2box')){
		if (m2prev_state == id){
			$('menu2box').toggle();
			return;	
		}
		if ($('menu2box').visible() == false){
			$('menu2box').show();
		}
		if (m2prev_state != id){
			$('menu2cont').update('Идет загрузка...');
			var load = true;
		}		
	} else {
	    new Insertion.Top(document.body, "<table cellpadding=0 cellspacing=0 border=0 class=menu2box id=menu2box><tr><td id=menu2boxr><img src=/pic/f/menu2top.png width=193 height=14 alt=''></td></tr><tr><td id=menu2cont>Идет загрузка...</td></tr><tr><td id=menu2boxr><img src=/pic/f/menu2bot.png width=193 height=14 alt=''></td></tr></table>");
	    var load = true;
	}
    Position.clone('m1_'+id, 'menu2box', {'offsetTop':40});
    m2prev_state = id;
    $('menu2box').setStyle({'width':'193px'});
    if (load){
    	doLoad('/PWE/etc/loader.php?mode=local&module=/etc/menu&template=menu.aj&id='+id, null, 'menu2cont');
    }
}*/

Position.Window = {
    //extended prototypes position to return
    //the scrolled window deltas
    getDeltas: function() {
        var deltaX =  window.pageXOffset
            || document.documentElement.scrollLeft
            || document.body.scrollLeft
            || 0;
        var deltaY =  window.pageYOffset
            || document.documentElement.scrollTop
            || document.body.scrollTop
            || 0;
        return [deltaX, deltaY];
    },
    //extended prototypes position to
    //return working window's size, 
    //copied this code from the 
    size: function() {
        var winWidth, winHeight, d=document;
        if (typeof window.innerWidth!='undefined') {
            winWidth = window.innerWidth;
            winHeight = window.innerHeight;
        } else {
            if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
                winWidth = d.documentElement.clientWidth
                winHeight = d.documentElement.clientHeight
            } else {
                if (d.body && typeof d.body.clientWidth!='undefined') {
                    winWidth = d.body.clientWidth
                    winHeight = d.body.clientHeight
                }
            }
        }
        return [winWidth, winHeight];
    }
}
//my own custom effect that basically
//calls the Effect.Move Scriptaculous
//effect with the correct window offsets
Effect.KeepFixed = function(element, offsetx, offsety) {
    var _scroll = Position.Window.getDeltas();
    //var _window = Position.Window.size();
    var elementDimensions = Element.getDimensions(element);
    var eWidth = elementDimensions.width;
    var eHeight = elementDimensions.height;
	var moveX =  qmInitPos[0] + offsetx;
    var moveY =  qmInitPos[1] + _scroll[1] + offsety;
    var stopY =  qmStopPos[1] - eHeight;
   	if (moveY > stopY)
        moveY = stopY;
    if (moveY < qmInitPos[1])
        moveY = qmInitPos[1];       
   	return new Effect.Move(element, { x: moveX, y: moveY, mode: 'absolute' });
}


//the function that calls the KeepFixed effect.
//It accepts the id, and offsets from bottom left
function quickmenu() {
    new Effect.KeepFixed('quick_menu', 40, -100);
}

function commitFlashObject(_obj, _container){
	_output=""
	_paramoutput=""
	_src=""
	_ver=""
	for(_cO in _obj){
		_output+=_cO+"=\""+_obj[_cO]+"\" "
		_paramoutput+="<param name="+_cO+" value=\""+_obj[_cO]+"\">";
		if(_cO=="movie")_src="src=\""+_obj[_cO]+"\"";
		if(_cO=="version")_ver=_obj[_cO];
	}
	if(_ver=="")_ver="8,0,0,0"
	ihtm="<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+_ver+" "+_output+">\n"
	ihtm+=_paramoutput+"\n"
	ihtm+="<embed "+_src+" pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash "+_output+">\n";
	ihtm+="</embed>\n";
	ihtm+="</object>\n";
	document.getElementById(_container).innerHTML=ihtm	
}

/* Quick Menu */

var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";

function getRef(id){
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}


function getSty(id){
	return (isNS4 ? getRef(id) : getRef(id).style);
}

function moveRightEdge(){
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;

	if (isNS4){
		yMenuFrom   = divMenu.top;
		yMenuTo     = windows.pageYOffset + 50;
	} else if (isDOM){
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 50;
	}
	if (yMenuTo < startY)
		yMenuTo = startY;	
	timeoutNextCheck = 500;

	if (yMenuFrom != yMenuTo){
		yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
		if (yMenuTo < yMenuFrom){
			yOffset = -yOffset;
		}
		if (isNS4 && (divMenu.top + yOffset) < stopY){
			divMenu.top += yOffset;
		} else if (isDOM && (parseInt (divMenu.style.top, 10) + yOffset) < stopY) {
			divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
		}
		timeoutNextCheck = 10;
	}
	setTimeout ("moveRightEdge()", timeoutNextCheck);
}
