function $(id) { return document.getElementById(id); }

function menu() {
	var nodes = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<nodes.length; i++) {
		nodes[i].onmouseover=function() { this.className+=" over"; }
		nodes[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" over\\b"), ""); }
	}
}

function move(items,to,shift) {
	items = $(items);
	box = items.parentNode;

	if ((to == 'top')||(to == 'bottom')) { direct = 'top'; core(direct); }
	if ((to == 'left')||(to == 'right')) { direct = 'left'; core(direct); }

	function core(direct) {
		if (!items.style[direct]) items.style[direct] = 0;
		var shif_now = parseInt(items.style[direct]);
		if (((to == 'top')||(to == 'left'))&&(shif_now < 0)) items.style[direct] = (shif_now + shift) + 'px';
		if ((to == 'bottom')&&(box.scrollHeight >= (box.offsetHeight + shift))) items.style[direct] = (shif_now - shift) + 'px';
		if ((to == 'right')&&(box.scrollWidth >= (box.offsetWidth + shift))) items.style[direct] = (shif_now - shift) + 'px';
	}
}

function photogal(img,img_big) {
//	$('photogal_big').src = img;
    $('#photogal_big').attr({ 
        src: img
    });
//	$('photogal_big').parentNode.href = img_big;
	$('#photogal_big').parent().attr({ 
        href: img_big
    });
}

function mi_switches(link) {
	linkRoot = link.parentNode.parentNode;
	blockRoot = $('mod_table');
	j = 0;
	n = 0;
	for (i=0; i<linkRoot.childNodes.length; i++) {
		node = linkRoot.childNodes[i];
		if (node.nodeName == "TD") {
			if (node == link.parentNode) num = j;
			node.className = node == link.parentNode ? "act" : "";
			j++;
		}
	}
	for (m=0; m<blockRoot.childNodes.length; m++) {
		node = blockRoot.childNodes[m];
		if (node.nodeName == "TR") {
			node.className = n == num ? "" : "n_act";
			n++;
		}
	}
}

function popup(url,width,height) {
	var okno, url, width, height;
	okno = window.open(url,'_blank','copyhistory=no,directories=no,location=no,status=no,scrollbars=yes,menubar=no,toolbar=no,resizable=no,width='+width+',height='+height);
}

$(
function(){
	var men_i = $('#top_menu li');
		men_i.hover(
			function(){
				$(this).find('#menu_first_level').show();
			},
			function(){
			$(this).find('#menu_first_level').hide();
			}
		);	
});

function showlink() {
    $(document).ready(function(){
        $("div.car-showlink").click(function () {
            if ($(this).parent().find('.car-options').is(":hidden")){
                $(this).text("Скрыть опции");
                $(this).parent().find('.car-options').show();
            } else {
                $(this).parent().find('.car-options').hide();
                $(this).text("Показать опции")    
            }
        });
//        $("div.divplus").click(function () {
//            if ($(this).prev().is(":hidden")){
//                $(this).css('background','url(/images/arrowup.png) right center no-repeat');
////                $(this).children("span").text("Свернуть");
//    			$(this).prev().stop(true,true).slideToggle("slow");
//    		}else{
//    		    $(this).css('background','url(/images/arrowdown.png) right center no-repeat');
////    		    $(this).children("span").text("Развернуть");
////    		    $(this).css('background-color','#fff');
//    			$(this).prev().stop(true,true).hide();
//    		}
//        });  
    });
}
